Tk Library Source Code

Check-in [2717837a22]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Introduced two new subcommands for timecharts (suggestion by Nick Matthews) and a new subcommand for 3D plots Adapted two examples to take advantage of these new subcommands
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:2717837a22da9a0f6077c94be01fd1f858fafd7d
User & Date: markus 2014-06-23 07:58:53
Context
2014-06-25
10:51
Remove leftover test statement from the example check-in: d383b32b42 user: markus tags: trunk
2014-06-23
07:58
Introduced two new subcommands for timecharts (suggestion by Nick Matthews) and a new subcommand for 3D plots Adapted two examples to take advantage of these new subcommands check-in: 2717837a22 user: markus tags: trunk
2014-03-19
13:29
Add missing source file check-in: adac221980 user: markus tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to examples/plotchart/plotdemos1.tcl.

1
2
3
4


5
6
7
8
9
10
11
12
...
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
#! /bin/sh
# -*- tcl -*- \
exec tclsh "$0" ${1+"$@"}



package require Tcl 8.4
package require Tk
package require Plotchart

# plotdemos1.tcl --
#    Test program 1 for the Plotchart package
#

................................................................................

   expr { 3.0 * (1.0-($x1*$x1+$y1*$y1))*(1.0-($x1*$x1+$y1*$y1)) }
}

toplevel .h3
canvas .h3.c  -bg white -width 400 -height 300
canvas .h3.c2 -bg white -width 400 -height 250

pack .h3.c .h3.c2

set s [::Plotchart::create3DPlot .h3.c {0 10 3} {-10 10 10} {0 10 2.5}]
$s title "3D Plot"
$s plotfunc cowboyhat

set s [::Plotchart::create3DPlot .h3.c2 {0 10 3} {-10 10 10} {0 10 2.5}]
$s title "3D Plot - data "
$s colour "green" "black"
$s plotdata { {1.0 2.0 1.0 0.0} {1.1 3.0 1.1 -0.5} {3.0 1.0 4.0 5.0} }







set s [::Plotchart::createTXPlot .c4 {2006-01-01 2007-01-01 120} {0.0 100.0 20.0}]

$s dataconfig series1 -colour "red"
$s dataconfig series2 -colour "blue"

$s xtext "Time"




>
>
|







 







>
|










>
>
>
>
>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
...
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
#! /bin/sh
# -*- tcl -*- \
exec tclsh "$0" ${1+"$@"}

set auto_path [concat ../../modules/plotchart $auto_path]

package require Tcl 8.5
package require Tk
package require Plotchart

# plotdemos1.tcl --
#    Test program 1 for the Plotchart package
#

................................................................................

   expr { 3.0 * (1.0-($x1*$x1+$y1*$y1))*(1.0-($x1*$x1+$y1*$y1)) }
}

toplevel .h3
canvas .h3.c  -bg white -width 400 -height 300
canvas .h3.c2 -bg white -width 400 -height 250
canvas .h3.c3 -bg white -width 400 -height 250
pack .h3.c .h3.c2 .h3.c3

set s [::Plotchart::create3DPlot .h3.c {0 10 3} {-10 10 10} {0 10 2.5}]
$s title "3D Plot"
$s plotfunc cowboyhat

set s [::Plotchart::create3DPlot .h3.c2 {0 10 3} {-10 10 10} {0 10 2.5}]
$s title "3D Plot - data "
$s colour "green" "black"
$s plotdata { {1.0 2.0 1.0 0.0} {1.1 3.0 1.1 -0.5} {3.0 1.0 4.0 5.0} }

set s [::Plotchart::create3DPlot .h3.c3 {0 10 3} {-10 10 10} {0 10 2.5}]
$s title "3D Plot - data "
$s colour "green" "black"
$s interpolatedata { {1.0 2.0 1.0 0.0} {1.1 3.0 1.1 -0.5} {3.0 1.0 4.0 5.0} } {0.0 0.5 1.0 1.5 2.0}


set s [::Plotchart::createTXPlot .c4 {2006-01-01 2007-01-01 120} {0.0 100.0 20.0}]

$s dataconfig series1 -colour "red"
$s dataconfig series2 -colour "blue"

$s xtext "Time"

Changes to examples/plotchart/plotdemos7.tcl.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
...
149
150
151
152
153
154
155

156
157
158
159
160

161
162
#! /bin/sh
# -*- tcl -*- \
exec tclsh "$0" ${1+"$@"}

# plotdemos7.tcl --
#     This test/demo script focuses on customising the plots
#

