Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Changes In Branch subtitles-and-corrected-tests Excluding Merge-Ins
This is equivalent to a diff from c20649fc11 to 5ba99b11b9
2013-06-09
| ||
12:36 | Merge implementation of subtitles, extended and corrected tests, options -timeformat and -gmt check-in: b412199073 user: markus tags: trunk | |
12:30 | Removed leftover print statements Leaf check-in: 5ba99b11b9 user: markus tags: subtitles-and-corrected-tests | |
2013-06-05
| ||
23:57 | Ticket [3651bb1b96]: Integrated MaxJarek's canvas gradient package. check-in: 894b8ead99 user: andreask tags: trunk | |
20:45 | Updated plotchart work with latest from release and trunk. check-in: b99a4a95be user: andreask tags: subtitles-and-corrected-tests | |
20:18 | Merged documentation work for publication. check-in: c20649fc11 user: andreask tags: trunk | |
20:16 | Added feedback section, with proper tracker link. Regenerated embedded docs. Leaf check-in: d4ee97f711 user: andreask tags: doc-cleanup | |
2013-05-26
| ||
10:24 | * ../../examples/styles.tcl: Using the "-stripebackground" option * ../../examples/styles_tile.tcl: at column level, too. check-in: 9d0c0de577 user: csaba tags: trunk | |
Added examples/plotchart/test_stripchart.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 | # test_stripchart.tcl -- # Problem 3613718 on SF regarding stripcharts and custom labels # # Reported by Donal # # Use case: date/time source plotchart.tcl 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 } |
Changes to modules/plotchart/ChangeLog.
1 2 3 4 | 2013-03-25 Andreas Kupries <[email protected]> * * Released and tagged Tklib 0.6 ======================== | > > > > > > > > > > > > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | 2013-06-09 Arjen Markus <arjenmarkus@users,sourceforge.net> * plotaxis.tcl: Remove leftover print statements 2013-05-25 Arjen Markus <arjenmarkus@users,sourceforge.net> * plotchart.tcl: Implement the options -timeformat and -gmt as per bug 3613718 * plotpriv.tcl: Use the original axis options to reconstruct the axis for stripcharts * plotaxis.tcl: Implement the options -timeformat and -gmt * plotchart.man: Document the options -timeformat and -gmt * pkgIndex.tcl: Bumped version to 2.1.1 * test_stripchart.tcl: Test and demonstraton of stripchart with date/time 2013-03-25 Andreas Kupries <[email protected]> * * Released and tagged Tklib 0.6 ======================== * 2013-03-10 Arjen Markus <arjenmarkus@users,sourceforge.net> * plotchart.tcl: Basic support for subtexts with axes, accurate factor "torad", pixelToCoords extended * plotchart.test: Extended tests for coordinate transformations * plotaxis.tcl: Support for subtexts * plotconfig.tcl: Support for subtexts * plotspecial.tcl: Removed debug output |
︙ | ︙ |
Changes to modules/plotchart/pkgIndex.tcl.
1 2 3 4 | if {![package vsatisfies [package provide Tcl] 8.5]} { # PRAGMA: returnok return } | | | 1 2 3 4 5 6 7 | if {![package vsatisfies [package provide Tcl] 8.5]} { # PRAGMA: returnok return } package ifneeded Plotchart 2.1.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/plotaxis.tcl.
︙ | ︙ | |||
483 484 485 486 487 488 489 490 491 492 493 494 495 496 | set scaling($w,xaxis) {} set xs {} set xts {} set xbackup {} set numeric 1 if { $xdelt eq {} } { set numeric 1 foreach {arg val} $args { switch -exact -- $arg { -xlabels { | > | 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 | set scaling($w,xaxis) {} set xs {} set xts {} set xbackup {} set numeric 1 set gmt 0 if { $xdelt eq {} } { set numeric 1 foreach {arg val} $args { switch -exact -- $arg { -xlabels { |
︙ | ︙ | |||
509 510 511 512 513 514 515 | set xb [expr {$xb + $xdbackup}] } set scaling($w,xdelt) $xs } default { | | | > > > > > > > > > > > > > > > | > | | | > > > | 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 | set xb [expr {$xb + $xdbackup}] } set scaling($w,xdelt) $xs } default { error "Argument $arg not recognized or incorrectly used" } } } } else { set scaling($w,xdelt) $xdelt while { $x < $xm+0.5*abs($xdelt) } { lappend xs $x lappend xts $xt lappend xbackup $xt set x [expr {$x+abs($xdelt)}] set xt [expr {$xt+$xdelt}] if { abs($x) < 0.5*abs($xdelt) } { set xt 0.0 } } set dxminor [expr {$xdelt/($config($w,bottomaxis,minorticks)+1.0)}] foreach {arg val} $args { switch -exact -- $arg { -timeformat { # Format the axis labels via [clock format] set numeric 2 set timeformat $val set scaling($w,xdelt) $xdelt } -gmt { set gmt $val } } } } foreach x $xs xt $xts xb $xbackup { if { $numeric > 0 } { foreach {xcrd ycrd} [coordsToPixel $w $xt $scaling($w,ymin)] {break} } else { foreach {xcrd ycrd} [coordsToPixel $w $xb $scaling($w,ymin)] {break} } set ycrd2 [expr {$ycrd+$ticklength}] set ycrd3 [expr {$ycrd+$offtick}] if { $xcrd >= $scaling($w,pxmin)-1 && $xcrd <= $scaling($w,pxmax)+1 } { lappend scaling($w,xaxis) $xcrd # # Use the default format %.12g - this is equivalent to setting # tcl_precision to 12 - to solve overly precise labels in Tcl 8.5 # if { [string is double $xt] } { if { $numeric == 1 } { set xlabel [format "%.12g" $xt] if { $format != "" } { set xlabel [FormatNumber $format $xt] } } else { set xlabel [clock format [expr {int($xt)}] -format $timeformat -gmt $gmt] } } else { set xlabel $xt } $w create line $xcrd $ycrd2 $xcrd $ycrd -tag [list xaxis $w] -fill $linecolor |
︙ | ︙ |
Changes to modules/plotchart/plotchart.man.
1 | [comment {-*- tcl -*- doctools manpage}] | | | | 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 | [comment {-*- tcl -*- doctools manpage}] [manpage_begin Plotchart n 2.1.1] [keywords {3D bars}] [keywords {3D surfaces}] [keywords {bar charts}] [keywords charts] [keywords {coordinate transformations}] [keywords coordinates] [keywords {graphical presentation}] [keywords {isometric plots}] [keywords {pie charts}] [keywords plotting] [keywords {polar plots}] [keywords {strip charts}] [keywords tables] [keywords {time charts}] [keywords xy-plots] [copyright {2011 Arjen Markus <[email protected]>}] [moddesc Plotchart] [titledesc {Simple plotting and charting package}] [require Tcl [opt 8.5]] [require Tk [opt 8.5]] [require Plotchart [opt 2.1.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 |
︙ | ︙ | |||
149 150 151 152 153 154 155 156 157 158 159 160 | the empty string. [item] [emph "-ylabels {labels}:"] Similarly, custom labels for the y-axis. [item] [emph "-box {measures}:"] See [sectref "ARRANGING MULTIPLE PLOTS IN A CANVAS"] [item] [emph "-axesbox {measures}:"] See [sectref "ARRANGING MULTIPLE PLOTS IN A CANVAS"] [list_end] [list_end] [para] | > > > > | > > > | > > > | > > > | > > > | > > > | > > > | 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 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 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 | the empty string. [item] [emph "-ylabels {labels}:"] Similarly, custom labels for the y-axis. [item] [emph "-box {measures}:"] See [sectref "ARRANGING MULTIPLE PLOTS IN A CANVAS"] [item] [emph "-axesbox {measures}:"] See [sectref "ARRANGING MULTIPLE PLOTS IN A CANVAS"] [item] [emph "-timeformat format:"] See [sectref "USING DATE/TIME LABELS"] [item] [emph "-gmt 0/1:"] See [sectref "USING DATE/TIME LABELS"] [list_end] [list_end] [para] [call [cmd ::Plotchart::createStripchart] [arg w] [arg xaxis] [arg yaxis] [arg args]] Create a new strip chart (configuration type: stripchart). The only difference to a regular XY plot is that the x-axis will be automatically adjusted when the x-coordinate of a new point exceeds the maximum. [list_begin arguments] [arg_def widget w in] Name of the [emph existing] canvas widget to hold the plot. [arg_def list xaxis in] A 3-element list containing minimum, maximum and stepsize for the x-axis, in this order. Note that an inverted x-axis is [emph not] supported for this type of plot. [arg_def list yaxis in] A 3-element list containing minimum, maximum and stepsize for the y-axis, in this order. For an inverted axis, where the maximum appears at the bottom, use: maximum, minimum and a [emph negative] stepsize. [arg_def list args in] Zero or more options - see the XY-plot for more information. [list_end] [para] [call [cmd ::Plotchart::createTXPlot] [arg w] [arg timeaxis] [arg xaxis] [arg args]] Create a new time-x-plot (configuration type: txplot). The horizontal axis represents the date/time of the data and the vertical axis the values themselves. [list_begin arguments] [arg_def widget w in] Name of the [emph existing] canvas widget to hold the plot. [arg_def list timeaxis in] A 3-element list containing the minimum and maximum date/time to be shown and the stepsize ([emph "in days"]) for the time-axis, in this order. Note that an inverted time-axis is [emph not] supported. [arg_def list xaxis in] A 3-element list containing minimum, maximum and stepsize for the vertical axis, in this order. For an inverted axis, where the maximum appears at the bottom, use: maximum, minimum and a [emph negative] stepsize. [arg_def list args in] Zero or more options - see the XY-plot for more information. [list_end] [para] [call [cmd ::Plotchart::createXLogYPlot] [arg w] [arg xaxis] [arg yaxis] [arg args]] Create a new xy-plot where the y-axis has a logarithmic scale (configuration type: xlogyplot). [para] The data should be given as for a linear scale, as the logarithmic transformation is taken of internally. [list_begin arguments] [arg_def widget w in] Name of the [emph existing] canvas widget to hold the plot. [arg_def list xaxis in] A 3-element list containing minimum, maximum and stepsize for the x-axis, in this order. For an inverted axis, where the maximum appears on the left-hand side, use: maximum, minimum and a [emph negative] stepsize. [arg_def list yaxis in] A 2-element list containing minimum and maximum for the y-axis, in this order. Note that an inverted logarithmic axis is [emph not] supported. [arg_def list args in] Zero or more options - see the XY-plot for more information. [list_end] [para] [call [cmd ::Plotchart::createLogXYPlot] [arg w] [arg xaxis] [arg yaxis] [arg args]] Create a new xy-plot where the x-axis has a logarithmic scale (configuration type: logxyplot). [para] The data should be given as for a linear scale, as the logarithmic transformation is taken of internally. [list_begin arguments] [arg_def widget w in] Name of the [emph existing] canvas widget to hold the plot. [arg_def list xaxis in] A 2-element list containing minimum and maximum for the x-axis, in this order. Note that an inverted logarithmic axis is [emph not] supported. [arg_def list yaxis in] A 3-element list containing minimum, maximum and stepsize for the y-axis, in this order. For an inverted axis, where the maximum appears on the left-hand side, use: maximum, minimum and a [emph negative] stepsize. [arg_def list args in] Zero or more options - see the XY-plot for more information. [list_end] [para] [call [cmd ::Plotchart::createLogXLogYPlot] [arg w] [arg xaxis] [arg yaxis] [arg args]] Create a new xy-plot where both the x-axis and the y-axis have a logarithmic scale (configuration type: logxlogyplot). [para] The data should be given as for a linear scale, as the logarithmic transformation is taken of internally. [list_begin arguments] [arg_def widget w in] Name of the [emph existing] canvas widget to hold the plot. [arg_def list xaxis in] A 2-element list containing minimum and maximum for the x-axis, in this order. Note that an inverted logarithmic axis is [emph not] supported. [arg_def list yaxis in] A 2-element list containing minimum and maximum for the y-axis, in this order. Note that an inverted logarithmic axis is [emph not] supported. [arg_def list args in] Zero or more options - see the XY-plot for more information. [list_end] [para] [call [cmd ::Plotchart::createPolarPlot] [arg w] [arg radius_data] [arg args]] Create a new polar plot (configuration type: polarplot). [list_begin arguments] [arg_def widget w in] Name of the [emph existing] canvas widget to hold the plot. [arg_def list radius_data in] A 2-element list containing maximum radius and stepsize for the radial axis, in this order. [arg_def list args in] Zero or more options - see the XY-plot for more information. [list_end] [para] [call [cmd ::Plotchart::createWindrose] [arg w] [arg radius_data] [arg sectors]] Create a new windrose diagram. The diagram will consist of concentric circles as defined by the [term radius_data] argument and a number of |
︙ | ︙ | |||
3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 | } $t row $row }}] [section "CONTROL DISPLAYS"] TODO [section "ARRANGING MULTIPLE PLOTS IN A CANVAS"] The command [term plotpack] allows you to copy the contents of a plot into another canvas widget. This canvas widget does not act as a composite plot, but it can be saved as a PostScript file for instance: | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 | } $t row $row }}] [section "CONTROL DISPLAYS"] TODO [section "USING DATE/TIME LABELS"] The options -timeformat and -gmt are used to control the display of date/time labels along the x-axis for those plot types for which it makes sense. These options were implemented to take care of date/time labels for stripcharts, as you can also use custom labels (the option -xlabels) if the axis is "static". Since this is not the case for stripcharts, this was not an option (Tcllib/Tklib bug 3613718). The example below illustrates how to use the -timeformat option. The -gmt option merely suppresses the handling of daylight saving time by the [lb]clock format[rb] command. [example { package require Plotchart pack [canvas .c -width 500 -bg white] # # 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"] 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 }}] The [emph plot] subcommand simply interprets the x and y data as straightforward numbers, so that you need to do the conversion from date/time to "clock seconds" yourself. [section "ARRANGING MULTIPLE PLOTS IN A CANVAS"] The command [term plotpack] allows you to copy the contents of a plot into another canvas widget. This canvas widget does not act as a composite plot, but it can be saved as a PostScript file for instance: |
︙ | ︙ |
Changes to modules/plotchart/plotchart.tcl.
︙ | ︙ | |||
1038 1039 1040 1041 1042 1043 1044 | if { $ydelt ne {} && ($ymax-$ymin)*$ydelt < 0.0 } { set ydelt [expr {-$ydelt}] } viewPort $w $pxmin $pymin $pxmax $pymax worldCoordinates $w $xmin $ymin $xmax $ymax | | > | > > | > | 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 | if { $ydelt ne {} && ($ymax-$ymin)*$ydelt < 0.0 } { set ydelt [expr {-$ydelt}] } viewPort $w $pxmin $pymin $pxmax $pymax worldCoordinates $w $xmin $ymin $xmax $ymax if { $xdelt eq {} || [lsearch $argv "-timeformat"] >= 0 } { set known_args {} foreach {arg val} [array get options] { switch -exact -- $arg { -xlabels - -timeformat - -gmt { lappend known_args $arg $val } -ylabels { # Ignore } default { error "Argument $arg not recognized" } } } DrawXaxis $w $xmin $xmax $xdelt {*}$known_args } else { DrawXaxis $w $xmin $xmax $xdelt } if { $ydelt eq {} } { foreach {arg val} [array get options] { switch -exact -- $arg { -ylabels { |
︙ | ︙ | |||
1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 | CopyScalingData $w $c # # Prepare labeldots # $newchart dataconfig labeldot -colour red -type symbol -symbol dot return $newchart } # createStripchart -- # Create a command for drawing a strip chart # Arguments: # w Name of the canvas # xscale Minimum, maximum and step for x-axis (initial) # yscale Minimum, maximum and step for y-axis # args Options (currently: "-box list" and "-axesbox list") # Result: # Name of a new command # Note: # By default the entire canvas will be dedicated to the stripchart. # The stripchart will be drawn with axes # proc ::Plotchart::createStripchart { w xscale yscale args } { return [CreateXYPlotImpl stripchart $w $xscale $yscale $args] } # createIsometricPlot -- # Create a command for drawing an "isometric" plot # Arguments: | > > > > > > > > > > > | 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 | CopyScalingData $w $c # # Prepare labeldots # $newchart dataconfig labeldot -colour red -type symbol -symbol dot # # Store the options for later use (especially stripcharts) # set scaling($w,axisoptions) $argv return $newchart } # createStripchart -- # Create a command for drawing a strip chart # Arguments: # w Name of the canvas # xscale Minimum, maximum and step for x-axis (initial) # yscale Minimum, maximum and step for y-axis # args Options (currently: "-box list" and "-axesbox list") # Result: # Name of a new command # Note: # By default the entire canvas will be dedicated to the stripchart. # The stripchart will be drawn with axes # # The option "-xlabels" makes no sense for stripcharts. # proc ::Plotchart::createStripchart { w xscale yscale args } { if { [lsearch $args "-xlabels"] >= 0 } { return -code error "The option \"-xlabels\" is invalid - use \"-timeformat\" if you want date/time labels" } return [CreateXYPlotImpl stripchart $w $xscale $yscale $args] } # createIsometricPlot -- # Create a command for drawing an "isometric" plot # Arguments: |
︙ | ︙ |
Changes to modules/plotchart/plotpriv.tcl.
︙ | ︙ | |||
1042 1043 1044 1045 1046 1047 1048 | set xmin [expr {$xmin+$xdelt}] set xmax [expr {$xmax+$xdelt}] } set ymin $scaling($w,ymin) set ymax $scaling($w,ymax) worldCoordinates $w $xmin $ymin $xmax $ymax | | | 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 | set xmin [expr {$xmin+$xdelt}] set xmax [expr {$xmax+$xdelt}] } set ymin $scaling($w,ymin) set ymax $scaling($w,ymax) worldCoordinates $w $xmin $ymin $xmax $ymax DrawXaxis $w $xmin $xmax $xdelt {*}$scaling($w,axisoptions) foreach {pxminorg pyminorg} [coordsToPixel $w $xminorg $ymin] {break} foreach {pxmin pymin} [coordsToPixel $w $xmin $ymin] {break} $w move data [expr {$pxminorg-$pxmin+1}] 0 } DrawData $w $series $xcrd $ycrd |
︙ | ︙ |