Tk Library Source Code
Check-in [807a93a8bb]
Not logged in
Bounty program for improvements to Tcl and certain Tcl packages.

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

Overview
Comment:Extend the set of tests for the coordinate transformation procedures. This revealed that the procedure pixelToCoords had not been updated for the various transformation options. This has now been corrected. Other changes: explicitly take care of an expected value of 0 and more accurate conversion factor degrees to radians.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | subtitles-and-corrected-tests
Files: files | file ages | folders
SHA1:807a93a8bbe000ebd737f93f70c9f7670bd89c85
User & Date: markus 2013-03-10 11:49:40
Context
2013-03-10
14:12
Document the subtext subcommands. Compute the new margins based on the presence or absence of subtexts to the axes. Bumped version to 2.1.0 to reflect the addition of these subcommands and the repair of the pixelToCoords procedure. check-in: b779f23b2e user: markus tags: subtitles-and-corrected-tests
11:49
Extend the set of tests for the coordinate transformation procedures. This revealed that the procedure pixelToCoords had not been updated for the various transformation options. This has now been corrected. Other changes: explicitly take care of an expected value of 0 and more accurate conversion factor degrees to radians. check-in: 807a93a8bb user: markus tags: subtitles-and-corrected-tests
2013-02-20
17:54
Fixed plotcontour-1.0 not properly cleaning up its main canvas. All tests pass. check-in: 5f65b7f4cc user: andreask tags: subtitles-and-corrected-tests
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to modules/plotchart/plotchart.tcl.

42
43
44
45
46
47
48

49

50

51
52
53
54
55
56
57
..
92
93
94
95
96
97
98

99

100

101
102
103
104
105
106
107
...
119
120
121
122
123
124
125

126

127

128
129
130
131
132
133
134
...
146
147
148
149
150
151
152

153

154

155
156
157
158
159
160
161
...
214
215
216
217
218
219
220

221

222

223
224
225
226
227
228
229
...
237
238
239
240
241
242
243

244

245

246
247
248
249
250
251
252
...
261
262
263
264
265
266
267

268

269

270
271
272
273
274
275
276
...
320
321
322
323
324
325
326

327

328

329
330
331
332
333
334
335
...
343
344
345
346
347
348
349

350

351

352
353
354
355
356
357
358
...
395
396
397
398
399
400
401

402

403

404
405
406
407
408
409
410
...
426
427
428
429
430
431
432

433

434

435
436
437
438
439
440
441
...
455
456
457
458
459
460
461

462

463

464
465
466
467
468
469
470
...
483
484
485
486
487
488
489

490

491

492
493
494
495
496
497
498
...
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
...
833
834
835
836
837
838
839


























840
841
842
843
844
845
846

   #
   # Array linking procedures with methods
   #
   set methodProc(xyplot,title)             DrawTitle
   set methodProc(xyplot,subtitle)          DrawSubtitle
   set methodProc(xyplot,xtext)             DrawXtext

   set methodProc(xyplot,ytext)             DrawYtext

   set methodProc(xyplot,vtext)             DrawVtext

   set methodProc(xyplot,plot)              DrawData
   set methodProc(xyplot,dot)               DrawDot
   set methodProc(xyplot,dotconfig)         DotConfigure
   set methodProc(xyplot,interval)          DrawInterval
   set methodProc(xyplot,trend)             DrawTrendLine
   set methodProc(xyplot,vector)            DrawVector
   set methodProc(xyplot,vectorconfig)      VectorConfigure
................................................................................
   set methodProc(xyplot,plotlist)          DrawDataList
   set methodProc(xyplot,plotarea)          GetPlotArea
   set methodProc(xyplot,canvas)            GetCanvas
   set methodProc(xyplot,deletedata)        DeleteData
   set methodProc(xlogyplot,title)          DrawTitle
   set methodProc(xlogyplot,subtitle)       DrawSubtitle
   set methodProc(xlogyplot,xtext)          DrawXtext

   set methodProc(xlogyplot,ytext)          DrawYtext

   set methodProc(xlogyplot,vtext)          DrawVtext

   set methodProc(xlogyplot,plot)           DrawData
   set methodProc(xlogyplot,dot)            DrawDot
   set methodProc(xlogyplot,labeldot)       DrawLabelDot
   set methodProc(xlogyplot,dotconfig)      DotConfigure
   set methodProc(xlogyplot,interval)       DrawLogInterval
   set methodProc(xlogyplot,trend)          DrawLogTrendLine
   set methodProc(xlogyplot,saveplot)       SavePlot
................................................................................
   set methodProc(xlogyplot,plaintext)      DrawPlainText
   set methodProc(xlogyplot,plaintextconfig) ConfigPlainText
   set methodProc(xlogyplot,canvas)         GetCanvas
   set methodProc(xlogyplot,deletedata)     DeleteData
   set methodProc(logxyplot,title)          DrawTitle
   set methodProc(logxyplot,subtitle)       DrawSubtitle
   set methodProc(logxyplot,xtext)          DrawXtext

   set methodProc(logxyplot,ytext)          DrawYtext

   set methodProc(logxyplot,vtext)          DrawVtext

   set methodProc(logxyplot,plot)           DrawData
   set methodProc(logxyplot,dot)            DrawDot
   set methodProc(logxyplot,labeldot)       DrawLabelDot
   set methodProc(logxyplot,dotconfig)      DotConfigure
   set methodProc(logxyplot,interval)       DrawLogInterval
   set methodProc(logxyplot,trend)          DrawLogTrendLine
   set methodProc(logxyplot,saveplot)       SavePlot