package require Tcl 8.4
package require Tk
package require Plotchart

# plotdemos7.tcl --
#    Test/demo program 7 for the Plotchart package
#

................................................................................


set s [::Plotchart::createTimechart .v.c3 "1 january 2004" \
                                          "31 december 2004" 4]

$s period "Spring" "1 march 2004" "1 june 2004" green
$s period "Summer" "1 june 2004" "1 september 2004" yellow

$s vertline "1 jan" "1 january 2004"
$s vertline "1 apr" "1 april 2004"
$s vertline "1 jul" "1 july 2004"
$s vertline "1 oct" "1 october 2004"
$s milestone "Longest day" "21 july 2004"

$s title "Seasons (northern hemisphere)"








<
|







 







>

|



>


1
2
3
4
5
6
7

8
9
10
11
12
13
14
15
...
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
#! /bin/sh
# -*- tcl -*- \
exec tclsh "$0" ${1+"$@"}

# plotdemos7.tcl --
#     This test/demo script focuses on customising the plots
#

package require Tcl 8.5
package require Tk
package require Plotchart

# plotdemos7.tcl --
#    Test/demo program 7 for the Plotchart package
#

................................................................................


set s [::Plotchart::createTimechart .v.c3 "1 january 2004" \
                                          "31 december 2004" 4]

$s period "Spring" "1 march 2004" "1 june 2004" green
$s period "Summer" "1 june 2004" "1 september 2004" yellow
$s addperiod "21 september 2004" "21 october 2004" blue
$s vertline "1 jan" "1 january 2004"
$s vertline "1 apr" "1 april 2004" lime
$s vertline "1 jul" "1 july 2004"
$s vertline "1 oct" "1 october 2004"
$s milestone "Longest day" "21 july 2004"
$s addmilestone "21 december 2004"
$s title "Seasons (northern hemisphere)"

Changes to modules/plotchart/ChangeLog.











1
2
3
4
5
6
7










2014-03-19  Arjen Markus  <arjenmarkus@users,sourceforge.net>
	* plotchart.tcl: Add source file "plotstatustimeline.tcl" - supplied by Sean Woods
	* plotstatustimeline.tcl: New source file implementing the new status timeline plot type - supplied by Sean Woods
	* plotdemos18.tcl: New example illustrating the new status timeline plot type - supplied by Sean Woods
	* plotchart.man: Description of the new plot type
	* pkgIndex.tcl: Bumped the version to 2.3.0 because of the new plot type

>
>
>
>
>
>
>
>
>
>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
2014-06-21  Arjen Markus  <arjenmarkus@users,sourceforge.net>
	* plotchart.tcl: Add new commands for timecharts (addperiod, addmilestone and option to vertline)
	                 as suggested by Nick Matthews; also the interpolatedata command for 3D-plots
	* plotchart.man: Document new commands for timecharts, document new tags for 3D-plots
	* plotpriv.tcl: Implement the new commands for timecharts and interpolatedata for 3D-plots
	* plot3d.tcl: Add tags for the data objects (data and line) and method interpolatedata
	* plotdemos1.tcl: Illustrate the new interpolate subcommand for 3D-plots
	* plotdemos7.tcl: Illustrate the new subcommands for timecharts
	* pkgIndex.tcl: Bumped the version to 2.3.1 because of the new commands and improvements

2014-03-19  Arjen Markus  <arjenmarkus@users,sourceforge.net>
	* plotchart.tcl: Add source file "plotstatustimeline.tcl" - supplied by Sean Woods
	* plotstatustimeline.tcl: New source file implementing the new status timeline plot type - supplied by Sean Woods
	* plotdemos18.tcl: New example illustrating the new status timeline plot type - supplied by Sean Woods
	* plotchart.man: Description of the new plot type
	* pkgIndex.tcl: Bumped the version to 2.3.0 because of the new plot type

Changes to modules/plotchart/pkgIndex.tcl.

1
2
3
4
5
6
7
if {![package vsatisfies [package provide Tcl] 8.5]} {
    # PRAGMA: returnok
    return
}
package ifneeded Plotchart 2.3.0 [list source [file join $dir plotchart.tcl]]
package ifneeded xyplot    1.0.1 [list source [file join $dir xyplot.tcl]]
package ifneeded plotanim    0.2 [list source [file join $dir plotanim.tcl]]




|


