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
|
#!/usr/bin/env tclsh
## -*- tcl -*-
# test_stripchart.tcl --
# Problem 3613718 on SF regarding stripcharts and custom labels
#
# Reported by Donal
#
# Use case: date/time
package require Plotchart
pack [canvas .c]
if { 0 } {
#
# Original code:
#
set s [::Plotchart::createStripchart .c {0 10 ""} {0 10 1} -xlabels {a b c}]
# I then get an error when I try to plot the final point in this data:
foreach {x y} {0 0 2 5 5 2 9 9 12 10} {
if { $x < 12 } {
$s plot a $x $y
}
}
}
#
# New code:
# Note that we need to present the x values as clock seconds
#
set start [clock scan "0:00"]
set stop [clock scan "10:00"]
set s [::Plotchart::createStripchart .c [list $start $stop 7200] {0 10 1} -timeformat "%H:%M"]
# I then get an error when I try to plot the final point in this data:
foreach {x y} {0 0 2 5 5 2 9 9 12 10} {
set x [expr {$start + 3600 * $x}] ;# Convert hour to clock seconds
$s plot a $x $y
}
|