................................................................................
   set methodProc(logxyplot,plaintext)      DrawPlainText
   set methodProc(logxyplot,plaintextconfig)   ConfigPlainText
   set methodProc(logxyplot,canvas)         GetCanvas
   set methodProc(logxyplot,deletedata)     DeleteData
   set methodProc(logxlogyplot,title)          DrawTitle
   set methodProc(logxlogyplot,subtitle)       DrawSubtitle
   set methodProc(logxlogyplot,xtext)          DrawXtext

   set methodProc(logxlogyplot,ytext)          DrawYtext

   set methodProc(logxlogyplot,vtext)          DrawVtext

   set methodProc(logxlogyplot,plot)           DrawData
   set methodProc(logxlogyplot,dot)            DrawDot
   set methodProc(logxlogyplot,labeldot)       DrawLabelDot
   set methodProc(logxlogyplot,dotconfig)      DotConfigure
   set methodProc(logxlogyplot,interval)       DrawLogInterval
   set methodProc(logxlogyplot,trend)          DrawLogTrendLine
   set methodProc(logxlogyplot,saveplot)       SavePlot
................................................................................
   set methodProc(polarplot,plaintextconfig)   ConfigPlainText
   set methodProc(polarplot,labeldot)          DrawLabelDot
   set methodProc(polarplot,canvas)            GetCanvas
   set methodProc(polarplot,deletedata)        DeleteData
   set methodProc(histogram,title)             DrawTitle
   set methodProc(histogram,subtitle)          DrawSubtitle
   set methodProc(histogram,xtext)             DrawXtext

   set methodProc(histogram,ytext)             DrawYtext

   set methodProc(histogram,vtext)             DrawVtext

   set methodProc(histogram,plot)              DrawHistogramData
   set methodProc(histogram,plotcumulative)    DrawHistogramCumulative
   set methodProc(histogram,saveplot)          SavePlot
   set methodProc(histogram,dataconfig)        DataConfig
   set methodProc(histogram,xconfig)           XConfig
   set methodProc(histogram,yconfig)           YConfig
   set methodProc(histogram,yticklines)        DrawYTicklines
................................................................................
   set methodProc(histogram,plaintextconfig)   ConfigPlainText
   set methodProc(histogram,canvas)            GetCanvas
   set methodProc(histogram,bindlast)          BindLastHistogram
   set methodProc(histogram,deletedata)        DeleteData
   set methodProc(horizbars,title)             DrawTitle
   set methodProc(horizbars,subtitle)          DrawSubtitle
   set methodProc(horizbars,xtext)             DrawXtext

   set methodProc(horizbars,ytext)             DrawYtext

   set methodProc(horizbars,vtext)             DrawVtext

   set methodProc(horizbars,plot)              DrawHorizBarData
   set methodProc(horizbars,xticklines)        DrawXTicklines
   set methodProc(horizbars,background)        BackgroundColour
   set methodProc(horizbars,saveplot)          SavePlot
   set methodProc(horizbars,colours)           SetColours
   set methodProc(horizbars,colors)            SetColours
   set methodProc(horizbars,xconfig)           XConfig
................................................................................
   set methodProc(horizbars,drawobject)        DrawObject
   set methodProc(horizbars,object)            DrawObject
   set methodProc(horizbars,canvas)            GetCanvas
   set methodProc(horizbars,deletedata)        DeleteData
   set methodProc(vertbars,title)              DrawTitle
   set methodProc(vertbars,subtitle)           DrawSubtitle
   set methodProc(vertbars,xtext)              DrawXtext

   set methodProc(vertbars,ytext)              DrawYtext

   set methodProc(vertbars,vtext)              DrawVtext

   set methodProc(vertbars,plot)               DrawVertBarData
   set methodProc(vertbars,background)         BackgroundColour
   set methodProc(vertbars,yticklines)         DrawYTicklines
   set methodProc(vertbars,saveplot)           SavePlot
   set methodProc(vertbars,colours)            SetColours
   set methodProc(vertbars,colors)             SetColours
   set methodProc(vertbars,yconfig)            YConfig
................................................................................
   set methodProc(ganttchart,plaintextconfig)  ConfigPlainText
   set methodProc(ganttchart,hscroll)          ConnectHorizScrollbar
   set methodProc(ganttchart,vscroll)          ConnectVertScrollbar
   set methodProc(ganttchart,canvas)           GetCanvas
   set methodProc(stripchart,title)            DrawTitle
   set methodProc(stripchart,subtitle)         DrawSubtitle
   set methodProc(stripchart,xtext)            DrawXtext

   set methodProc(stripchart,ytext)            DrawYtext

   set methodProc(stripchart,vtext)            DrawVtext

   set methodProc(stripchart,plot)             DrawStripData
   set methodProc(stripchart,saveplot)         SavePlot
   set methodProc(stripchart,dataconfig)       DataConfig
   set methodProc(stripchart,xconfig)          XConfig
   set methodProc(stripchart,yconfig)          YConfig
   set methodProc(stripchart,yticklines)       DrawYTicklines
   set methodProc(stripchart,background)       BackgroundColour