1
2
3
4
5
6
7
if {![package vsatisfies [package provide Tcl] 8.5]} {
    # PRAGMA: returnok
    return
}
package ifneeded Plotchart 2.3.1 [list source [file join $dir plotchart.tcl]]
package ifneeded xyplot    1.0.1 [list source [file join $dir xyplot.tcl]]
package ifneeded plotanim    0.2 [list source [file join $dir plotanim.tcl]]

Changes to modules/plotchart/plot3d.tcl.

191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
...
249
250
251
252
253
254
255
256
257
258
259




































































260
261
262
263
264
265
266
...
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
...
334
335
336
337
338
339
340
341
342
343
344
         foreach {px11 py11} [coords3DToPixel $w $x1 $y1 $z11] {break}
         foreach {px12 py12} [coords3DToPixel $w $x1 $y2 $z12] {break}
         foreach {px21 py21} [coords3DToPixel $w $x2 $y1 $z21] {break}
         foreach {px22 py22} [coords3DToPixel $w $x2 $y2 $z22] {break}

         $w create polygon $px11 $py11 $px21 $py21 $px22 $py22 \
                           $px12 $py12 $px11 $py11 \
                           -fill $fill -outline $border
      }
   }
}

# Draw3DData --
#    Plot a matrix of data as a function of x and y
# Arguments:
................................................................................
         foreach {px11 py11} [coords3DToPixel $w $x1 $y1 $z11] {break}
         foreach {px12 py12} [coords3DToPixel $w $x1 $y2 $z12] {break}
         foreach {px21 py21} [coords3DToPixel $w $x2 $y1 $z21] {break}
         foreach {px22 py22} [coords3DToPixel $w $x2 $y2 $z22] {break}

         $w create polygon $px11 $py11 $px21 $py21 $px22 $py22 \
                           $px12 $py12 $px11 $py11 \
                           -fill $fill -outline $border
      }
   }
}





































































# Draw3DRibbon --
#     Plot yz-data as a 3D ribbon
#
# Arguments:
#     w               Widget to draw in
#     yzData          List of duples, each of which is y,z pair
................................................................................

        foreach {px11 py11} [::Plotchart::coords3DToPixel $w $x1 $y1 $z1] break
        foreach {px12 py12} [::Plotchart::coords3DToPixel $w $x1 $y2 $z2] break
        foreach {px21 py21} [::Plotchart::coords3DToPixel $w $x2 $y1 $z1] break
        foreach {px22 py22} [::Plotchart::coords3DToPixel $w $x2 $y2 $z2] break
        $w create polygon $px11 $py11 $px21 $py21 $px22 $py22 \
            $px12 $py12 $px11 $py11 \
            -fill $fill -outline $border
    }
}

# Draw3DLineFrom3Dcoordinates --
#    Plot a line in the three-dimensional axis system
# Arguments:
#    w           Name of the canvas
................................................................................
       set factor [expr {0.5*(2.0*$xmax-$xprev-$x)/($xmax-$xmin)}]

       lappend colours [GreyColour $colour $factor]
       set xprev $x
   }

   foreach {xb yb} [lrange $coords 0 end-2] {xe ye} [lrange $coords 2 end] c [lrange $colours 0 end-1] {
       $w create line $xb $yb $xe $ye -fill $c
   }
}








|







 







|
|
|
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







|







 







|



191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
...
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
...
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
...
402
403
404
405
406
407
408
409
410
411
412
         foreach {px11 py11} [coords3DToPixel $w $x1 $y1 $z11] {break}
         foreach {px12 py12} [coords3DToPixel $w $x1 $y2 $z12] {break}
         foreach {px21 py21} [coords3DToPixel $w $x2 $y1 $z21] {break}
         foreach {px22 py22} [coords3DToPixel $w $x2 $y2 $z22] {break}

         $w create polygon $px11 $py11 $px21 $py21 $px22 $py22 \
                           $px12 $py12 $px11 $py11 \
                           -fill $fill -outline $border -tags data
      }
   }
}

# Draw3DData --
#    Plot a matrix of data as a function of x and y
# Arguments:
................................................................................
         foreach {px11 py11} [coords3DToPixel $w $x1 $y1 $z11] {break}
         foreach {px12 py12} [coords3DToPixel $w $x1 $y2 $z12] {break}
         foreach {px21 py21} [coords3DToPixel $w $x2 $y1 $z21] {break}
         foreach {px22 py22} [coords3DToPixel $w $x2 $y2 $z22] {break}

         $w create polygon $px11 $py11 $px21 $py21 $px22 $py22 \
                           $px12 $py12 $px11 $py11 \
                           -fill $fill -outline $border -tags data
      }
   }
}

