This file is indexed.

/usr/share/tcltk/tklib0.6/plotchart/plotconfig.tcl is in tklib 0.6-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
# plotconfig.tcl --
#     Facilities for configuring the various procedures of Plotchart
#


# plotstyle --
#     Plotting style mechanism (this proc needs to be first in this file, since
#                               the namespace eval uses this proc)
#
# Arguments:
#     cmd         subcommand to the plotstyle command
#                 Can be configure|current|load|merge|names ('merge' not implemented yet)
#     stylename   symbolic name of the style (defaults to 'default')
#     args        additional optional arguments (only used in 'configure' subcommand)
#
# Result:
#     The name of the current style (for subcommand 'current'),
#     a list of available styles (for subcommand 'names'),
#     else the empty string
#
# Side effects:
#     Styles are created, loaded, or modified
#
proc ::Plotchart::plotstyle {cmd {stylename default} args} {
    variable style
    variable config
    switch $cmd {
        configure {
            #
            # 'plotstyle configure stylename type component property value ?type component property value ...?'
            #
            # register the 'default' style:
            set newStyle false
            if { [lsearch -exact $config(styles) $stylename] < 0 } {
                # this is a new style -> register it:
                lappend config(styles) $stylename
                set newStyle true
            }
            foreach {type component property value} $args {
                set style($stylename,$type,$component,$property) $value
                if { $newStyle } {
                    # also save the item as default, so it can be restored via plotconfig:
                    set style($stylename,$type,$component,$property,default) $value
                }
            }
            if { $config(currentstyle) eq $stylename } {
                # load the modified style items:
                foreach {type component property value} $args {
                    set config($type,$component,$property) $value
                }
            }
        }
        current {
            #
            # 'plotstyle current'
            #
            return $config(currentstyle)
        }
        load {
            #
            # 'plotstyle load stylename'
            #
            if { [lsearch -exact $config(styles) $stylename] < 0 } {
                return -code error "no such plotting style '$stylename'"
            }
            foreach {item value} [array get style $stylename,*] {
                set item [string map [list $stylename, {}] $item]
                set config($item) $value
            }
            set config(currentstyle) $stylename
        }
        merge {
            #
            # 'plotstyle merge stylename otherstylename pattern ?otherstylename pattern ...?'
            #

        }
        names {
            #
            # 'plotstyle names'
            #
            return $config(styles)
        }
    }
}

namespace eval ::Plotchart {
    variable config

    # FontMetrics --
    #     Determine the font metrics
    #
    # Arguments:
    #     w         Canvas to be used
    #
    # Result:
    #     List of character width and height
    #
    proc FontMetrics {w} {
        set item        [$w create text 0 0 -text "M"]
        set bbox        [$w bbox $item]
        set char_width  [expr {[lindex $bbox 2] - [lindex $bbox 0]}]
        set char_height [expr {[lindex $bbox 3] - [lindex $bbox 1]}]
        if { $char_width  <  8 } { set char_width   8 }
        if { $char_height < 14 } { set char_height 14 }
        $w delete $item

        return [list $char_width $char_height]
    }

    #
    # List of styles
    #
    set config(styles) [list]

    #
    # The currently selected style
    #
    set config(currentstyle) {}

    #
    # Define implemented chart types
    #
    set config(charttypes) {
        xyplot xlogyplot logxyplot logxlogyplot
        piechart spiralpie polarplot
        histogram horizbars vertbars ganttchart
        timechart stripchart isometric 3dplot 3dbars
        radialchart txplot 3dribbon boxplot windrose
        targetdiagram performance table
    }

