Tk Library Source Code

Check-in [6de43b34a0]
Login

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

Overview
Comment:Merged with trunk
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | hypnotoad
Files: files | file ages | folders
SHA1:6de43b34a0ba36090acd95aa1300b5160849573a
User & Date: seandeelywoods 2014-03-19 13:23:46
Context
2014-03-19
13:30
Merging with trunk again. check-in: c1f6533ae5 user: seandeelywoods tags: hypnotoad
13:23
Merged with trunk check-in: 6de43b34a0 user: seandeelywoods tags: hypnotoad
12:08
Add the status timeline plot type as supplied by Sean Deely Woods. This includes a new demo program. check-in: 1c99ea3336 user: markus tags: trunk
2014-03-18
15:18
Updated the comments for the new vertical line tool in plotstatustimeline. check-in: a4a7e3ff04 user: seandeelywoods tags: hypnotoad
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Added examples/plotchart/plotdemos18.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#! /bin/sh
# The next line restarts with tclsh \
exec tclsh "$0" ${1+"$@"}

package require Tk

package require Plotchart

# plotdemos18.tcl --
#     Demonstration of the status timeline plot
#
#     Supplied by Sean Deely Woods
#

set devices {e1 e2 e12231 r1 r2}

canvas .c  -background white -width 600 -height 400
set s [::Plotchart::createStatusTimeline .c {0 7200 900} $devices -xaxis 0]
pack .c -side left -fill both

#
# Add the data to the plot
#
set xd    5.0
set yd   20.0
set xold  0.0
set yold 50.0

#$s dataconfig e1 -colour "red"
#$s dataconfig e2 -colour "blue"
#$s dataconfig r1 -colour "magenta"
#$s dataconfig r2 -colour "green"

#$s plot e1 0.0 green
#$s plot e2 0.0 green
#$s plot r1 0.0 green
#$s plot r2 0.0 green


set li 0

for {set i [expr {int(rand()*10)}]} {$i < 7200} {incr i} {
  foreach item $devices {
    if {[expr {rand()>0.5}]} {
      set color red
    } else {
      set color green
    }
    #puts [list period $item $li $i $color]

    $s plot $item $li $i $color
  }
  set next [expr {int(rand()*600)}]
  set li $i
  incr i $next
}

$s plot XX $li $i $color

for {set x 0} {$x <= 7200} {incr x 900} {
  set hours   [expr int(floor($x/3600))]
  set minutes [expr int((floor($x-($hours*3600)))/60)]
  set text    [format %02dh:%02d $hours $minutes]
  if {($x % 3600)==0} {
    set style [list -fill black -width 2]
  } else {
    set text {}
    set style [list -fill grey -dash ...]
  }
  $s vertline $text $x {*}$style
}

#$s xtext "Time"
#$s ytext ""
$s title "Operational over time"

Changes to modules/plotchart/ChangeLog.

1
2




3
4
5
6
7
8
9
2014-03-18  Sean Woods  <yoda@etoyoc.com>
	* plotchart.tcl: Added a new chart "Statue Timeline"





2014-03-14  Arjen Markus  <arjenmarkus@users,sourceforge.net>
	* plotchart.tcl: Forgot to bump the version to 2.2.2 in the "provide" statement (ticket 530c40d269eb3bc4523115e121c38e7a6c047632)

2014-02-06  Arjen Markus  <arjenmarkus@users,sourceforge.net>
	* plotconfig.tcl: Add dummy axis components for Gantt charts
	* examples/demo.tcl: Corrected call to plot subcommand for boxplots (series argument was missing)
|
|
>
>
>
>







1
2
3
4
5
6
7
8
9
10
11
12
13
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

2014-03-14  Arjen Markus  <arjenmarkus@users,sourceforge.net>
	* plotchart.tcl: Forgot to bump the version to 2.2.2 in the "provide" statement (ticket 530c40d269eb3bc4523115e121c38e7a6c047632)

2014-02-06  Arjen Markus  <arjenmarkus@users,sourceforge.net>
	* plotconfig.tcl: Add dummy axis components for Gantt charts
	* examples/demo.tcl: Corrected call to plot subcommand for boxplots (series argument was missing)

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.2.3 [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.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]]

Changes to modules/plotchart/plotchart.man.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
...
762
763
764
765
766
767
768


























769
770
771
772
773
774
775
....
2783
2784
2785
2786
2787
2788
2789
2790

2791






































