Tk Library Source Code

Check-in [34b323e562]
Login

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

Overview
Comment:Two additional examples - one from the Wiki (storing data in the canvas), one demonstrating time-x-plots with annotations
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:34b323e562eb67e5397c4e791cc2698bf875a3f1
User & Date: arjenmarkus 2012-01-05 09:33:21
Context
2012-01-05
09:34
And some more that I apparently had forgotten to actually add and commit check-in: 37a851abef user: arjenmarkus tags: trunk
09:33
Two additional examples - one from the Wiki (storing data in the canvas), one demonstrating time-x-plots with annotations check-in: 34b323e562 user: arjenmarkus tags: trunk
2011-12-23
08:51
Added several small examples/tests to show the new functionality of Plotchart` check-in: 547690cbcb user: arjenmarkus tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Added examples/plotchart/slidercnv.tcl.











































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
# slidercnv.tcl --
#     Use the canvas as a way to store data
#
source plotchart.tcl
package require Plotchart 2.0

namespace eval demo {

proc addCircle {p x y data} {

    set w [$p canvas]
    foreach {xp yp} [::Plotchart::coordsToPixel $w $x $y] {break}

    $w create oval [expr {$xp-5}] [expr {$yp-5}] [expr {$xp+5}] [expr {$yp+5}] -fill white -outline black \
        -tag [list data $data]

    $w lower data
}

proc colourCircles {w threshold} {

    foreach object [$w find withtag data] {

        set value [lindex [$w itemcget $object -tag] 1]

        if { $value < $threshold } {
            $w itemconfigure $object -fill white
        } else {
            $w itemconfigure $object -fill red
        }
    }
}

# Not just yet:
# ::Plotchart::plotmethod xyplot circle addCircle
}

pack [canvas .c -bg white] \
     [scale .s -from 1 -to 0 -digits 3 -resolution 0.001 -command [list ::demo::colourCircles .c]] \
     -fill both -side left

set p [::Plotchart::createXYPlot .c {0 100 10} {0 20 5}]

#
# Put in some randomly placed circles
#
for { set i 0 } { $i < 20 } { incr i } {
    set x [expr {100 * rand()}]
    set y [expr { 20 * rand()}]
    set z [expr {rand()}]

    ::demo::addCircle $p $x $y $z
}

Added examples/plotchart/testtxplot.tcl.



















































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
#! /bin/sh
# -*- tcl -*- \
exec tclsh "$0" ${1+"$@"}

package require Tcl 8.4
package require Tk
package require Plotchart

# testxplot.tcl --
#    Test program for TXPlots and balloons
#

canvas .c -background white -width 400 -height 200
pack   .c

set s [::Plotchart::createTXPlot .c {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"
$s ytext "Data"
$s xticklines

$s plot series1 2006-02-01 10.0
$s plot series1 2006-02-11 50.0
$s plot series1 2006-03-01 50.0
$s plot series1 2006-07-01 40.0
$s plot series1 2006-08-21 20.0
$s plot series1 2006-08-22  1.0
$s plot series1 2006-12-11 78.0

$s plot series2 2006-03-01 110.0
$s plot series2 2006-04-11  50.0
$s plot series2 2006-07-28  20.0
$s plot series2 2006-10-21  99.0
$s plot series2 2006-11-22   1.0
$s plot series2 2006-12-31  78.0

$s balloon   2006-05-06 60.0 "Aha" n
$s plaintext 2006-11-06 50.0 "Aha"