# InterpolateData3D --
#    Interpolate and plot a function of x and y based on a grid of data
# Arguments:
#    w           Name of the canvas
#    data        Nested list of data in the form of a matrix
#    cont        Contour levels
# Result:
#    None
# Side effect:
#    The plot of the function - given the grid of data
#
proc ::Plotchart::InterpolateData3D { w data cont } {
   variable scaling

   #
   # Store the scale values
   #
   set s(xmin) $scaling($w,xmin)
   set s(xmax) $scaling($w,xmax)
   set s(ymin) $scaling($w,ymin)
   set s(ymax) $scaling($w,ymax)
   set s(nx)   [expr {[llength [lindex $data 0]] - 1}]
   set s(ny)   [expr {[llength $data] - 1}]

   Draw3DFunctionContour $w InterpolateData3DXY $cont
}

# InterpolateData3DXY --
#    Interpolate the data and return the value
# Arguments:
#    x           X-coordinate
#    y           Y-coordinate
# Result:
#    None
# Side effect:
#    The plot of the function - given the grid of data
#
proc ::Plotchart::InterpolateData3DXY { x y } {
   upvar 2 data data
   upvar 2 s    s

   set x [expr {$s(nx) * ($x - $s(xmin)) / ($s(xmax) - $s(xmin))}]
   set y [expr {$s(ny) * ($y - $s(ymin)) / ($s(ymax) - $s(ymin))}]

   set ix1 [expr {int($x)}]
   set ix2 [expr {$ix1 + 1}]
   set iy1 [expr {int($y)}]
   set iy2 [expr {$iy1 + 1}]

   if {$ix2 > $s(nx)-1 } {
      set ix2 $ix1
   }
   if {$iy2 > $s(ny)-1 } {
      set iy2 $iy1
   }

   set wx  [expr {$x - $ix1}]
   set wy  [expr {$y - $iy1}]

   set z11 [lindex $data $iy1 $ix1]
   set z12 [lindex $data $iy1 $ix2]
   set z21 [lindex $data $iy2 $ix1]
   set z22 [lindex $data $iy2 $ix2]

   return [expr {$z11 + $wx * ($z12 - $z11) + $wy * ($z21 - $z11) +
                 $wx * $wy * ($z22 + $z11 - $z12 - $z21)}]
}

# Draw3DRibbon --
#     Plot yz-data as a 3D ribbon
#
# Arguments:
#     w               Widget to draw in
#     yzData          List of duples, each of which is y,z pair
................................................................................

        foreach {px11 py11} [::Plotchart::coords3DToPixel $w $x1 $y1 $z1] break
        foreach {px12 py12} [::Plotchart::coords3DToPixel $w $x1 $y2 $z2] break
        foreach {px21 py21} [::Plotchart::coords3DToPixel $w $x2 $y1 $z1] break
        foreach {px22 py22} [::Plotchart::coords3DToPixel $w $x2 $y2 $z2] break
        $w create polygon $px11 $py11 $px21 $py21 $px22 $py22 \
            $px12 $py12 $px11 $py11 \
            -fill $fill -outline $border -tags data
    }
}

# Draw3DLineFrom3Dcoordinates --
#    Plot a line in the three-dimensional axis system
# Arguments:
#    w           Name of the canvas
................................................................................
       set factor [expr {0.5*(2.0*$xmax-$xprev-$x)/($xmax-$xmin)}]

       lappend colours [GreyColour $colour $factor]
       set xprev $x
   }

   foreach {xb yb} [lrange $coords 0 end-2] {xe ye} [lrange $coords 2 end] c [lrange $colours 0 end-1] {
       $w create line $xb $yb $xe $ye -fill $c -tags line
   }
}

Changes to modules/plotchart/plotchart.man.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
....
1925
1926
1927
1928
1929
1930
1931



















1932
1933
1934
1935
1936
1937
1938
....
2357
2358
2359
2360
2361
2362
2363


















2364
2365
2366
2367
2368
2369
2370
....
2376
2377
2378
2379
2380
2381
2382

2383













2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396



2397
2398
2399
2400
2401
2402
2403
....
4234
4235
4236
4237
4238
4239
4240
4241





4242
4243
4244
4245
4246
4247
4248
[comment {-*- tcl -*- doctools manpage}]
[manpage_begin Plotchart n 2.3.0]
[copyright {2013 Arjen Markus <arjenmarkus@users.sourceforge.net>}]
[moddesc   Plotchart]
[titledesc {Simple plotting and charting package}]
[require Tcl [opt 8.5]]
[require Tk [opt 8.5]]
[require Plotchart [opt 2.3.0]]