2792
2793
2794
2795
2796
2797
2798
[comment {-*- tcl -*- doctools manpage}]
[manpage_begin Plotchart n 2.2.1]
[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.2.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
................................................................................

[arg_def list args in]
Zero or more option-value pairs to influence the position and the appearance of the
diagram. In addition to the positioning options (-box and -axesbox) the diagram supports:
[term "-fractions yes/no"], to display numbers 0 to 1 instead of 0 to 100% and [term "-steps number"]
to influence the number of labels along the three sides.



























[list_end]
[para]

[list_end]

[section "PLOT METHODS"]

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

[list_begin arguments]
[arg_def string colour in]
Optional argument used as the colour of the ticklines. Defaults to grey.
[list_end]
[list_end]

There are a number of public procedures that may be useful in specific

situations: [emph "Pro memorie"].








































[section {COORDINATE TRANSFORMATIONS}]

Besides the commands that deal with the plots and charts directly,
there are a number of commands that can be used to convert world
coordinates to pixels and vice versa.

|





|







 







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







 







<
>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
...
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
....
2809
2810
2811
2812
2813
2814
2815

2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
[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
................................................................................

[arg_def list args in]
Zero or more option-value pairs to influence the position and the appearance of the
diagram. In addition to the positioning options (-box and -axesbox) the diagram supports:
[term "-fractions yes/no"], to display numbers 0 to 1 instead of 0 to 100% and [term "-steps number"]
to influence the number of labels along the three sides.

[list_end]
[para]


[call [cmd ::Plotchart::createStatusTimeline] [arg w] [arg xaxis] [arg ylabel] [arg args]]

Create a command to draw a so-called status timeline. Its layout is similar to a horizontal
barchart, but the bars are drawn in different colours, each representing the status of
the item as it varies over time (the horizontal axis).

[list_begin arguments]
[arg_def widget w in]
Name of the canvas widget to hold the ternary diagram.

[arg_def list xaxis in]
A 3-element list containing minimum, maximum and stepsize for the x-axis, in this order.

[arg_def list ylabels in]
List of labels for the y-axis. Its length also determines the number of
bars that will be plotted per series.

[arg_def list args in]
Zero or more option-value pairs to influence the position and the appearance of the
diagram. In addition to the positioning options (-box and -axesbox) the diagram supports:
[term "-xaxis yes/no"], to turn displaying the numeric labels on or off.

[list_end]
[para]

[list_end]

[section "PLOT METHODS"]

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

[list_begin arguments]
[arg_def string colour in]
Optional argument used as the colour of the ticklines. Defaults to grey.
[list_end]
[list_end]



For [emph {status timeline plots}] you can use the following subcommands:

[list_begin definitions]
[call [cmd \$timeline] plot [arg series] [arg item] [arg start] [arg stop] [arg color]]
Draw a bar in the given colour from [term start] to [term stop] for the item [term item].
The item is a convenient label - there is no relation to the labels along the axis.
The items are drawn from bottom to top.

[list_begin arguments]
[arg_def string item in]
Name to identify the bar. See remark above.

[arg_def float start in]
X-coordinate (or time) at which the bar starts

[arg_def float stop in]
X-coordinate (or time) at which the bar stops

[arg_def string color in]
Colour to use for the bar. Defaults to black.
[list_end]


[call [cmd \$timeline] vertline [arg text] [arg time] [arg args]]
Draw a vertical line to indicate a significant moment.

[list_begin arguments]
[arg_def string text in]
Text to identify the moment.

[arg_def float time in]
X-coordinate (or time) at which the line is to be drawn

[arg_def list args in]
Individual optional arguments that will be passed to the [term "create line"] subcommand
of the underlying canvas. This way you can set the colour or the line width
of the vertical line.
[list_end]
[list_end]


[section {COORDINATE TRANSFORMATIONS}]

Besides the commands that deal with the plots and charts directly,
there are a number of commands that can be used to convert world
coordinates to pixels and vice versa.

Changes to modules/plotchart/plotchart.tcl.

33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
....
2984
2985
2986
2987
2988
2989
2990
2991
                    createGanttChart createHistogram colorMap \
                    create3DBars createRadialchart \
                    createTXPlot createRightAxis \
                    create3DRibbonChart create3DRibbonPlot \
                    createXLogYPlot createLogXYPlot createLogXLogYPlot \
                    createWindrose createTargetDiagram createPerformanceProfile \
                    createTableChart createTitleBar \
                    createSpiralPie createTernaryDiagram \
                    plotstyle plotconfig plotpack plotmethod clearcanvas eraseplot

   #
   # Array linking procedures with methods
   #
   set methodProc(xyplot,title)             DrawTitle
   set methodProc(xyplot,subtitle)          DrawSubtitle
................................................................................
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.2.3







|







 







|
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
....
2984
2985
2986
2987
2988
2989
2990
2991
                    createGanttChart createHistogram colorMap \
                    create3DBars createRadialchart \
                    createTXPlot createRightAxis \
                    create3DRibbonChart create3DRibbonPlot \
                    createXLogYPlot createLogXYPlot createLogXLogYPlot \
                    createWindrose createTargetDiagram createPerformanceProfile \
                    createTableChart createTitleBar \
                    createSpiralPie createTernaryDiagram createStatusTimeline \
                    plotstyle plotconfig plotpack plotmethod clearcanvas eraseplot

   #
   # Array linking procedures with methods
   #
   set methodProc(xyplot,title)             DrawTitle
   set methodProc(xyplot,subtitle)          DrawSubtitle
................................................................................
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