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 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 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 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 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 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784
|
# -*- tcl -*-
# Test cases of the Plotchart package
#
# Note:
# Most tests concentrate on the coordinate transformations,
# as these do not require graphics
#
# TODO:
# - Error handling tests
# - checks for setZoomPan (changes of coordinates)
#
if {![package vsatisfies [package provide Tcl] 8.5]} {
puts " Aborting the tests found in \"[file tail [info script]]\"."
puts " Requiring Tcl 8.5, have [package present Tcl]"
return
}
# Future: put all tests under constraint tk and set constraint properly
if {[catch { package require Tk 8.5 } msg]} {
puts " Aborting the tests found in \"[file tail [info script]]\"."
puts " Requiring Tk 8.5, $msg"
return
}
::tcltest::testConstraint tk 1
# -------------------------------------------------------------------------
#
# Note:
# The tests assume tcltest 2.1, in order to compare
# floating-point results
if {[lsearch [namespace children] ::tcltest] == -1} {
package require tcltest 2.1
#package require tcltest 2.2
namespace import ::tcltest::*
} else {
# Ensure that 2.1 or higher present.
if {![package vsatisfies [package present tcltest] 2.1]} {
puts "Aborting tests for Plotchart"
puts "Requiring tcltest 2.1, have [package present tcltest]"
return
}
}
#catch { console show }
source [file join [file dirname [info script]] plotchart.tcl]
#puts "Plotchart [package present Plotchart]"
# -------------------------------------------------------------------------
#
# Note:
# The tests were formulated such that the resulting numbers
# are exact. Test Plotchart-2.12, however, has a slight aberration
# in Tcl 8.5: the result is "0.9999999940000001 1.000000006 2e-9"
# Hence the small tolerance
#
proc matchNumbers {expected actual} {
set match 1
foreach a $actual e $expected {
if { $e != 0.0 } {
if { abs($a - $e) > 0.5e-9*(abs($a)+abs($e)) } {
set match 0
break
}
} else {
if { abs($a) > 0.5e-9 } {
set match 0
break
}
}
}
return $match
}
proc checkCanvasItems {w tags} {
set okay 1
foreach tag $tags {
if {[llength [$w find withtag $tag]] == 0} {
set okay 0
break
}
}
return $okay
}
customMatch numbers matchNumbers
# -------------------------------------------------------------------------
#
# Test cases: coordinate transformations
# To avoid round-off errors, all transforms use "round" values
#
# Note:
# The coordinate system has to be set explicitly, as this is ordinarily
# done by the creation procedure
#
#
# World coordinates to pixels: Linear scales
#
test Plotchart-1.1 {World coordinates to pixel - basic 1} -match numbers -body {
set ::Plotchart::scaling(window,coordSystem) 0
::Plotchart::worldCoordinates "window" 0.0 0.0 100.0 1000.0
::Plotchart::viewPort "window" 0 0 100 100
::Plotchart::coordsToPixel "window" 0 0
} -result {0 100}
test Plotchart-1.2 {World coordinates to pixel - basic 2} -match numbers -body {
set ::Plotchart::scaling(window,coordSystem) 0
::Plotchart::worldCoordinates "window" 0.0 0.0 100.0 1000.0
::Plotchart::viewPort "window" 0 0 100 100
::Plotchart::coordsToPixel "window" 10 10
} -result {10 99}
test Plotchart-1.3 {World coordinates to pixel - basic 3} -match numbers -body {
set ::Plotchart::scaling(window,coordSystem) 0
::Plotchart::worldCoordinates "window" 0.0 0.0 100.0 1000.0
::Plotchart::viewPort "window" 10 20 110 120
::Plotchart::coordsToPixel "window" 100 100
} -result {110 110}
test Plotchart-1.4 {World coordinates to pixel - ordering} -match numbers -body {
set ::Plotchart::scaling(window,coordSystem) 0
::Plotchart::viewPort "window" 10 20 110 120
::Plotchart::worldCoordinates "window" 0.0 0.0 100.0 1000.0
::Plotchart::coordsToPixel "window" 100 100
} -result {110 110}
#
# World coordinates to pixels: Log scales
#
test Plotchart-1.5 {World coordinates to pixel - logX-Y} -match numbers -body {
set ::Plotchart::scaling(window,coordSystem) 1
set xmin [expr {log10(1.0)}]
set xmax [expr {log10(100.0)}]
::Plotchart::worldCoordinates "window" $xmin 0.0 $xmax 1000.0
::Plotchart::viewPort "window" 0 0 100 100
set result [concat \
[::Plotchart::coordsToPixel "window" 1 0] \
[::Plotchart::coordsToPixel "window" 100 1000] \
[::Plotchart::coordsToPixel "window" 10 500] \
]
} -result {0 100 100 0 50 50}
test Plotchart-1.6 {World coordinates to pixel - X-logY} -match numbers -body {
set ::Plotchart::scaling(window,coordSystem) 2
set ymin [expr {log10(1.0)}]
set ymax [expr {log10(1000.0)}]
::Plotchart::worldCoordinates "window" 0.0 $ymin 100.0 $ymax
::Plotchart::viewPort "window" 0 0 100 100
set result [concat \
[::Plotchart::coordsToPixel "window" 0 1] \
[::Plotchart::coordsToPixel "window" 100 1000] \
[::Plotchart::coordsToPixel "window" 50 [expr {sqrt(1000)}]] \
]
} -result {0 100 100 0 50 50}
test Plotchart-1.7 {World coordinates to pixel - logX-logY} -match numbers -body {
set ::Plotchart::scaling(window,coordSystem) 3
set xmin [expr {log10(1.0)}]
set xmax [expr {log10(100.0)}]
set ymin [expr {log10(1.0)}]
set ymax [expr {log10(1000.0)}]
::Plotchart::worldCoordinates "window" $xmin $ymin $xmax $ymax
::Plotchart::viewPort "window" 0 0 100 100
set result [concat \
[::Plotchart::coordsToPixel "window" 1 1] \
[::Plotchart::coordsToPixel "window" 100 1000] \
[::Plotchart::coordsToPixel "window" 10 [expr {sqrt(1000)}]] \
]
} -result {0 100 100 0 50 50}
test Plotchart-1.8 {World coordinates to pixel - radial coordinates} -match numbers -body {
set ::Plotchart::scaling(window,coordSystem) 4
::Plotchart::polarCoordinates "window" 10
::Plotchart::viewPort "window" 0 0 100 100
set result [concat \
[::Plotchart::coordsToPixel "window" 0 0] \
[::Plotchart::coordsToPixel "window" 10 90] \
[::Plotchart::coordsToPixel "window" 5 180] \
]
} -result {50 50 50 0 25 50}
#
# Pixels to world coordinates: Linear scales
#
test Plotchart-2.1 {Pixel to world coordinates - basic 1} -match numbers -body {
set ::Plotchart::scaling(window,coordSystem) 0
::Plotchart::viewPort "window" 10 20 110 120
::Plotchart::worldCoordinates "window" 0.0 0.0 100.0 1000.0
::Plotchart::pixelToCoords "window" 10 20
} -result {0 1000}
test Plotchart-2.2 {Pixel to world coordinates - basic 2} -match numbers -body {
set ::Plotchart::scaling(window,coordSystem) 0
::Plotchart::viewPort "window" 10 20 110 120
::Plotchart::worldCoordinates "window" 0.0 0.0 100.0 1000.0
::Plotchart::pixelToCoords "window" 110 120
} -result {100 0}
test Plotchart-2.3 {Pixel to world coordinates - ordering} -match numbers -body {
set ::Plotchart::scaling(window,coordSystem) 0
::Plotchart::worldCoordinates "window" 0.0 0.0 100.0 1000.0
::Plotchart::viewPort "window" 10 20 110 120
::Plotchart::pixelToCoords "window" 110 120
} -result {100 0}
#
# Pixels to world coordinates: Log scales
#
test Plotchart-2.4 {Pixel to world coordinates - logX-Y} -match numbers -body {
set ::Plotchart::scaling(window,coordSystem) 1
set xmin [expr {log10(1.0)}]
set xmax [expr {log10(100.0)}]
::Plotchart::worldCoordinates "window" $xmin 0.0 $xmax 1000.0
::Plotchart::viewPort "window" 0 0 100 100
set result [concat \
[::Plotchart::pixelToCoords "window" 0 100] \
[::Plotchart::pixelToCoords "window" 100 0] \
[::Plotchart::pixelToCoords "window" 50 50] \
]
} -result {1 0 100 1000 10 500}
test Plotchart-2.5 {Pixel to world coordinates - X-logY} -match numbers -body {
set ::Plotchart::scaling(window,coordSystem) 2
set ymin [expr {log10(1.0)}]
set ymax [expr {log10(1000.0)}]
::Plotchart::worldCoordinates "window" 0.0 $ymin 100.0 $ymax
::Plotchart::viewPort "window" 0 0 100 100
set result [concat \
[::Plotchart::pixelToCoords "window" 0 100] \
[::Plotchart::pixelToCoords "window" 100 0] \
[::Plotchart::pixelToCoords "window" 50 50] \
]
} -result [list 0 1 100 1000 50 [expr {sqrt(1000)}]]
test Plotchart-2.6 {Pixel to world coordinates - logX-logY} -match numbers -body {
set ::Plotchart::scaling(window,coordSystem) 3
set xmin [expr {log10(1.0)}]
set xmax [expr {log10(100.0)}]
set ymin [expr {log10(1.0)}]
set ymax [expr {log10(1000.0)}]
::Plotchart::worldCoordinates "window" $xmin $ymin $xmax $ymax
::Plotchart::viewPort "window" 0 0 100 100
set result [concat \
[::Plotchart::pixelToCoords "window" 0 100] \
[::Plotchart::pixelToCoords "window" 100 0] \
[::Plotchart::pixelToCoords "window" 50 50] \
]
} -result [list 1 1 100 1000 10 [expr {sqrt(1000)}]]
#
# Constructing nice scales
#
test Plotchart-3.1 {Nice scale 1} -match numbers -body {
::Plotchart::determineScale 0.1 1.0
} -result {0.0 1.0 0.2}
test Plotchart-3.2 {Nice scale 2} -match numbers -body {
::Plotchart::determineScale 0.001 0.01
} -result {0.0 0.01 0.002}
test Plotchart-3.3 {Nice scale 3} -match numbers -body {
::Plotchart::determineScale -0.2 0.9
} -result {-0.2 1.0 0.2}
test Plotchart-3.4 {Nice scale 4} -match numbers -body {
::Plotchart::determineScale -0.25 0.85
} -result {-0.4 1.0 0.2}
test Plotchart-3.5 {Nice scale 5} -match numbers -body {
::Plotchart::determineScale -0.25 0.7999
} -result {-0.4 0.8 0.2}
test Plotchart-3.6 {Nice scale 6} -match numbers -body {
::Plotchart::determineScale 10001 10010
} -result {10000 10010 2}
test Plotchart-3.7 {Nice scale 7} -match numbers -body {
::Plotchart::determineScale 10001 10015
} -result {10000 10015 5}
test Plotchart-3.8 {Nice scale 8} -match numbers -body {
::Plotchart::determineScale -1.7 26.8
} -result {-10.0 30.0 10.0}
test Plotchart-3.9 {Nice scale 9} -match numbers -body {
::Plotchart::determineScale 0.99999999999999911 1.0000000000000007
} -result {0.999999994 1.000000006 2e-009}
test Plotchart-3.10 {Nice scale from list} -match numbers -body {
::Plotchart::determineScaleFromList {-0.25 -0.1 0.6 0.6 0.85}
} -result {-0.4 1.0 0.2}
test Plotchart-3.11 {Nice scale from list with missing data} -match numbers -body {
::Plotchart::determineScaleFromList {-0.25 -0.1 0.6 {} {} {} 0.6 0.85}
} -result {-0.4 1.0 0.2}
#
# Graphical tests: plotting data
#
test Plotchart-4.1 {XY-plot} -constraints tk -body {
canvas .c -width 300 -height 200 -bg white
pack .c -fill both
.c delete all
set s [::Plotchart::createXYPlot .c {0.0 100.0 10.0} {0.0 100.0 20.0}]
set xd 5.0
set yd 20.0
set xold 0.0
set yold 50.0
for { set i 0 } { $i < 20 } { incr i } {
set xnew [expr {$xold+$xd}]
set ynew [expr {$yold+(rand()-0.5)*$yd}]
set ynew2 [expr {$yold+(rand()-0.5)*2.0*$yd}]
$s plot series1 $xnew $ynew
$s plot series2 $xnew $ynew2
set xold $xnew
set yold $ynew
}
$s title "Aha!"
$s xticklines green
$s yticklines red
$s legendconfig -position "top-left"
$s legendconfig -background grey
$s legend series1 "Series 1"
$s legend series2 "Series 2"
after 1000 {set waited 1}
vwait waited
set waited 0
set res [checkCanvasItems .c {data xaxis yaxis}]
destroy .c
set res
} -result 1 ;# {}
test Plotchart-4.2 {Piechart} -constraints tk -body {
canvas .c -width 300 -height 200 -bg white
pack .c -fill both
.c delete all
set s [::Plotchart::createPiechart .c]
$s plot {"Long names" 10 "Short names" 30 "Average" 40 "Ultra-short names" 5}
$s title "Okay - this works"
after 1000 {set waited 1}
vwait waited
set waited 0
#checkCanvasItems .c {data}
destroy .c
set result 1
} -result 1
test Plotchart-4.3 {Polar plot} -constraints tk -body {
canvas .c -width 300 -height 200 -bg white
pack .c -fill both
.c delete all
set s [::Plotchart::createPolarplot .c {3.0 1.0}]
for { set angle 0 } { $angle < 360.0 } { set angle [expr {$angle+10.0}] } {
set rad [expr {1.0+cos($angle*$::Plotchart::torad)}]
$s plot "cardioid" $rad $angle
}
$s title "Cardioid"
after 1000 {set waited 1}
vwait waited
set waited 0
set res [checkCanvasItems .c {data}]
destroy .c
set res
} -result 1
test Plotchart-4.4 {Barchart} -constraints tk -body {
canvas .c -width 300 -height 200 -bg white
pack .c -fill both
.c delete all
set s [::Plotchart::createBarchart .c {A B C D E} {0.0 10.0 2.0} 2]
$s plot series1 {1.0 4.0 6.0 1.0 7.0} red
$s plot series2 {0.0 3.0 7.0 9.3 2.0} green
$s title "Arbitrary data"
after 1000 {set waited 1}
vwait waited
set waited 0
set res [checkCanvasItems .c {data yaxis}]
destroy .c
set res
} -result 1
test Plotchart-4.5 {Barchart (stacked)} -constraints tk -body {
canvas .c -width 300 -height 200 -bg white
pack .c -fill both
.c delete all
set s [::Plotchart::createBarchart .c {A B C D E} {0.0 20.0 5.0} stacked]
$s plot series1 {1.0 4.0 6.0 1.0 7.0} red
$s plot series2 {0.0 3.0 7.0 9.3 2.0} green
$s title "Stacked diagram"
after 1000 {set waited 1}
vwait waited
set waited 0
set res [checkCanvasItems .c {data yaxis}]
destroy .c
set res
} -result 1
test Plotchart-4.6 {Horizontal barchart} -constraints tk -body {
canvas .c -width 300 -height 200 -bg white
pack .c -fill both
.c delete all
set s [::Plotchart::createHorizontalBarchart .c {0.0 10.0 2.0} {A B C D E} 2]
$s plot series1 {1.0 4.0 6.0 1.0 7.0} red
$s plot series2 {0.0 3.0 7.0 9.3 2.0} green
$s title "Arbitrary data"
after 1000 {set waited 1}
vwait waited
set waited 0
set res [checkCanvasItems .c {data xaxis}]
destroy .c
set res
} -result 1
test Plotchart-4.7 {Horizontal barchart (stacked)} -constraints tk -body {
canvas .c -width 300 -height 200 -bg white
pack .c -fill both
.c delete all
set s [::Plotchart::createHorizontalBarchart .c {0.0 20.0 5.0} {A B C D E} stacked]
$s plot series1 {1.0 4.0 6.0 1.0 7.0} red
$s plot series2 {0.0 3.0 7.0 9.3 2.0} green
$s title "Stacked diagram"
after 1000 {set waited 1}
vwait waited
set waited 0
set res [checkCanvasItems .c {data xaxis}]
destroy .c
set res
} -result 1
test Plotchart-4.8 {Timechart} -constraints tk -body {
canvas .c -width 300 -height 200 -bg white
pack .c -fill both
.c delete all
set s [::Plotchart::createTimechart .c "1 january 2004" \
"31 december 2004" 4]
$s period "Spring" "1 march 2004" "1 june 2004" green
$s period "Summer" "1 june 2004" "1 september 2004" yellow
$s vertline "1 jan" "1 january 2004"
$s vertline "1 apr" "1 april 2004"
$s vertline "1 jul" "1 july 2004"
$s vertline "1 oct" "1 october 2004"
$s milestone "Longest day" "21 july 2004"
$s title "Seasons (northern hemisphere)"
after 1000 {set waited 1}
vwait waited
set waited 0
#checkCanvasItems .c {data}
destroy .c
set result 1
} -result 1
test Plotchart-4.9 {Stripchart} -constraints tk -body {
canvas .c -width 300 -height 200 -bg white
pack .c -fill both
.c delete all
set s [::Plotchart::createStripchart .c {0.0 100.0 10.0} {0.0 100.0 20.0}]
proc gendata {s xold xd yold yd} {
set xnew [expr {$xold+$xd}]
set ynew [expr {$yold+(rand()-0.5)*$yd}]
set ynew2 [expr {$yold+(rand()-0.5)*2.0*$yd}]
$s plot series1 $xnew $ynew
$s plot series2 $xnew $ynew2
if { $xnew < 200 } {
after 200 [list gendata $s $xnew $xd $ynew $yd]
}
}
after 100 [list gendata $s 0.0 15.0 50.0 30.0]
$s title "Aha!"
$s background plot grey
after 4000 {set waited 1}
vwait waited
set waited 0
set res [checkCanvasItems .c {data xaxis yaxis}]
destroy .c
set res
} -result 1
test Plotchart-4.10 {Isometric plot} -constraints tk -body {
canvas .c -width 300 -height 200 -bg white
pack .c -fill both
.c delete all
set s [::Plotchart::createIsometricPlot .c {0.0 100.0} {0.0 200.0} noaxes]
::Plotchart::setZoomPan .c
$s plot rectangle 10.0 10.0 50.0 50.0 green
$s plot filled-rectangle 20.0 20.0 40.0 40.0 red
$s plot filled-circle 70.0 70.0 40.0 yellow
$s plot circle 70.0 70.0 42.0
after 100 {
::Plotchart::MoveItems .c 0 40
}
after 200 {
::Plotchart::MoveItems .c 0 -40
}
after 300 {
::Plotchart::ScaleItems .c 0 0 2
}
after 400 {
::Plotchart::ScaleItems .c 0 0 0.5
}
after 1000 {set waited 1}
vwait waited
set waited 0
#checkCanvasItems .c {data}
destroy .c
set result 1
} -result 1
test Plotchart-4.11 {Histogram} -constraints tk -body {
canvas .c -width 300 -height 200 -bg white
pack .c -fill both
.c delete all
set s [::Plotchart::createHistogram .c {0.0 100.0 10.0} {0.0 100.0 20.0}]
$s dataconfig series1 -colour green
set xd 5.0
set yd 20.0
set xold 0.0
set yold 50.0
for { set i 0 } { $i < 20 } { incr i } {
set xnew [expr {$xold+$xd}]
set ynew [expr {$yold+(rand()-0.5)*$yd}]
$s plot series1 $xnew $ynew
set xold $xnew
set yold $ynew
}
$s title "Aha!"
$s background axes grey
after 1000 {set waited 1}
vwait waited
set waited 0
set res [checkCanvasItems .c {data xaxis yaxis}]
destroy .c
set res
} -result 1 ;# {}
#
# Graphical tests: annotations and various plot/chart types
#
test Plotchart-5.1 {XY-plot - balloon} -constraints tk -body {
canvas .c -width 300 -height 200 -bg white
pack .c -fill both
.c delete all
set s [::Plotchart::createXYPlot .c {0.0 100.0 10.0} {0.0 100.0 20.0}]
set xd 5.0
set yd 20.0
set xold 0.0
set yold 50.0
for { set i 0 } { $i < 20 } { incr i } {
set xnew [expr {$xold+$xd}]
set ynew [expr {$yold+(rand()-0.5)*$yd}]
set ynew2 [expr {$yold+(rand()-0.5)*2.0*$yd}]
$s plot series1 $xnew $ynew
$s plot series2 $xnew $ynew2
set xold $xnew
set yold $ynew
}
$s title "Aha!"
$s xticklines green
$s yticklines red
$s balloonconfig -background green
$s balloon 50 50 "Here it is!" south-east
$s balloonconfig -background red -font "Times 14"
$s balloonconfig -margin 10
$s balloon 50 100 "No, here!" north-east
after 1000 {set waited 1}
vwait waited
set waited 0
set res [checkCanvasItems .c {data xaxis yaxis}]
destroy .c
set res
} -result 1 ;# {}
test Plotchart-5.2 {Gantt chart} -constraints tk -body {
canvas .c -width 600 -height 200 -bg white
pack .c -fill both
.c delete all
set s [::Plotchart::createGanttchart .c "1 january 2004" \
"31 december 2004" 4]
#
# Two tasks, add a summary for them
#
set begin [$s task "Spring" "1 march 2004" "1 june 2004" 30]
set end [$s task "Summer" "1 june 2004" "1 september 2004" 0]
$s summary "Half year" $begin $end
$s milestone "Holiday" "21 july 2004" blue
$s vertline "1 apr" "1 april 2004"
$s vertline "1 jul" "1 july 2004"
$s vertline "1 oct" "1 october 2004"
$s title "Seasons (northern hemisphere)"
after 1000 {set waited 1}
vwait waited
set waited 0
#set res [checkCanvasItems .c {data xaxis yaxis}]
destroy .c
set res
} -result 1 ;# {}
test Plotchart-5.3 {3D Bars} -constraints tk -body {
canvas .c -width 600 -height 200 -bg white
pack .c -fill both
.c delete all
set s [::Plotchart::create3DBarchart .c {-200.0 900.0 100.0} 7]
foreach {bar value} {red 765 green 234 blue 345 yellow 321
magenta 567 cyan -123 white 400} {
$s plot $bar $value $bar
}
$s title "3D Bars"
$s balloon 1.2 100 "Arrow pointing\nat second bar" south-east
after 1000 {set waited 1}
vwait waited
set waited 0
#set res [checkCanvasItems .c {data xaxis yaxis}]
destroy .c
set res
} -result 1 ;# {}
test Plotchart-5.4 {Radial chart} -constraints tk -body {
canvas .c -width 600 -height 400 -bg white
pack .c -fill both
.c delete all
set s [::Plotchart::createRadialchart .c {A B LongerName C} 10]
$s plot {1 2 3 4} green 2
$s plot {4 5 0 1} red 3
$s title "Sample of a radial chart"
after 1000 {set waited 1}
vwait waited
set waited 0
#set res [checkCanvasItems .c {data xaxis yaxis}]
destroy .c
set res
} -result 1 ;# {}
test Plotchart-5.5 {Filled radial chart} -constraints tk -body {
canvas .c -width 600 -height 400 -bg white
pack .c -fill both
.c delete all
set s [::Plotchart::createRadialchart .c {A B LongerName C} 10 filled]
$s plot {1 2 3 4} green 2
$s plot {4 5 0 1} red 3
$s title "Sample of a filled radial chart"
after 1000 {set waited 1}
vwait waited
set waited 0
#set res [checkCanvasItems .c {data xaxis yaxis}]
destroy .c
set res
} -result 1 ;# {}
test Plotchart-5.6 {Filled radial chart} -constraints tk -body {
canvas .c -width 600 -height 400 -bg white
pack .c -fill both
.c delete all
set s [::Plotchart::createRadialchart .c {A B LongerName C} 10 cumulative]
$s plot {1 2 3 4} green 2
$s plot {4 5 0 1} red 3
$s title "Sample of a cumulative radial chart"
after 1000 {set waited 1}
vwait waited
set waited 0
#set res [checkCanvasItems .c {data xaxis yaxis}]
destroy .c
set res
} -result 1 ;# {}
# -------------------------------------------------------------------------
::tcltest::cleanupTests
|