    # define implemented components for each chart type:
    foreach {type components} {
        xyplot        {title subtitle margin text legend leftaxis rightaxis bottomaxis background mask}
        xlogyplot     {title subtitle margin text legend leftaxis rightaxis bottomaxis background mask}
        logxyplot     {title subtitle margin text legend leftaxis rightaxis bottomaxis background mask}
        logxlogyplot  {title subtitle margin text legend leftaxis rightaxis bottomaxis background mask}
        piechart      {title subtitle margin text legend                               background      labels slice}
        spiralpie     {title subtitle margin text legend                               background      labels slice}
        polarplot     {title subtitle margin text legend axis                          background}
        histogram     {title subtitle margin text legend leftaxis rightaxis bottomaxis background mask}
        horizbars     {title subtitle margin text legend leftaxis rightaxis bottomaxis background mask bar object}
        vertbars      {title subtitle margin text legend leftaxis rightaxis bottomaxis background mask bar}
        ganttchart    {title subtitle margin text legend axis                          background}
        timechart     {title subtitle margin text legend leftaxis rightaxis bottomaxis background}
        stripchart    {title subtitle margin text legend leftaxis rightaxis bottomaxis background mask}
        isometric     {title subtitle margin text legend leftaxis rightaxis bottomaxis background mask}
        3dplot        {title subtitle margin text legend xaxis yaxis zaxis             background}
        3dbars        {title subtitle margin text legend leftaxis rightaxis bottomaxis background}
        radialchart   {title subtitle margin text legend leftaxis rightaxis bottomaxis background}
        txplot        {title subtitle margin text legend leftaxis rightaxis bottomaxis background mask}
        3dribbon      {title subtitle margin text legend leftaxis rightaxis bottomaxis background}
        boxplot       {title subtitle margin text legend leftaxis rightaxis bottomaxis background mask bar}
        windrose      {title subtitle margin text legend axis                          background}
        targetdiagram {title subtitle margin text legend leftaxis rightaxis bottomaxis background mask limits}
        performance   {title subtitle margin text legend leftaxis rightaxis bottomaxis background mask limits}
        table         {title subtitle margin background header oddrow evenrow cell frame}
    } {
        set config($type,components) $components
    }

    # define implemented properties for each component:
    # (the '-' means that the component inherits the properties of the previous component on the list)
    foreach {component properties} {
        leftaxis   {color thickness font format ticklength textcolor labeloffset minorticks shownumbers showaxle render vtextoffset subtextcolor subtextfont vsubtextfont vsubtextcolor usesubtext usevsubtext}
        rightaxis  -
        axis       {color thickness font format ticklength textcolor labeloffset minorticks shownumbers showaxle render justify subtextcolor subtextfont usesubtext}
        topaxis    -
        bottomaxis -
        xaxis      -
        yaxis      -
        zaxis      -
        margin     {left right top bottom}
        title      {textcolor font anchor background}
        subtitle   {textcolor font anchor background}
        text        -
        labels     {textcolor font placement sorted shownumbers format formatright}
        background {outercolor innercolor}
        legend     {background border position}
        limits     {color}
        bar        {barwidth innermargin outline}
        mask       {draw}
        header     {background font color height anchor}
        oddrow     {background font color height anchor}
        evenrow    {background font color height anchor}
        cell       {background font color anchor leftspace rightspace topspace}
        frame      {color outerwidth innerwidth}
        slice      {outlinewidth outline startangle direction}
        object     {transposecoordinates}
    } {
        if { $properties eq "-" } {
            set properties $lastProperties
        }
        set config($component,properties) $properties
        set lastProperties $properties
    }

    # get some font properties:
    canvas .invisibleCanvas
    set invisibleLabel [.invisibleCanvas create text 0 0 -text "M"]

    foreach {char_width char_height} [FontMetrics .invisibleCanvas] {break}
    set config(font,char_width)  $char_width
    set config(font,char_height) $char_height

    # values for the 'default' style:
    set _color         "black"
    set _font          [.invisibleCanvas itemcget $invisibleLabel -font]
    set _subtextfont   $_font
    set _subtextcolor  $_color
    set _vsubtextfont  $_font
    set _vsubtextcolor $_color
    set _usesubtext    0
    set _usevsubtext   0
    set _thickness     1
    set _format        ""
    set _ticklength    3
    set _minorticks    0
    set _textcolor     "black"
    set _anchor        n
    set _labeloffset   2
    set _left          [expr {$char_width  * 8}]
    set _right         [expr {$char_width  * 4}]
    set _top           [expr {$char_height * 2}]
    set _bottom        [expr {$char_height * 2 + 2}]
    set _bgcolor       "white"
    set _outercolor    "white"
    set _innercolor    "white"  ;# Not implemented yet: "$w lower data" gets in the way
    set _background    "white"
    set _border        "black"
    set _position      "top-right"
    set _barwidth      0.8
    set _innermargin   0.2
    set _outline       black
    set _outlinewidth  1
    set _vtextoffset   2
    set _draw          1
    set _shownumbers   1
    set _showaxle      1
    set _leftspace     5
    set _rightspace    5
    set _topspace      5
    set _height        [expr {$char_height + 2*$_topspace}]
    set _anchor        center
    set _outerwidth    2
    set _innerwidth    1
    set _startangle    0
    set _direction     +
    set _placement     out    ;# piechart label placement: 'out' or 'in'
    set _render        simple ;# rendering of text: 'simple' or 'text'
    set _sorted        0      ;# piechart and spiral pie
   #set _shownumbers   0      ;# piechart and spiral pie      - conflict with axes - see below
   #set _format        "%s (%g)"  ;# piechart and spiral pie
    set _formatright   ""         ;# piechart and spiral pie
    set _transposecoordinates 0 ;# horizontal barchart
    set _justify       "left"