................................................................................
   set methodProc(stripchart,drawobject)       DrawObject
   set methodProc(stripchart,object)           DrawObject
   set methodProc(stripchart,canvas)           GetCanvas
   set methodProc(stripchart,deletedata)       DeleteData
   set methodProc(isometric,title)             DrawTitle
   set methodProc(isometric,subtitle)          DrawSubtitle
   set methodProc(isometric,xtext)             DrawXtext

   set methodProc(isometric,ytext)             DrawYtext

   set methodProc(isometric,vtext)             DrawVtext

   set methodProc(isometric,plot)              DrawIsometricData
   set methodProc(isometric,saveplot)          SavePlot
   set methodProc(isometric,background)        BackgroundColour
   set methodProc(isometric,balloon)           DrawBalloon
   set methodProc(isometric,balloonconfig)     ConfigBalloon
   set methodProc(isometric,plaintext)         DrawPlainText
   set methodProc(isometric,plaintextconfig)   ConfigPlainText
................................................................................
   set methodProc(radialchart,plaintext)       DrawPlainText
   set methodProc(radialchart,plaintextconfig) ConfigPlainText
   set methodProc(radialchart,canvas)          GetCanvas
   set methodProc(radialchart,deletedata)      DeleteData
   set methodProc(txplot,title)                DrawTitle
   set methodProc(txplot,subtitle)             DrawSubtitle
   set methodProc(txplot,xtext)                DrawXtext

   set methodProc(txplot,ytext)                DrawYtext

   set methodProc(txplot,vtext)                DrawVtext

   set methodProc(txplot,plot)                 DrawTimeData
   set methodProc(txplot,interval)             DrawInterval
   set methodProc(txplot,saveplot)             SavePlot
   set methodProc(txplot,dataconfig)           DataConfig
   set methodProc(txplot,xconfig)              TConfig
   set methodProc(txplot,yconfig)              YConfig
   set methodProc(txplot,xticklines)           DrawXTicklines
................................................................................
   set methodProc(3dribbon,area)               Draw3DArea
   set methodProc(3dribbon,background)         BackgroundColour
   set methodProc(3dribbon,canvas)             GetCanvas
   set methodProc(3dribbon,deletedata)         DeleteData
   set methodProc(boxplot,title)               DrawTitle
   set methodProc(boxplot,subtitle)            DrawSubtitle
   set methodProc(boxplot,xtext)               DrawXtext

   set methodProc(boxplot,ytext)               DrawYtext

   set methodProc(boxplot,vtext)               DrawVtext

   set methodProc(boxplot,plot)                DrawBoxData
   set methodProc(boxplot,saveplot)            SavePlot
   set methodProc(boxplot,dataconfig)          DataConfig
   set methodProc(boxplot,xconfig)             XConfig
   set methodProc(boxplot,yconfig)             YConfig
   set methodProc(boxplot,xticklines)          DrawXTicklines
   set methodProc(boxplot,yticklines)          DrawYTicklines
................................................................................
   set methodProc(windrose,saveplot)           SavePlot
   set methodProc(windrose,title)              DrawTitle
   set methodProc(windrose,subtitle)           DrawSubtitle
   set methodProc(windrose,canvas)             GetCanvas
   set methodProc(targetdiagram,title)         DrawTitle
   set methodProc(targetdiagram,subtitle)      DrawSubtitle
   set methodProc(targetdiagram,xtext)         DrawXtext

   set methodProc(targetdiagram,ytext)         DrawYtext

   set methodProc(targetdiagram,vtext)         DrawVtext

   set methodProc(targetdiagram,plot)          DrawTargetData
   set methodProc(targetdiagram,saveplot)      SavePlot
   set methodProc(targetdiagram,background)    BackgroundColour
   set methodProc(targetdiagram,legendconfig)  LegendConfigure
   set methodProc(targetdiagram,legend)        DrawLegend
   set methodProc(targetdiagram,removefromlegend) RemoveFromLegend
   set methodProc(targetdiagram,balloon)       DrawBalloon
................................................................................
   set methodProc(3dribbonplot,zconfig)        ZConfig
   set methodProc(3dribbonplot,background)     BackgroundColour
   set methodProc(3dribbonplot,canvas)         GetCanvas
   set methodProc(3dribbonplot,deletedata)     DeleteData
   set methodProc(performance,title)           DrawTitle
   set methodProc(performance,subtitle)        DrawSubtitle
   set methodProc(performance,xtext)           DrawXtext

   set methodProc(performance,ytext)           DrawYtext

   set methodProc(performance,vtext)           DrawVtext

   set methodProc(performance,plot)            DrawPerformanceData
   set methodProc(performance,dot)             DrawDot
   set methodProc(performance,saveplot)        SavePlot
   set methodProc(performance,dataconfig)      DataConfig
   set methodProc(performance,xconfig)         XConfig
   set methodProc(performance,yconfig)         YConfig
   set methodProc(performance,xticklines)      DrawXTicklines
