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
|
#!/usr/bin/env tclsh
## -*- tcl -*-
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"
|