    destroy .invisibleCanvas

    #
    # Define the 'default' style
    #
    foreach type $config(charttypes) {
        foreach component $config($type,components) {
            foreach property $config($component,properties) {
                plotstyle configure "default" $type $component $property [set _$property]
            }
        }
        #
        # Default colour for title bar: same as outercolour
        #
        plotstyle configure "default" $type title background ""
    }
    #
    # Specific defaults
    #
    plotstyle configure "default" targetdiagram limits color "gray"
    plotstyle configure "default" table margin left 30 right 30
    plotstyle configure "default" piechart  labels shownumbers 0
    plotstyle configure "default" piechart  labels format      "%s (%g)"
    plotstyle configure "default" spiralpie labels shownumbers 0
    plotstyle configure "default" spiralpie labels format      "%s (%g)"
    plotstyle configure "default" polarplot axis   color       "gray"

    #
    # load the style
    #
    plotstyle load default
}

# plotconfig --
#     Set or query general configuration options of Plotchart
#
# Arguments:
#     charttype         Type of plot or chart or empty (optional)
#     component         Component of the type of plot or chart or empty (optional)
#     property          Property of the component or empty (optional)
#     value             New value of the property if given (optional)
#                       (if "default", default is restored)
#
# Result:
#     No arguments: list of supported chart types
#     Only chart type given: list of components for that type
#     Chart type and component given: list of properties for that component
#     Chart type, component and property given: current value
#     If a new value is given, nothing
#
# Note:
#     The command contains a lot of functionality, but its structure is
#     fairly simple. No property has an empty string as a sensible value.
#
proc ::Plotchart::plotconfig {{charttype {}} {component {}} {property {}} args} {
    variable config
    variable style

    if { $charttype == {} } {
        return $config(charttypes)
    } else {
        if { [lsearch $config(charttypes) $charttype] < 0 } {
            return -code error "Unknown chart type - $charttype"
        }
    }

    if { $component == {} } {
        return $config($charttype,components)
    } else {
        if { [lsearch $config($charttype,components) $component] < 0 } {
            return -code error "Unknown component '$component' for this chart type - $charttype"
        }
    }

    if { $property == {} } {
        return $config($component,properties)
    } else {
        if { [lsearch $config($component,properties) $property] < 0 } {
            return -code error "Unknown property '$property' for this component '$component' (chart: $charttype)"
        }
    }

    if { $args eq {} } {
        return $config($charttype,$component,$property)
    } else {
        set args [linsert $args 0 $property]
        foreach {property value} $args {
            if { $value == "default" } {
                set config($charttype,$component,$property) \
                $style($config(currentstyle),$charttype,$component,$property)
            } else {
                if { $value == "none" } {
                    set value ""
                }
                set config($charttype,$component,$property) $value
            }
        }
    }
}

# CopyConfig --
#     Copy the configuration options to a particular plot/chart
#
# Arguments:
#     charttype         Type of plot or chart
#     chart             Widget of the actual chart
#
# Result:
#     None
#
# Side effects:
#     The configuration options are available for the particular plot or
#     chart and can be modified specifically for that plot or chart.
#
proc ::Plotchart::CopyConfig {charttype chart} {
    variable config

    foreach {prop value} [array get config $charttype,*] {
        set chprop [string map [list $charttype, $chart,] $prop]
        set config($chprop) $value
    }
}

# plotmethod --
#     Register a new plotting method
#
# Arguments:
#     charttype         Type of plot or chart
#     methodname        Name of the method
#     plotproc          Plotting procedure that implements the method
#
# Result:
#     None
#
# Side effects:
#     Registers the plotting procedure under the method name,
#     so that for that type of plot/chart you can now use:
#
#         $p methodname ...
#
#     and the plotting procedure is invoked.
#
#     The plotting procedure must have the following interface:
#
#         proc plotproc {plot widget ...} {...}
#
#     The first argument is the identification of the plot
#     (the $p in the above example), the second is the name
#     of the widget. This way you can use canvas subcommands
#     via $widget and Plotchart's existing commands via $plot.
#
proc ::Plotchart::plotmethod {charttype methodname plotproc} {

    variable methodProc

    set fullname [uplevel 1 [list namespace which $plotproc]]

    if { $fullname != "" } {
        set methodProc($charttype,$methodname) [list $fullname $charttype]
    } else {
        return -code error "No such command or procedure: $plotproc"
    }
}