................................................................................
   set methodProc(table,topixels)              TableWorldToPixels
   set methodProc(table,canvas)                GetCanvas

   #
   # Auxiliary parameters
   #
   variable torad
   set torad [expr {3.1415926/180.0}]

   variable options
   variable option_keys
   variable option_values
   set options       {-colour -color  -symbol -type -filled -fillcolour -fillcolor -boxwidth -width -radius \
      -whisker -whiskerwidth -mediancolour -mediancolor  -medianwidth -style}
   set option_keys   {-colour -colour -symbol -type -filled -fillcolour -fillcolour -boxwidth -width -radius \
................................................................................
      set dy                  [expr {$scaling($w,ymax)-$scaling($w,ymin)}]
      set scaling($w,xfactor) [expr {$width/$dx}]
      set scaling($w,yfactor) [expr {$height/$dy}]
   }

   set xcrd [expr {$scaling($w,xmin)+($xpix-$scaling($w,pxmin))/$scaling($w,xfactor)}]
   set ycrd [expr {$scaling($w,ymax)-($ypix-$scaling($w,pymin))/$scaling($w,yfactor)}]


























   return [list $xcrd $ycrd]
}

# pixelToIndex --
#    Convert pixel coordinates to elements list index
# Arguments:
#    w           Name of the canvas







>

>

>







 







>

>

>







 







>

>

>







 







>

>

>







 







>

>

>







 







>

>

>







 







>

>

>







 







>

>

>







 







>

>

>







 







>

>

>







 







>

>

>







 







>

>

>







 







>

>

>







 







|







 







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







42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
..
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
...
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
...
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
...
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
...
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
...
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
...
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
...
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
...
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
...
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
...
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
...
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
...
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
...
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911

   #
   # Array linking procedures with methods
   #
   set methodProc(xyplot,title)             DrawTitle
   set methodProc(xyplot,subtitle)          DrawSubtitle
   set methodProc(xyplot,xtext)             DrawXtext
   set methodProc(xyplot,xsubtext)          DrawXsubtext
   set methodProc(xyplot,ytext)             DrawYtext
   set methodProc(xyplot,ysubtext)          DrawYsubtext
   set methodProc(xyplot,vtext)             DrawVtext
   set methodProc(xyplot,vsubtext)          DrawVsubtext
   set methodProc(xyplot,plot)              DrawData
   set methodProc(xyplot,dot)               DrawDot
   set methodProc(xyplot,dotconfig)         DotConfigure
   set methodProc(xyplot,interval)          DrawInterval
   set methodProc(xyplot,trend)             DrawTrendLine
   set methodProc(xyplot,vector)            DrawVector
   set methodProc(xyplot,vectorconfig)      VectorConfigure
................................................................................
   set methodProc(xyplot,plotlist)          DrawDataList
   set methodProc(xyplot,plotarea)          GetPlotArea
   set methodProc(xyplot,canvas)            GetCanvas
   set methodProc(xyplot,deletedata)        DeleteData
   set methodProc(xlogyplot,title)          DrawTitle
   set methodProc(xlogyplot,subtitle)       DrawSubtitle
   set methodProc(xlogyplot,xtext)          DrawXtext
   set methodProc(xlogyplot,xsubtext)       DrawXsubtext
   set methodProc(xlogyplot,ytext)          DrawYtext
   set methodProc(xlogyplot,ysubtext)       DrawYsubtext
   set methodProc(xlogyplot,vtext)          DrawVtext
   set methodProc(xlogyplot,vsubtext)       DrawVsubtext
   set methodProc(xlogyplot,plot)           DrawData
   set methodProc(xlogyplot,dot)            DrawDot
   set methodProc(xlogyplot,labeldot)       DrawLabelDot
   set methodProc(xlogyplot,dotconfig)      DotConfigure
   set methodProc(xlogyplot,interval)       DrawLogInterval
   set methodProc(xlogyplot,trend)          DrawLogTrendLine
   set methodProc(xlogyplot,saveplot)       SavePlot
................................................................................
   set methodProc(xlogyplot,plaintext)      DrawPlainText
   set methodProc(xlogyplot,plaintextconfig) ConfigPlainText
   set methodProc(xlogyplot,canvas)         GetCanvas
   set methodProc(xlogyplot,deletedata)     DeleteData
   set methodProc(logxyplot,title)          DrawTitle
   set methodProc(logxyplot,subtitle)       DrawSubtitle
   set methodProc(logxyplot,xtext)          DrawXtext
   set methodProc(logxyplot,xsubtext)       DrawXsubtext
   set methodProc(logxyplot,ytext)          DrawYtext
   set methodProc(logxyplot,ysubtext)       DrawYsubtext
   set methodProc(logxyplot,vtext)          DrawVtext
   set methodProc(logxyplot,vsubtext)       DrawVsubtext
   set methodProc(logxyplot,plot)           DrawData
   set methodProc(logxyplot,dot)            DrawDot
   set methodProc(logxyplot,labeldot)       DrawLabelDot
   set methodProc(logxyplot,dotconfig)      DotConfigure
   set methodProc(logxyplot,interval)       DrawLogInterval
   set methodProc(logxyplot,trend)          DrawLogTrendLine
   set methodProc(logxyplot,saveplot)       SavePlot
