-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathetrace.tcl
More file actions
589 lines (542 loc) · 25.6 KB
/
Copy pathetrace.tcl
File metadata and controls
589 lines (542 loc) · 25.6 KB
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
# Copyright (c) 2022-2025 Nicolas ROBERT.
# Distributed under MIT license. Please see LICENSE for details.
#
proc ticklecharts::traceEchartsVersion {minversion baseversion args} {
# Changes the script Echarts version variable.
#
# minversion - minimum version
# baseversion - current version
# args - not used.
#
# Returns nothing.
variable escript ; variable echarts_version
variable checkURL
# Minimum Echarts version.
if {[ticklecharts::vCompare $minversion $echarts_version] == 1} {
error "The minimum Echarts version for 'ticklEcharts' package\
is the version '$minversion', currently the modified version\
is '$echarts_version'"
}
if {[regexp {@([0-9.]+)} $escript -> match]} {
set vMap [list $match $echarts_version]
set escript [string map $vMap $escript]
} else {
puts stderr "warning(trace): Num version (@X.X.X) should be present in 'Echarts' path js.\
If no pattern matches, the script path is left unchanged\
and the 'echarts_version' variable is set to base version"
set echarts_version $baseversion
}
# Verify if a URL exists.
# Output warning message if url doesn't exists
if {$checkURL && [ticklecharts::isURL? $escript]} {
ticklecharts::urlExists? $escript
}
return {}
}
proc ticklecharts::traceEchartsGLVersion {minversion baseversion args} {
# Changes the script Echarts GL version variable.
#
# minversion - minimum version
# baseversion - current version
# args - not used.
#
# Returns nothing.
variable eGLscript ; variable gl_version
variable checkURL
# Minimum GL Echarts version.
if {[ticklecharts::vCompare $minversion $gl_version] == 1} {
error "The minimum Echarts GL version for 'ticklEcharts' package\
is the version '$minversion', currently the modified version\
is '$gl_version'"
}
if {[regexp {@([0-9.]+)} $eGLscript -> match]} {
set vMap [list $match $gl_version]
set eGLscript [string map $vMap $eGLscript]
} else {
puts stderr "warning(trace): Num version (@X.X.X) should be present in 'EchartsGL' path js.\
If no pattern matches, the script path is left unchanged\
and the 'gl_version' variable is set to base version"
set gl_version $baseversion
}
# Verify if a URL exists.
# Output warning message if url doesn't exists
if {$checkURL && [ticklecharts::isURL? $eGLscript]} {
ticklecharts::urlExists? $eGLscript
}
return {}
}
proc ticklecharts::traceGmapVersion {minversion baseversion args} {
# Changes the script Gmap version variable.
#
# minversion - minimum version
# baseversion - current version
# args - not used.
#
# Returns nothing.
variable gmscript ; variable gmap_version
variable checkURL
# Minimum WordCloud Echarts version.
if {[ticklecharts::vCompare $minversion $gmap_version] == 1} {
error "The minimum Echarts Gmap version for 'ticklEcharts' package\
is the version '$minversion', currently the modified version\
is '$gmap_version'"
}
if {[regexp {@([0-9.]+)} $gmscript -> match]} {
set vMap [list $match $gmap_version]
set gmscript [string map $vMap $gmscript]
} else {
puts stderr "warning(trace): Num version (@X.X.X) should be present in 'gmap' path js.\
If no pattern matches, the script path is left unchanged\
and the 'gmap_version' variable is set to base version"
set gmap_version $baseversion
}
# Verify if a URL exists.
# Output warning message if url doesn't exists
if {$checkURL && [ticklecharts::isURL? $gmscript]} {
ticklecharts::urlExists? $gmscript
}
return {}
}
proc ticklecharts::traceWCVersion {minversion baseversion args} {
# Changes the script echarts-wordcloud version variable.
#
# minversion - minimum version
# baseversion - current version
# args - not used.
#
# Returns nothing.
variable wcscript ; variable wc_version
variable checkURL
# Minimum WordCloud Echarts version.
if {[ticklecharts::vCompare $minversion $wc_version] == 1} {
error "The minimum Echarts wordcloud version for 'ticklEcharts' package\
is the version '$minversion', currently the modified version\
is '$wc_version'"
}
if {[regexp {@([0-9.]+)} $wcscript -> match]} {
set WCMap [list $match $wc_version]
set wcscript [string map $WCMap $wcscript]
} else {
puts stderr "warning(trace): Num version (@X.X.X) should be present in 'wordcloud' path js.\
If no pattern matches, the script path is left unchanged\
and the 'wc_version' variable is set to base version"
set wc_version $baseversion
}
# Verify if a URL exists.
# Output warning message if url doesn't exists
if {$checkURL && [ticklecharts::isURL? $wcscript]} {
ticklecharts::urlExists? $wcscript
}
return {}
}
proc ticklecharts::traceKeyGMAPI {args} {
# Changes the API key in Google script js.
#
# args - not used.
#
# Returns nothing.
variable gapiscript ; variable keyGMAPI
if {[regexp {key=([a-zA-Z0-9?_-]+)} $gapiscript -> match]} {
set vMap [list $match $keyGMAPI]
set gapiscript [string map $vMap $gapiscript]
} else {
puts stderr "warning(trace): 'key=' should be present in Google script path js.\
If no pattern matches, the script path is left unchanged."
}
return {}
}
proc ticklecharts::readEchartsVersion {minversion baseversion args} {
# Checks the first variable reading.
# Note : This trace is removed at first reading.
#
# minversion - minimum version
# baseversion - current version
# args - list command
#
# Returns nothing.
if {[ticklecharts::vCompare $minversion $baseversion] == 1} {
error "The minimum version for '[lindex $args 0]' must be equal\
to or greater to '$minversion', currently the variable\
is equal to '$baseversion'"
}
# Remove trace.
set vinfo [lindex [trace info variable [lindex $args 0]] 0 1]
trace remove variable [lindex $args 0] read [list {*}$vinfo]
return {}
}
proc ticklecharts::getTraceLevelProperties {level key value} {
# Gets trace level properties
#
# level - num level procedure
# key - key properties
# value - value properties
#
# Returns nothing
set properties {}
set key [string map {"-" ""} $key]
for {set i $level} {$i > 0} {incr i -1} {
set name [lindex [info level $i] 0]
if {[string match {ticklecharts::*} $name] || [ticklecharts::isAObject $name]} {
set property [string map {ticklecharts:: ""} $name]
# Adds an index if the level properties is related
# to a series or specific axes.
if {
[string match {ticklecharts::*Series} $name] ||
[string match {ticklecharts::[xy]Axis} $name] ||
[string match {ticklecharts::radarCoordinate} $name]
} {
set index [lindex [info level $i] 1]
if {[ticklecharts::typeOf $index] ne "num"} {
error "'$index' should be an integer value."
}
set property $property\($index)
}
if {$property ni $properties} {
lappend properties $property
}
}
}
set properties [lreverse $properties]
set obj [lindex $properties 0]
if {![ticklecharts::isAObject $obj]} {
error "First index of list for 'getTraceLevelProperties' command\
should be an object, now is '$obj'"
}
# No other classes accepted.
if {[$obj getType] ni {chart chart3D}} {
return {}
}
# Guess if '$value' is an object.
if {[ticklecharts::isAObject $value]} {
set value [$value get]
}
set keyP [join [list {*}[lrange $properties 1 end] $key] "."]
# Special case for 'parallelAxis'
if {[lindex $properties 1] eq "parallelAxis"} {
set trace [lreverse [$obj getTrace]]
set map [string map {parallelAxis {parallelAxis(*)}} $keyP]
set pos [lsearch -glob $trace $map]
if {$pos > -1} {
set re [string map {parallelAxis {parallelAxis\(([0-9]+)\)}} $keyP]
regexp $re [lindex $trace $pos] -> match
lset properties 1 "parallelAxis\([incr match])"
} else {
lset properties 1 "parallelAxis\(1)"
}
set keyP [join [list {*}[lrange $properties 1 end] $key] "."]
}
$obj setTrace $keyP $value
return {}
}
proc ticklecharts::track {properties} {
# The goal here is to find if certain values
# match each other (experimental procedure 2nd test)
# Maybe will be deleted... or reworked
# Currently tested for :
# - lineSeries
# - barSeries
# - barSeries3D
# Outputs :
# - A 'warning' message if there is a conflict between the properties.
# - An 'error' message if some axis combinations are not allowed.
#
# properties - list
#
# Returns nothing.
foreach {keyP value} $properties {
switch -glob -- $keyP {
"lineSeries(*).showAllSymbol" {
# https://echarts.apache.org/en/option.html#series-line.showAllSymbol
if {$value ni {nothing null}} {
foreach {k info} [dict filter $properties key xAxis(*).type] {
if {$info ne "category"} {
puts stderr "warning(trace): '$k' should be set to 'category'\
if '$keyP' is set to '$value'"
}
}
}
}
"barSeries(*).stack" -
"barSeries3D(*).stack" -
"lineSeries(*).stack" {
# https://echarts.apache.org/en/option.html#series-line.stack
# https://echarts.apache.org/en/option.html#series-bar.stack
# https://echarts.apache.org/en/option-gl.html#series-bar3D.stack
if {$value ni {nothing null}} {
foreach {k info} [dict filter $properties key yAxis(*).type] {
# Case barSeries (horizontal)
set xval ""
if {[string match {barSeries*} $keyP]} {
foreach {kb infob} [dict filter $properties key xAxis(*).type] {
set xval $infob
}
}
if {$info in {time category} && ($xval ne "value")} {
puts stderr "warning(trace): '$k' should be set to 'value' or 'log'\
if '$keyP' is set."
}
}
}
}
"barSeries(*).stackStrategy" -
"barSeries3D(*).stackStrategy" -
"lineSeries(*).stackStrategy" {
# https://echarts.apache.org/en/option.html#series-line.stackStrategy
# https://echarts.apache.org/en/option.html#series-bar.stackStrategy
# https://echarts.apache.org/en/option-gl.html#series-bar3D.stackStrategy
if {$value ni {nothing null}} {
lassign [split $keyP "."] series _
if {![dict exists $properties $series.stack] || [dict get $properties $series.stack] in {nothing null}} {
puts stderr "warning(trace): If '$keyP' is set, '$series.stack' should be set too."
}
}
}
"lineSeries(*).label.distance" {
# https://echarts.apache.org/en/option.html#series-line.label.distance
lassign [split $keyP "."] series _
if {($value ni {nothing null}) && [dict exists $properties $series.label.position]} {
set v [dict get $properties $series.label.position]
if {($v ni {nothing null}) && ($v ni {top insideRight})} {
puts stderr "warning(trace): '$keyP' is valid only\
when '$series.label.position' is a 'string' (like 'top', 'insideRight')."
}
}
}
"lineSeries(*).labelLine.lineStyle.miterLimit" {
# https://echarts.apache.org/en/option.html#series-line.labelLine.lineStyle.miterLimit
lassign [split $keyP "."] series _
if {($value ni {nothing null}) && [dict exists $properties $series.labelLine.lineStyle.join]} {
set v [dict get $properties $series.labelLine.lineStyle.join]
if {$v ne "miter"} {
puts stderr "warning(trace): '$keyP' is valid only\
when '$series.labelLine.lineStyle.join' is set as 'miter'"
}
}
}
"lineSeries(*).labelLine.lineStyle.join" {
# https://echarts.apache.org/en/option.html#series-line.labelLine.lineStyle.join
lassign [split $keyP "."] series _
if {($value ni {nothing null}) && [dict exists $properties $series.labelLine.lineStyle.miterLimit]} {
set v [dict get $properties $series.labelLine.lineStyle.miterLimit]
if {$v eq "nothing"} {
puts stderr "warning(trace): '$keyP' is valid only\
when '$series.labelLine.lineStyle.miterLimit' is set, now it set to '$v'"
}
}
}
"lineSeries(*).itemStyle.borderMiterLimit" {
# https://echarts.apache.org/en/option.html#series-line.itemStyle.borderMiterLimit
lassign [split $keyP "."] series _
if {($value ni {nothing null}) && [dict exists $properties $series.itemStyle.borderJoin]} {
set v [dict get $properties $series.itemStyle.borderJoin]
if {$v ne "miter"} {
puts stderr "warning(trace): '$keyP' is valid only\
when '$series.itemStyle.borderJoin' is set as 'miter'"
}
}
}
"lineSeries(*).itemStyle.borderJoin" {
# Doc e.g: https://echarts.apache.org/en/option.html#series-line.itemStyle.borderJoin
lassign [split $keyP "."] series _
if {($value eq "miter") && [dict exists $properties $series.itemStyle.borderMiterLimit]} {
set v [dict get $properties $series.itemStyle.borderMiterLimit]
if {$v in {nothing null}} {
puts stderr "warning(trace): '$keyP' is valid only\
when '$series.itemStyle.borderMiterLimit' is set, now it set to '$v'"
}
}
}
"lineSeries(*).label.ellipsis" {
# https://echarts.apache.org/en/option.html#series-line.label.ellipsis
lassign [split $keyP "."] series _
if {($value ni {nothing null}) && [dict exists $properties $series.label.overflow]} {
set v [dict get $properties $series.label.overflow]
if {$v ne "truncate"} {
puts stderr "warning(trace): '$keyP' is displayed when\
'$series.label.overflow' is set to 'truncate'."
}
}
}
"xAxis(*).id" -
"yAxis(*).id" {
# Some axis combinations are not allowed.
foreach axisID {
angleAxis radiusAxis radarCoordinate
singleAxis parallelAxis
} {
if {[dict keys $properties ${axisID}*.id] ne ""} {
regsub {\(\d+\)\.id} $keyP {} axis1
return -code error "'$axisID' not suitable with '$axis1'"
}
}
}
"barSeries(*).data" -
"lineSeries(*).data" {
if {$value ne ""} {
foreach axis {xAxis yAxis} {
foreach {k info} [dict filter $properties key ${axis}(*).data] {
if {($info ne "nothing") && [llength $value] > 1} {
return -code error "'$keyP' is defined as \[\[X, Y] \[...]], data\
'$axis.data' property should not exist."
}
}
}
}
}
"xAxis(*).data" -
"yAxis(*).data" {
if {($value ni {nothing null}) && [llength $value] > 1} {
return -code error "'$keyP' cannot be defined as \[\[X, Y] \[...]]."
}
}
"yAxis(*).alignTicks" -
"xAxis(*).alignTicks" {
# https://echarts.apache.org/en/option.html#xAxis.alignTicks
if {($value ni {nothing null}) && $value} {
set axis [lindex [split $keyP "."] 0]
if {[dict exists $properties ${axis}.type]} {
set p [dict get $properties ${axis}.type]
if {($p ne "null") && ($p ni {value log})} {
puts stderr "warning(trace): ${axis}.type should be set to\
'value' or 'log' if '$keyP' is set to '$value'."
}
}
}
}
"yAxis(*).scale" - "radiusAxis.scale" - "angleAxis.scale" -
"xAxis(*).scale" - "singleAxis.scale" - "parallelAxis(*).scale" {
# https://echarts.apache.org/en/option.html#xAxis.scale
if {($value ni {nothing null}) && $value} {
set axis [lindex [split $keyP "."] 0]
if {[dict exists $properties ${axis}.type]} {
set p [dict get $properties ${axis}.type]
if {($p ne "null") && ($p ne "value")} {
puts stderr "warning(trace): ${axis}.type should be set to\
'value' if '$keyP' is set to '$value'."
}
}
if {[dict exists $properties ${axis}.max] &&
[dict exists $properties ${axis}.min]
} {
set max [dict get $properties ${axis}.max]
set min [dict get $properties ${axis}.min]
if {($max ni {nothing null}) && ($min ni {nothing null})} {
puts stderr "warning(trace): ${axis}.scale is unavailable\
when the 'min' and 'max' properties are set."
}
}
}
}
"yAxis(*).splitNumber" - "singleAxis.splitNumber" - "angleAxis.splitNumber" -
"xAxis(*).splitNumber" - "radiusAxis.splitNumber" - "parallelAxis(*).splitNumber" {
# https://echarts.apache.org/en/option.html#xAxis.splitNumber
if {$value ni {nothing null}} {
set axis [lindex [split $keyP "."] 0]
if {[dict exists $properties ${axis}.type]} {
set p [dict get $properties ${axis}.type]
if {($p ne "null") && ($p eq "category")} {
puts stderr "warning(trace): ${axis}.type should not be set to\
'category' if '$keyP' is set."
}
}
}
}
"yAxis(*).interval" - "singleAxis.interval" - "angleAxis.interval" -
"xAxis(*).interval" - "radiusAxis.interval" - "parallelAxis(*).interval" {
# https://echarts.apache.org/en/option.html#xAxis.interval
if {$value ni {nothing null}} {
set axis [lindex [split $keyP "."] 0]
if {[dict exists $properties ${axis}.type]} {
set p [dict get $properties ${axis}.type]
if {($p ne "null") && ($p eq "category")} {
puts stderr "warning(trace): ${axis}.type should not be set to\
'category' if '$keyP' is set."
}
}
}
}
"yAxis(*).minInterval" - "yAxis(*).maxInterval" - "singleAxis.maxInterval" -
"radiusAxis.minInterval" - "radiusAxis.maxInterval" - "angleAxis.maxInterval" -
"xAxis(*).minInterval" - "xAxis(*).maxInterval" - "singleAxis.minInterval" -
"angleAxis.minInterval" - "parallelAxis(*).maxInterval" - "parallelAxis(*).minInterval" {
# https://echarts.apache.org/en/option.html#xAxis.minInterval
# https://echarts.apache.org/en/option.html#xAxis.maxInterval
if {$value ni {nothing null}} {
set axis [lindex [split $keyP "."] 0]
if {[dict exists $properties ${axis}.type]} {
set p [dict get $properties ${axis}.type]
if {($p ni {null nothing}) && ($p ni {value time})} {
puts stderr "warning(trace): ${axis}.type should not be set to\
'$p' if '$keyP' is set."
}
}
}
}
"yAxis(*).logBase" - "singleAxis.logBase" - "angleAxis.logBase" -
"xAxis(*).logBase" - "radiusAxis.logBase" - "parallelAxis(*).logBase" {
# https://echarts.apache.org/en/option.html#xAxis.logBase
if {$value ni {nothing null}} {
set axis [lindex [split $keyP "."] 0]
if {[dict exists $properties ${axis}.type]} {
set p [dict get $properties ${axis}.type]
if {($p ne "null") && ($p ne "log")} {
puts stderr "warning(trace): ${axis}.type should be set to\
'log' if '$keyP' is set."
}
}
}
}
"yAxis(*).offset" -
"xAxis(*).offset" {
# https://echarts.apache.org/en/option.html#xAxis.offset
# https://echarts.apache.org/en/option.html#yAxis.offset
if {$value ni {nothing null}} {
set axis [lindex [split $keyP "."] 0]
if {[dict exists $properties ${axis}.axisLine.onZero] &&
[dict get $properties ${axis}.axisLine.onZero]} {
puts stderr "warning(trace): Set '${axis}.axisLine.onZero' to\
'False' to activate '$keyP' option."
}
}
}
"xAxis(*).tooltip" - "yAxis(*).tooltip" - "radiusAxis.tooltip" -
"angleAxis.tooltip" - "parallelAxis(*).tooltip" - "parallel.parallelAxisDefault.tooltip" {
if {$value ni {nothing null}} {
if {$keyP eq "parallel.parallelAxisDefault.tooltip"} {
set axis [string map {.tooltip ""} $keyP]
} else {
set axis [lindex [split $keyP "."] 0]
}
if {[dict exists $properties ${axis}.triggerEvent] &&
![string equal -nocase "true" [dict get $properties ${axis}.triggerEvent]]
} {
puts stderr "warning(trace): Set '${axis}.triggerEvent' to\
'True' to activate '$keyP' option."
}
}
}
}
}
return {}
}
namespace eval ticklecharts {
# Minimum versions :
proc EVMIN {} {return "5.0.0"}
proc GLVMIN {} {return "2.0.0"}
proc GMAPVMIN {} {return "1.5.0"}
proc WCVMIN {} {return "2.0.0"}
# Adds a trace when the variable version is read for the first time.
# This trace command is removed on first reading.
trace add variable echarts_version read [list ticklecharts::readEchartsVersion [EVMIN] $echarts_version]
trace add variable gl_version read [list ticklecharts::readEchartsVersion [GLVMIN] $gl_version]
trace add variable gmap_version read [list ticklecharts::readEchartsVersion [GMAPVMIN] $gmap_version]
trace add variable wc_version read [list ticklecharts::readEchartsVersion [WCVMIN] $wc_version]
# When the version is modified adds trace command.
# - The first argument of the command is the minimum version.
# - The last argument of the command is the current version.
trace add variable echarts_version write [list ticklecharts::traceEchartsVersion [EVMIN] $echarts_version]
trace add variable gl_version write [list ticklecharts::traceEchartsGLVersion [GLVMIN] $gl_version]
trace add variable gmap_version write [list ticklecharts::traceGmapVersion [GMAPVMIN] $gmap_version]
trace add variable wc_version write [list ticklecharts::traceWCVersion [WCVMIN] $wc_version]
trace add variable keyGMAPI write [list ticklecharts::traceKeyGMAPI]
}