[description]
[para]

Plotchart is a Tcl-only package that focuses on the easy creation of
xy-plots, barcharts and other common types of graphical presentations.
The emphasis is on ease of use, rather than flexibility. The procedures
................................................................................
    {4.0 5.0 6.0}
    }
}]

[list_end]
[para]





















[call [cmd \$plot3d] colours [arg fill] [arg border]]

Configure the colours to use for polygon borders and inner area.

[list_begin arguments]

................................................................................

[arg_def color colour in]
The colour of the bar (defaults to black).

[list_end]
[para]




















[call [cmd \$timechart] milestone [arg text] [arg time] [arg colour]]

Add a [term milestone] (represented as an point-down triangle) to the
chart.

[list_begin arguments]
................................................................................

[arg_def color colour in]
The colour of the triangle (defaults to black).

[list_end]
[para]
















[call [cmd \$timechart] vertline [arg text] [arg time]]

Add a vertical line (to indicate the start of the month for instance)
to the chart.

[list_begin arguments]
[arg_def string text in]
The text appearing at the top (an abbreviation of the
date/time for instance).

[arg_def string time in]
Time at which the line must be positioned.




[list_end]


[call [cmd \$timechart] hscroll [arg scrollbar]]

Connect a horizontal scrollbar to the chart. See also the section on
scrolling.
................................................................................
[emph "Contour and isoline plots:"]
[para]
No tags are used.

[para]
[emph "3D plots and 3D ribbon plots:"]
[para]
No tags are used for the data objects, only for the axes.






[para]
[emph "Charts decorated with 3D effects:"]
[para]
The following tags are used to identify various types of graphical objects: platform, background, d, u,
ticklines.
[para]







|







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







>

>
>
>
>
>
>
>
>
>
>
>
>
>
|


|









>
>
>







 







|
>
>
>
>
>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
....
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
....
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
....
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
....
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
[comment {-*- tcl -*- doctools manpage}]
[manpage_begin Plotchart n 2.3.0]
[copyright {2013 Arjen Markus <arjenmarkus@users.sourceforge.net>}]
[moddesc   Plotchart]
[titledesc {Simple plotting and charting package}]
[require Tcl [opt 8.5]]
[require Tk [opt 8.5]]
[require Plotchart [opt 2.3.1]]

[description]
[para]

Plotchart is a Tcl-only package that focuses on the easy creation of
xy-plots, barcharts and other common types of graphical presentations.
The emphasis is on ease of use, rather than flexibility. The procedures
................................................................................
    {4.0 5.0 6.0}
    }
}]

[list_end]
[para]

[call [cmd \$plot3d] interpolatedata [arg data] [arg contours]]

Plot the data using bilinear interpolation with
the contour levels in [var contours] to colour the surface.

The resolution is determined by the set grid sizes (see the method
[method gridsize] for more information).

[list_begin arguments]
[arg_def list data in]
The data to be plotted, just as for the plotdata subcommand.

[arg_def list contours in]
List of values in ascending order that represent the contour levels
(the boundaries between the colours in the contour map).

[list_end]
[para]


[call [cmd \$plot3d] colours [arg fill] [arg border]]

Configure the colours to use for polygon borders and inner area.

[list_begin arguments]

................................................................................

[arg_def color colour in]
The colour of the bar (defaults to black).

[list_end]
[para]

[call [cmd \$timechart] addperiod [arg time_begin] [arg time_end] [arg colour]]

Add a new period to the current row in the chart. This allows you to highlight several periods
in the same row. No new text is drawn.

[list_begin arguments]
[arg_def string time_begin in]
Start time of the period.

[arg_def string time_end in]
Stop time of the period.

[arg_def color colour in]
The colour of the bar (defaults to black).

[list_end]
[para]


[call [cmd \$timechart] milestone [arg text] [arg time] [arg colour]]

Add a [term milestone] (represented as an point-down triangle) to the
chart.

[list_begin arguments]
................................................................................

[arg_def color colour in]
The colour of the triangle (defaults to black).

[list_end]
[para]

[call [cmd \$timechart] addmilestone [arg time] [arg colour]]

Add another [term milestone] to the current row in the chart.

[list_begin arguments]
[arg_def string time in]
Time at which the milestone must be positioned.

[arg_def color colour in]
The colour of the triangle (defaults to black).

[list_end]
[para]


[call [cmd \$timechart] vertline [arg text] [arg time] [arg colour]]