................................................................................
   set methodProc(logxyplot,plaintext)      DrawPlainText
   set methodProc(logxyplot,plaintextconfig)   ConfigPlainText
   set methodProc(logxyplot,canvas)         GetCanvas
   set methodProc(logxyplot,deletedata)     DeleteData
   set methodProc(logxlogyplot,title)          DrawTitle
   set methodProc(logxlogyplot,subtitle)       DrawSubtitle
   set methodProc(logxlogyplot,xtext)          DrawXtext
   set methodProc(logxlogyplot,xsubtext)       DrawXsubtext
   set methodProc(logxlogyplot,ytext)          DrawYtext
   set methodProc(logxlogyplot,ysubtext)       DrawYsubtext
   set methodProc(logxlogyplot,vtext)          DrawVtext
   set methodProc(logxlogyplot,vsubtext)       DrawVsubtext
   set methodProc(logxlogyplot,plot)           DrawData
   set methodProc(logxlogyplot,dot)            DrawDot
   set methodProc(logxlogyplot,labeldot)       DrawLabelDot
   set methodProc(logxlogyplot,dotconfig)      DotConfigure
   set methodProc(logxlogyplot,interval)       DrawLogInterval
   set methodProc(logxlogyplot,trend)          DrawLogTrendLine
   set methodProc(logxlogyplot,saveplot)       SavePlot
................................................................................
   set methodProc(polarplot,plaintextconfig)   ConfigPlainText
   set methodProc(polarplot,labeldot)          DrawLabelDot
   set methodProc(polarplot,canvas)            GetCanvas
   set methodProc(polarplot,deletedata)        DeleteData
   set methodProc(histogram,title)             DrawTitle
   set methodProc(histogram,subtitle)          DrawSubtitle
   set methodProc(histogram,xtext)             DrawXtext
   set methodProc(histogram,xsubtext)          DrawXsubtext
   set methodProc(histogram,ytext)             DrawYtext
   set methodProc(histogram,ysubtext)          DrawYsubtext
   set methodProc(histogram,vtext)             DrawVtext
   set methodProc(histogram,vsubtext)          DrawVsubtext
   set methodProc(histogram,plot)              DrawHistogramData
   set methodProc(histogram,plotcumulative)    DrawHistogramCumulative
   set methodProc(histogram,saveplot)          SavePlot
   set methodProc(histogram,dataconfig)        DataConfig
   set methodProc(histogram,xconfig)           XConfig
   set methodProc(histogram,yconfig)           YConfig
   set methodProc(histogram,yticklines)        DrawYTicklines
................................................................................
   set methodProc(histogram,plaintextconfig)   ConfigPlainText
   set methodProc(histogram,canvas)            GetCanvas
   set methodProc(histogram,bindlast)          BindLastHistogram
   set methodProc(histogram,deletedata)        DeleteData
   set methodProc(horizbars,title)             DrawTitle
   set methodProc(horizbars,subtitle)          DrawSubtitle
   set methodProc(horizbars,xtext)             DrawXtext
   set methodProc(horizbars,xsubtext)          DrawXsubtext
   set methodProc(horizbars,ytext)             DrawYtext
   set methodProc(horizbars,ysubtext)          DrawYsubtext
   set methodProc(horizbars,vtext)             DrawVtext
   set methodProc(horizbars,vsubtext)          DrawVsubtext
   set methodProc(horizbars,plot)              DrawHorizBarData
   set methodProc(horizbars,xticklines)        DrawXTicklines
   set methodProc(horizbars,background)        BackgroundColour
   set methodProc(horizbars,saveplot)          SavePlot
   set methodProc(horizbars,colours)           SetColours
   set methodProc(horizbars,colors)            SetColours
   set methodProc(horizbars,xconfig)           XConfig
................................................................................
   set methodProc(horizbars,drawobject)        DrawObject
   set methodProc(horizbars,object)            DrawObject
   set methodProc(horizbars,canvas)            GetCanvas
   set methodProc(horizbars,deletedata)        DeleteData
   set methodProc(vertbars,title)              DrawTitle
   set methodProc(vertbars,subtitle)           DrawSubtitle
   set methodProc(vertbars,xtext)              DrawXtext
   set methodProc(vertbars,xsubtext)           DrawXsubtext
   set methodProc(vertbars,ytext)              DrawYtext
   set methodProc(vertbars,ysubtext)           DrawYsubtext
   set methodProc(vertbars,vtext)              DrawVtext
   set methodProc(vertbars,vsubtext)           DrawVsubtext
   set methodProc(vertbars,plot)               DrawVertBarData
   set methodProc(vertbars,background)         BackgroundColour
   set methodProc(vertbars,yticklines)         DrawYTicklines
   set methodProc(vertbars,saveplot)           SavePlot
   set methodProc(vertbars,colours)            SetColours
   set methodProc(vertbars,colors)             SetColours
   set methodProc(vertbars,yconfig)            YConfig
................................................................................
   set methodProc(ganttchart,plaintextconfig)  ConfigPlainText
   set methodProc(ganttchart,hscroll)          ConnectHorizScrollbar
   set methodProc(ganttchart,vscroll)          ConnectVertScrollbar
   set methodProc(ganttchart,canvas)           GetCanvas
   set methodProc(stripchart,title)            DrawTitle
   set methodProc(stripchart,subtitle)         DrawSubtitle
   set methodProc(stripchart,xtext)            DrawXtext
   set methodProc(stripchart,xsubtext)         DrawXsubtext
   set methodProc(stripchart,ytext)            DrawYtext
   set methodProc(stripchart,ysubtext)         DrawYsubtext
   set methodProc(stripchart,vtext)            DrawVtext
   set methodProc(stripchart,vsubtext)         DrawVsubtext
   set methodProc(stripchart,plot)             DrawStripData
   set methodProc(stripchart,saveplot)         SavePlot
   set methodProc(stripchart,dataconfig)       DataConfig
   set methodProc(stripchart,xconfig)          XConfig
   set methodProc(stripchart,yconfig)          YConfig
   set methodProc(stripchart,yticklines)       DrawYTicklines
   set methodProc(stripchart,background)       BackgroundColour
................................................................................
   set methodProc(stripchart,drawobject)       DrawObject
   set methodProc(stripchart,object)           DrawObject
   set methodProc(stripchart,canvas)           GetCanvas
   set methodProc(stripchart,deletedata)       DeleteData
   set methodProc(isometric,title)             DrawTitle
   set methodProc(isometric,subtitle)          DrawSubtitle
   set methodProc(isometric,xtext)             DrawXtext
   set methodProc(isometric,xsubtext)          DrawXsubtext
   set methodProc(isometric,ytext)             DrawYtext
   set methodProc(isometric,ysubtext)          DrawYsubtext
   set methodProc(isometric,vtext)             DrawVtext
   set methodProc(isometric,vsubtext)          DrawVsubtext
   set methodProc(isometric,plot)              DrawIsometricData
   set methodProc(isometric,saveplot)          SavePlot
   set methodProc(isometric,background)        BackgroundColour
   set methodProc(isometric,balloon)           DrawBalloon
   set methodProc(isometric,balloonconfig)     ConfigBalloon
   set methodProc(isometric,plaintext)         DrawPlainText
   set methodProc(isometric,plaintextconfig)   ConfigPlainText
................................................................................
   set methodProc(radialchart,plaintext)       DrawPlainText
   set methodProc(radialchart,plaintextconfig) ConfigPlainText
   set methodProc(radialchart,canvas)          GetCanvas
   set methodProc(radialchart,deletedata)      DeleteData
   set methodProc(txplot,title)                DrawTitle
   set methodProc(txplot,subtitle)             DrawSubtitle
   set methodProc(txplot,xtext)                DrawXtext
   set methodProc(txplot,xsubtext)             DrawXsubtext
   set methodProc(txplot,ytext)                DrawYtext
   set methodProc(txplot,ysubtext)             DrawYsubtext
   set methodProc(txplot,vtext)                DrawVtext
   set methodProc(txplot,vsubtext)             DrawVsubtext
   set methodProc(txplot,plot)                 DrawTimeData
   set methodProc(txplot,interval)             DrawInterval
   set methodProc(txplot,saveplot)             SavePlot
   set methodProc(txplot,dataconfig)           DataConfig
   set methodProc(txplot,xconfig)              TConfig
   set methodProc(txplot,yconfig)              YConfig
   set methodProc(txplot,xticklines)           DrawXTicklines
................................................................................
   set methodProc(3dribbon,area)               Draw3DArea
   set methodProc(3dribbon,background)         BackgroundColour
   set methodProc(3dribbon,canvas)             GetCanvas
   set methodProc(3dribbon,deletedata)         DeleteData
   set methodProc(boxplot,title)               DrawTitle
   set methodProc(boxplot,subtitle)            DrawSubtitle
   set methodProc(boxplot,xtext)               DrawXtext
   set methodProc(boxplot,xsubtext)            DrawXsubtext
   set methodProc(boxplot,ytext)               DrawYtext
   set methodProc(boxplot,ysubtext)            DrawYsubtext
   set methodProc(boxplot,vtext)               DrawVtext
   set methodProc(boxplot,vsubtext)            DrawVsubtext
   set methodProc(boxplot,plot)                DrawBoxData
   set methodProc(boxplot,saveplot)            SavePlot
   set methodProc(boxplot,dataconfig)          DataConfig
   set methodProc(boxplot,xconfig)             XConfig
   set methodProc(boxplot,yconfig)             YConfig
   set methodProc(boxplot,xticklines)          DrawXTicklines
   set methodProc(boxplot,yticklines)          DrawYTicklines