Add a vertical line (to indicate the start of the month for instance)
to the chart in the specified colour.

[list_begin arguments]
[arg_def string text in]
The text appearing at the top (an abbreviation of the
date/time for instance).

[arg_def string time in]
Time at which the line must be positioned.

[arg_def color colour in]
The colour of the line to be drawn (defaults to black)

[list_end]


[call [cmd \$timechart] hscroll [arg scrollbar]]

Connect a horizontal scrollbar to the chart. See also the section on
scrolling.
................................................................................
[emph "Contour and isoline plots:"]
[para]
No tags are used.

[para]
[emph "3D plots and 3D ribbon plots:"]
[para]
Tags are used for the axes and for the data objects:
[list_begin itemized]
[item]
[emph data] - The general tag to identify graphical objects associated with data.
[emph line] - The tag used for lines created with the plotline subcommand.
[list_end]

[para]
[emph "Charts decorated with 3D effects:"]
[para]
The following tags are used to identify various types of graphical objects: platform, background, d, u,
ticklines.
[para]

Changes to modules/plotchart/plotchart.tcl.

306
307
308
309
310
311
312

313

314
315
316
317
318
319
320
...
385
386
387
388
389
390
391

392
393
394
395
396
397
398
....
2984
2985
2986
2987
2988
2989
2990
2991
   set methodProc(vertbars,drawobject)         DrawObject
   set methodProc(vertbars,object)             DrawObject
   set methodProc(vertbars,canvas)             GetCanvas
   set methodProc(vertbars,deletedata)         DeleteData
   set methodProc(timechart,title)             DrawTitle
   set methodProc(timechart,subtitle)          DrawSubtitle
   set methodProc(timechart,period)            DrawTimePeriod

   set methodProc(timechart,milestone)         DrawTimeMilestone

   set methodProc(timechart,vertline)          DrawTimeVertLine
   set methodProc(timechart,saveplot)          SavePlot
   set methodProc(timechart,background)        BackgroundColour
   set methodProc(timechart,balloon)           DrawBalloon
   set methodProc(timechart,balloonconfig)     ConfigBalloon
   set methodProc(timechart,plaintext)         DrawPlainText
   set methodProc(timechart,plaintextconfig)   ConfigPlainText
................................................................................
   set methodProc(isometric,plaintextconfig)   ConfigPlainText
   set methodProc(isometric,canvas)            GetCanvas
   set methodProc(isometric,deletedata)        DeleteData
   set methodProc(3dplot,title)                DrawTitle
   set methodProc(3dplot,subtitle)             DrawSubtitle
   set methodProc(3dplot,plotfunc)             Draw3DFunction
   set methodProc(3dplot,plotdata)             Draw3DData

   set methodProc(3dplot,plotline)             Draw3DLineFrom3Dcoordinates
   set methodProc(3dplot,gridsize)             GridSize3D
   set methodProc(3dplot,ribbon)               Draw3DRibbon
   set methodProc(3dplot,saveplot)             SavePlot
   set methodProc(3dplot,colour)               SetColours
   set methodProc(3dplot,color)                SetColours
   set methodProc(3dplot,xconfig)              XConfig
................................................................................
source [file join [file dirname [info script]] "plotspecial.tcl"]
source [file join [file dirname [info script]] "plotobject.tcl"]
source [file join [file dirname [info script]] "plottable.tcl"]
source [file join [file dirname [info script]] "plotstatustimeline.tcl"]

# Announce our presence
#
package provide Plotchart 2.3.0







>

>







 







>







 







|
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
...
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
....
2987
2988
2989
2990
2991
2992
2993
2994
   set methodProc(vertbars,drawobject)         DrawObject
   set methodProc(vertbars,object)             DrawObject
   set methodProc(vertbars,canvas)             GetCanvas
   set methodProc(vertbars,deletedata)         DeleteData
   set methodProc(timechart,title)             DrawTitle
   set methodProc(timechart,subtitle)          DrawSubtitle
   set methodProc(timechart,period)            DrawTimePeriod
   set methodProc(timechart,addperiod)         DrawAdditionalPeriod
   set methodProc(timechart,milestone)         DrawTimeMilestone
   set methodProc(timechart,addmilestone)      DrawAdditionalMilestone
   set methodProc(timechart,vertline)          DrawTimeVertLine
   set methodProc(timechart,saveplot)          SavePlot
   set methodProc(timechart,background)        BackgroundColour
   set methodProc(timechart,balloon)           DrawBalloon
   set methodProc(timechart,balloonconfig)     ConfigBalloon
   set methodProc(timechart,plaintext)         DrawPlainText
   set methodProc(timechart,plaintextconfig)   ConfigPlainText