................................................................................
   set methodProc(windrose,saveplot)           SavePlot
   set methodProc(windrose,title)              DrawTitle
   set methodProc(windrose,subtitle)           DrawSubtitle
   set methodProc(windrose,canvas)             GetCanvas
   set methodProc(targetdiagram,title)         DrawTitle
   set methodProc(targetdiagram,subtitle)      DrawSubtitle
   set methodProc(targetdiagram,xtext)         DrawXtext
   set methodProc(targetdiagram,xsubtext)      DrawXsubtext
   set methodProc(targetdiagram,ytext)         DrawYtext
   set methodProc(targetdiagram,ysubtext)      DrawYsubtext
   set methodProc(targetdiagram,vtext)         DrawVtext
   set methodProc(targetdiagram,vsubtext)      DrawVsubtext
   set methodProc(targetdiagram,plot)          DrawTargetData
   set methodProc(targetdiagram,saveplot)      SavePlot
   set methodProc(targetdiagram,background)    BackgroundColour
   set methodProc(targetdiagram,legendconfig)  LegendConfigure
   set methodProc(targetdiagram,legend)        DrawLegend
   set methodProc(targetdiagram,removefromlegend) RemoveFromLegend
   set methodProc(targetdiagram,balloon)       DrawBalloon
................................................................................
   set methodProc(3dribbonplot,zconfig)        ZConfig
   set methodProc(3dribbonplot,background)     BackgroundColour
   set methodProc(3dribbonplot,canvas)         GetCanvas
   set methodProc(3dribbonplot,deletedata)     DeleteData
   set methodProc(performance,title)           DrawTitle
   set methodProc(performance,subtitle)        DrawSubtitle
   set methodProc(performance,xtext)           DrawXtext
   set methodProc(performance,xsubtext)        DrawXsubtext
   set methodProc(performance,ytext)           DrawYtext
   set methodProc(performance,ysubtext)        DrawYsubtext
   set methodProc(performance,vtext)           DrawVtext
   set methodProc(performance,vsubtext)        DrawVsubtext
   set methodProc(performance,plot)            DrawPerformanceData
   set methodProc(performance,dot)             DrawDot
   set methodProc(performance,saveplot)        SavePlot
   set methodProc(performance,dataconfig)      DataConfig
   set methodProc(performance,xconfig)         XConfig
   set methodProc(performance,yconfig)         YConfig
   set methodProc(performance,xticklines)      DrawXTicklines
................................................................................
   set methodProc(table,topixels)              TableWorldToPixels
   set methodProc(table,canvas)                GetCanvas

   #
   # Auxiliary parameters
   #
   variable torad
   set torad [expr {acos(-1.0)/180.0}]

   variable options
   variable option_keys
   variable option_values
   set options       {-colour -color  -symbol -type -filled -fillcolour -fillcolor -boxwidth -width -radius \
      -whisker -whiskerwidth -mediancolour -mediancolor  -medianwidth -style}
   set option_keys   {-colour -colour -symbol -type -filled -fillcolour -fillcolour -boxwidth -width -radius \
................................................................................
      set dy                  [expr {$scaling($w,ymax)-$scaling($w,ymin)}]
      set scaling($w,xfactor) [expr {$width/$dx}]
      set scaling($w,yfactor) [expr {$height/$dy}]
   }

   set xcrd [expr {$scaling($w,xmin)+($xpix-$scaling($w,pxmin))/$scaling($w,xfactor)}]
   set ycrd [expr {$scaling($w,ymax)-($ypix-$scaling($w,pymin))/$scaling($w,yfactor)}]

   if { $scaling($w,coordSystem) != 0 } {
       switch -- $scaling($w,coordSystem) {
           1 {
               # log X versus Y
               set xcrd [expr {10.0**$xcrd}]
           }
           2 {
               # X versus log Y
               set ycrd [expr {10.0**$ycrd}]
           }
           3 {
               # log X versus log Y
               set xcrd [expr {10.0**$xcrd}]
               set ycrd [expr {10.0**$ycrd}]
           }
           4 {
               # radius versus angle
               set rad  [expr {hypot($xcrd,$ycrd)}]
               set phi  [expr {atan2($xycrd,$xcrd)/$torad}]
               set xcrd $rad
               set ycrd $phi
           }
       }
   }

   return [list $xcrd $ycrd]
}

# pixelToIndex --
#    Convert pixel coordinates to elements list index
# Arguments:
#    w           Name of the canvas

Changes to modules/plotchart/plotchart.test.

50
51
52
53
54
55
56

57
58
59






60
61
62
63
64
65
66
..
82
83
84
85
86
87
88



89
90
91
92
93
94
95
...
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
...
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
...
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
...
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
...
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
...
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
...
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
...
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
...
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
...
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
...
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
...
472
473
474
475
476
477
478




479
480
481
482
483
484
485
486
...
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
...
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
...
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
...
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
...
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
# 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 { abs($a - $e) > 0.5e-9*(abs($a)+abs($e)) } {
	    set match 0
	    break






	}
    }
    return $match
}

proc checkCanvasItems {w tags} {
    set okay 1
................................................................................
# 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
#




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.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}

































































test Plotchart-2.1 {Pixel to world coordinates - basic 1} -match numbers -body {
    set ::Plotchart::scaling(window,coordSystem) 1
    ::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) 1
    ::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) 1
    ::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}






















