................................................................................
   set methodProc(isometric,plaintextconfig)   ConfigPlainText
   set methodProc(isometric,canvas)            GetCanvas
   set methodProc(isometric,deletedata)        DeleteData
   set methodProc(3dplot,title)                DrawTitle
   set methodProc(3dplot,subtitle)             DrawSubtitle
   set methodProc(3dplot,plotfunc)             Draw3DFunction
   set methodProc(3dplot,plotdata)             Draw3DData
   set methodProc(3dplot,interpolatedata)      InterpolateData3D
   set methodProc(3dplot,plotline)             Draw3DLineFrom3Dcoordinates
   set methodProc(3dplot,gridsize)             GridSize3D
   set methodProc(3dplot,ribbon)               Draw3DRibbon
   set methodProc(3dplot,saveplot)             SavePlot
   set methodProc(3dplot,colour)               SetColours
   set methodProc(3dplot,color)                SetColours
   set methodProc(3dplot,xconfig)              XConfig
................................................................................
source [file join [file dirname [info script]] "plotspecial.tcl"]
source [file join [file dirname [info script]] "plotobject.tcl"]
source [file join [file dirname [info script]] "plottable.tcl"]
source [file join [file dirname [info script]] "plotstatustimeline.tcl"]

# Announce our presence
#
package provide Plotchart 2.3.1

Changes to modules/plotchart/plotpriv.tcl.

1
2
3
4
5
6
7






8
9
10
11
12
13
14
....
2437
2438
2439
2440
2441
2442
2443






































2444
2445
2446
2447
2448
2449
2450
....
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
....
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
....
2500
2501
2502
2503
2504
2505
2506









































2507
2508
2509
2510
2511
2512
2513
# plotpriv.tcl --
#    Facilities to draw simple plots in a dedicated canvas
#
# Note:
#    This source file contains the private functions.
#    It is the companion of "plotchart.tcl"
#







# WidthCanvas --
#    Return the width of the canvas
# Arguments:
#    w           Name of the canvas
#    useref      Use reference width if it exists
# Result:
................................................................................

   ReorderChartItems $w

   set scaling($w,current) [expr {$scaling($w,current)-1.0}]

   RescaleChart $w
}







































# DrawTimeVertLine --
#    Draw a vertical line with a label
# Arguments:
#    w           Name of the canvas
#    text        Text to identify the line
#    time        Time for which the line is drawn
................................................................................

   #
   # Draw the line
   #
   foreach {x1 y1} [coordsToPixel $w $xtime $scaling($w,ymin)] {break}
   foreach {x2 y2} [coordsToPixel $w $xtime $scaling($w,ymax)] {break}

   $w create line $x1 $y1 $x2 $y2 -fill black -tags [list $w horizscroll timeline tline]

   $w raise topmask
}

# DrawTimeMilestone --
#    Draw a "milestone"
# Arguments:
................................................................................
#    w           Name of the canvas
#    text        Text to identify the line
#    time        Time for which the milestone is drawn
#    colour      Optionally the colour
# Result:
#    None
# Side effects:
#    Line drawn in canvas
#
proc ::Plotchart::DrawTimeMilestone { w text time {colour black}} {
   variable data_series
   variable scaling

   #
   # Draw the text first
................................................................................
   #
   set ytext [expr {$scaling($w,current)+0.5*$scaling($w,dy)}]
   foreach {x y} [coordsToPixel $w $scaling($w,xmin) $ytext] {break}

   $w create text 5 $y -text $text -anchor w \
       -tags [list vertscroll above item_[expr {int($scaling($w,current))}]]










































   #
   # Draw an upside-down triangle to indicate the time
   #
   set xcentre [clock scan $time]
   set ytop    $scaling($w,current)
   set ybott   [expr {$scaling($w,current)+0.8*$scaling($w,dy)}]








>
>
>
>
>
>







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







|







 







|







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
....
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
....
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
....
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
....
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
# plotpriv.tcl --
#    Facilities to draw simple plots in a dedicated canvas
#
# Note:
#    This source file contains the private functions.
#    It is the companion of "plotchart.tcl"
#
# To do:
#    The procedures DrawTimePeriod and DrawAdditionalPeriod
#    share a lot of code - add two driver procedures and
#    parameterise?
#    Similar for DrawMilestone and DrawAdditionalMilestone
#

# WidthCanvas --
#    Return the width of the canvas
# Arguments:
#    w           Name of the canvas
#    useref      Use reference width if it exists
# Result:
................................................................................

   ReorderChartItems $w

   set scaling($w,current) [expr {$scaling($w,current)-1.0}]

   RescaleChart $w
}