test Plotchart-2.4 {Nice scale 1} -match numbers -body {
    ::Plotchart::determineScale 0.1 1.0
} -result {0.0 1.0 0.2}

test Plotchart-2.5 {Nice scale 2} -match numbers -body {
    ::Plotchart::determineScale 0.001 0.01
} -result {0.0 0.01 0.002}

test Plotchart-2.6 {Nice scale 3} -match numbers -body {
    ::Plotchart::determineScale -0.2 0.9
} -result {-0.2 1.0 0.2}

test Plotchart-2.7 {Nice scale 4} -match numbers -body {
    ::Plotchart::determineScale -0.25 0.85
} -result {-0.4 1.0 0.2}

test Plotchart-2.8 {Nice scale 5} -match numbers -body {
    ::Plotchart::determineScale -0.25 0.7999
} -result {-0.4 0.8 0.2}

test Plotchart-2.9 {Nice scale 6} -match numbers -body {
    ::Plotchart::determineScale 10001 10010
} -result {10000 10010 2}

test Plotchart-2.10 {Nice scale 7} -match numbers -body {
    ::Plotchart::determineScale 10001 10015
} -result {10000 10015 5}

test Plotchart-2.11 {Nice scale 8} -match numbers -body {
    ::Plotchart::determineScale -1.7 26.8
} -result {-10.0 30.0 10.0}

test Plotchart-2.12 {Nice scale 9} -match numbers -body {
    ::Plotchart::determineScale 0.99999999999999911  1.0000000000000007
} -result {0.999999994 1.000000006 2e-009}

test Plotchart-2.13 {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-2.14 {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}





test Plotchart-3.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 res [checkCanvasItems .c {data xaxis yaxis}]
    destroy .c
    set res
} -result 1 ;# {}


test Plotchart-3.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"
................................................................................

    #checkCanvasItems .c {data}
    destroy .c
    set result 1

} -result 1

test Plotchart-3.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 waited 0

    set res [checkCanvasItems .c {data}]
    destroy .c
    set res
} -result 1

test Plotchart-3.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
................................................................................
    set waited 0

    set res [checkCanvasItems .c {data yaxis}]
    destroy .c
    set res
} -result 1

test Plotchart-3.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
................................................................................
    set waited 0

    set res [checkCanvasItems .c {data yaxis}]
    destroy .c
    set res
} -result 1

test Plotchart-3.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
................................................................................
    set waited 0

    set res [checkCanvasItems .c {data xaxis}]
    destroy .c
    set res
} -result 1

test Plotchart-3.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
................................................................................
    set waited 0

    set res [checkCanvasItems .c {data xaxis}]
    destroy .c
    set res
} -result 1

test Plotchart-3.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]

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

    #checkCanvasItems .c {data}
    destroy .c
    set result 1

} -result 1

test Plotchart-3.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 waited 0

    set res [checkCanvasItems .c {data xaxis yaxis}]
    destroy .c
    set res
} -result 1

test Plotchart-3.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
................................................................................
    set waited 0

    #checkCanvasItems .c {data}
    destroy .c
    set result 1
} -result 1

test Plotchart-3.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 waited 0

    set res [checkCanvasItems .c {data xaxis yaxis}]
    destroy .c
    set res
} -result 1 ;# {}





test Plotchart-4.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 waited 0

    set res [checkCanvasItems .c {data xaxis yaxis}]
    destroy .c
    set res
} -result 1 ;# {}

test Plotchart-5.1 {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]

................................................................................
    set waited 0

    #set res [checkCanvasItems .c {data xaxis yaxis}]
    destroy .c
    set res
} -result 1 ;# {}

test Plotchart-6.1 {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
................................................................................

    #set res [checkCanvasItems .c {data xaxis yaxis}]
    destroy .c
    set res
} -result 1 ;# {}


test Plotchart-7.1 {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
................................................................................

    #set res [checkCanvasItems .c {data xaxis yaxis}]
    destroy .c
    set res
} -result 1 ;# {}


test Plotchart-7.2 {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
................................................................................

    #set res [checkCanvasItems .c {data xaxis yaxis}]
    destroy .c
    set res
} -result 1 ;# {}


test Plotchart-7.3 {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







>
|
|
|
>
>
>
>
>
>







 







>
>
>







 







|
>
|
>
>

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

|






|






|





>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|



|



|



|



|



|



|



|



|



|



|




|
>
>
|







 







|







 







|







 







|







 







|







 







|







 







|







 







|







 







|







 







|







 







|







 







>
>
>
>
|







 







|







 







|







 







|







 







|







 







|







50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
..
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
...
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
...
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
...
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
...
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
...
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
...
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
...
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
...
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
...
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
...
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
...
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
...
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
...
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
...
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
...
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
...
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
...
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
# 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
................................................................................
# 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.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 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"
................................................................................

    #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 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
................................................................................
    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
................................................................................
    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
................................................................................
    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
................................................................................
    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]

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

    #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 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
................................................................................
    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 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 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]

................................................................................
    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
................................................................................

    #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
................................................................................

    #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
................................................................................

    #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