# DrawAdditionalPeriod --
#    Draw an additional period on the same level (no text)
# Arguments:
#    w           Name of the canvas
#    time_begin  Start time
#    time_end    Stop time
#    colour      The colour to use (optional)
# Result:
#    None
# Side effects:
#    Data bars drawn in canvas
#
proc ::Plotchart::DrawAdditionalPeriod { w time_begin time_end {colour black}} {
   variable data_series
   variable scaling

   set scaling($w,current) [expr {$scaling($w,current)+1.0}]

   #
   # Draw the bar to indicate the period
   #
   set xmin  [clock scan $time_begin]
   set xmax  [clock scan $time_end]
   set ybott [expr {$scaling($w,current)+$scaling($w,dy)}]

   foreach {x1 y1} [coordsToPixel $w $xmin $scaling($w,current)] {break}
   foreach {x2 y2} [coordsToPixel $w $xmax $ybott              ] {break}

   $w create rectangle $x1 $y1 $x2 $y2 -fill $colour \
       -tags [list $w vertscroll horizscroll below item_[expr {int($scaling($w,current))}]]

   ReorderChartItems $w

   set scaling($w,current) [expr {$scaling($w,current)-1.0}]

   RescaleChart $w
}

# DrawTimeVertLine --
#    Draw a vertical line with a label
# Arguments:
#    w           Name of the canvas
#    text        Text to identify the line
#    time        Time for which the line is drawn
................................................................................

   #
   # Draw the line
   #
   foreach {x1 y1} [coordsToPixel $w $xtime $scaling($w,ymin)] {break}
   foreach {x2 y2} [coordsToPixel $w $xtime $scaling($w,ymax)] {break}

   $w create line $x1 $y1 $x2 $y2 -fill $colour -tags [list $w horizscroll timeline tline]

   $w raise topmask
}

# DrawTimeMilestone --
#    Draw a "milestone"
# Arguments:
................................................................................
#    w           Name of the canvas
#    text        Text to identify the line
#    time        Time for which the milestone is drawn
#    colour      Optionally the colour
# Result:
#    None
# Side effects:
#    Triangle drawn in canvas
#
proc ::Plotchart::DrawTimeMilestone { w text time {colour black}} {
   variable data_series
   variable scaling

   #
   # Draw the text first
................................................................................
   #
   set ytext [expr {$scaling($w,current)+0.5*$scaling($w,dy)}]
   foreach {x y} [coordsToPixel $w $scaling($w,xmin) $ytext] {break}

   $w create text 5 $y -text $text -anchor w \
       -tags [list vertscroll above item_[expr {int($scaling($w,current))}]]

   #
   # Draw an upside-down triangle to indicate the time
   #
   set xcentre [clock scan $time]
   set ytop    $scaling($w,current)
   set ybott   [expr {$scaling($w,current)+0.8*$scaling($w,dy)}]

   foreach {x1 y1} [coordsToPixel $w $xcentre $ybott] {break}
   foreach {x2 y2} [coordsToPixel $w $xcentre $ytop]  {break}

   set x2 [expr {$x1-0.4*($y1-$y2)}]
   set x3 [expr {$x1+0.4*($y1-$y2)}]
   set y3 $y2

   $w create polygon $x1 $y1 $x2 $y2 $x3 $y3 -fill $colour \
       -tags [list $w vertscroll horizscroll below item_[expr {int($scaling($w,current))}]]

   ReorderChartItems $w

   set scaling($w,current) [expr {$scaling($w,current)-1.0}]

   RescaleChart $w
}

# DrawAdditionalMilestone --
#    Draw an additional "milestone"
# Arguments:
#    w           Name of the canvas
#    time        Time for which the milestone is drawn
#    colour      Optionally the colour
# Result:
#    None
# Side effects:
#    Triangle drawn in canvas
#
proc ::Plotchart::DrawAdditionalMilestone { w time {colour black}} {
   variable data_series
   variable scaling

   set scaling($w,current) [expr {$scaling($w,current)+1.0}]

   #
   # Draw an upside-down triangle to indicate the time
   #
   set xcentre [clock scan $time]
   set ytop    $scaling($w,current)
   set ybott   [expr {$scaling($w,current)+0.8*$scaling($w,dy)}]