@orbcharts/plugins-basic 3.0.1 → 3.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +200 -200
- package/dist/lib/gridObservables.d.ts +1 -0
- package/dist/orbcharts-plugins-basic.es.js +14800 -13543
- package/dist/orbcharts-plugins-basic.umd.js +129 -99
- package/dist/src/base/BaseOrdinalBubbles.d.ts +26 -0
- package/dist/src/base/BaseRacingBars.d.ts +2 -1
- package/dist/src/base/BaseRacingLabels.d.ts +1 -0
- package/dist/src/base/BaseXZoom.d.ts +18 -0
- package/dist/src/grid/gridObservables.d.ts +4 -7
- package/dist/src/multiValue/defaults.d.ts +5 -1
- package/dist/src/multiValue/index.d.ts +4 -0
- package/dist/src/multiValue/multiValueObservables.d.ts +14 -1
- package/dist/src/multiValue/plugins/OrdinalAux.d.ts +3 -0
- package/dist/src/multiValue/plugins/OrdinalAxis.d.ts +3 -0
- package/dist/src/multiValue/plugins/OrdinalBubbles.d.ts +3 -0
- package/dist/src/multiValue/plugins/OrdinalZoom.d.ts +1 -0
- package/lib/core-types.ts +7 -7
- package/lib/core.ts +6 -6
- package/lib/gridObservables.ts +6 -0
- package/lib/plugins-basic-types.ts +6 -6
- package/package.json +48 -44
- package/src/base/BaseBars.ts +765 -765
- package/src/base/BaseBarsTriangle.ts +676 -676
- package/src/base/BaseDots.ts +464 -464
- package/src/base/BaseGroupAxis.ts +691 -691
- package/src/base/BaseLegend.ts +684 -684
- package/src/base/BaseLineAreas.ts +629 -629
- package/src/base/BaseLines.ts +706 -706
- package/src/base/BaseOrdinalBubbles.ts +728 -0
- package/src/base/BaseRacingBars.ts +582 -551
- package/src/base/BaseRacingLabels.ts +404 -396
- package/src/base/BaseRacingValueLabels.ts +403 -403
- package/src/base/BaseStackedBars.ts +782 -782
- package/src/base/BaseTooltip.ts +386 -386
- package/src/base/BaseValueAxis.ts +600 -600
- package/src/base/BaseXAxis.ts +427 -427
- package/src/base/BaseXZoom.ts +242 -0
- package/src/base/BaseYAxis.ts +389 -389
- package/src/base/types.ts +2 -2
- package/src/const.ts +30 -30
- package/src/grid/defaults.ts +213 -213
- package/src/grid/gridObservables.ts +635 -612
- package/src/grid/index.ts +16 -16
- package/src/grid/plugins/Bars.ts +69 -69
- package/src/grid/plugins/BarsPN.ts +66 -66
- package/src/grid/plugins/BarsTriangle.ts +73 -73
- package/src/grid/plugins/Dots.ts +68 -68
- package/src/grid/plugins/GridLegend.ts +107 -107
- package/src/grid/plugins/GridTooltip.ts +66 -66
- package/src/grid/plugins/GroupAux.ts +1095 -1120
- package/src/grid/plugins/GroupAxis.ts +73 -73
- package/src/grid/plugins/GroupZoom.ts +218 -218
- package/src/grid/plugins/LineAreas.ts +65 -65
- package/src/grid/plugins/Lines.ts +59 -59
- package/src/grid/plugins/StackedBars.ts +64 -64
- package/src/grid/plugins/StackedValueAxis.ts +96 -96
- package/src/grid/plugins/ValueAxis.ts +94 -94
- package/src/index.ts +6 -6
- package/src/multiGrid/defaults.ts +244 -244
- package/src/multiGrid/index.ts +14 -14
- package/src/multiGrid/multiGridObservables.ts +50 -50
- package/src/multiGrid/plugins/MultiBars.ts +108 -108
- package/src/multiGrid/plugins/MultiBarsTriangle.ts +114 -114
- package/src/multiGrid/plugins/MultiDots.ts +102 -102
- package/src/multiGrid/plugins/MultiGridLegend.ts +169 -169
- package/src/multiGrid/plugins/MultiGridTooltip.ts +66 -66
- package/src/multiGrid/plugins/MultiGroupAxis.ts +137 -137
- package/src/multiGrid/plugins/MultiLineAreas.ts +107 -107
- package/src/multiGrid/plugins/MultiLines.ts +101 -101
- package/src/multiGrid/plugins/MultiStackedBars.ts +106 -106
- package/src/multiGrid/plugins/MultiStackedValueAxis.ts +134 -134
- package/src/multiGrid/plugins/MultiValueAxis.ts +134 -134
- package/src/multiGrid/plugins/OverlappingStackedValueAxes.ts +300 -300
- package/src/multiGrid/plugins/OverlappingValueAxes.ts +300 -300
- package/src/multiValue/defaults.ts +523 -431
- package/src/multiValue/index.ts +16 -12
- package/src/multiValue/multiValueObservables.ts +781 -666
- package/src/multiValue/plugins/MultiValueLegend.ts +107 -107
- package/src/multiValue/plugins/MultiValueTooltip.ts +66 -66
- package/src/multiValue/plugins/OrdinalAux.ts +661 -0
- package/src/multiValue/plugins/OrdinalAxis.ts +525 -0
- package/src/multiValue/plugins/OrdinalBubbles.ts +226 -0
- package/src/multiValue/plugins/OrdinalZoom.ts +57 -0
- package/src/multiValue/plugins/RacingBars.ts +375 -373
- package/src/multiValue/plugins/RacingCounterTexts.ts +300 -300
- package/src/multiValue/plugins/RacingValueAxis.ts +114 -114
- package/src/multiValue/plugins/Scatter.ts +486 -426
- package/src/multiValue/plugins/ScatterBubbles.ts +635 -554
- package/src/multiValue/plugins/XAxis.ts +107 -107
- package/src/multiValue/plugins/XYAux.ts +683 -682
- package/src/multiValue/plugins/XYAxes.ts +194 -194
- package/src/multiValue/plugins/XYAxes_legacy.ts +683 -683
- package/src/multiValue/plugins/XZoom.ts +40 -299
- package/src/noneData/defaults.ts +102 -102
- package/src/noneData/index.ts +3 -3
- package/src/noneData/plugins/Container.ts +27 -27
- package/src/noneData/plugins/Tooltip.ts +373 -373
- package/src/relationship/defaults.ts +221 -221
- package/src/relationship/index.ts +5 -5
- package/src/relationship/plugins/ForceDirected.ts +1173 -1173
- package/src/relationship/plugins/ForceDirectedBubbles.ts +1411 -1411
- package/src/relationship/plugins/RelationshipLegend.ts +100 -100
- package/src/relationship/plugins/RelationshipTooltip.ts +66 -66
- package/src/relationship/relationshipObservables.ts +49 -49
- package/src/series/defaults.ts +221 -221
- package/src/series/index.ts +9 -9
- package/src/series/plugins/Bubbles.ts +636 -636
- package/src/series/plugins/Pie.ts +623 -623
- package/src/series/plugins/PieEventTexts.ts +284 -284
- package/src/series/plugins/PieLabels.ts +640 -640
- package/src/series/plugins/Rose.ts +516 -516
- package/src/series/plugins/RoseLabels.ts +600 -600
- package/src/series/plugins/SeriesLegend.ts +107 -107
- package/src/series/plugins/SeriesTooltip.ts +66 -66
- package/src/series/seriesObservables.ts +145 -145
- package/src/series/seriesUtils.ts +51 -51
- package/src/tree/defaults.ts +102 -102
- package/src/tree/index.ts +4 -4
- package/src/tree/plugins/TreeLegend.ts +100 -100
- package/src/tree/plugins/TreeMap.ts +341 -341
- package/src/tree/plugins/TreeTooltip.ts +66 -66
- package/src/utils/commonUtils.ts +31 -31
- package/src/utils/d3Graphics.ts +176 -176
- package/src/utils/d3Utils.ts +92 -92
- package/src/utils/observables.ts +14 -14
- package/src/utils/orbchartsUtils.ts +129 -129
- package/tsconfig.base.json +13 -13
- package/tsconfig.json +2 -2
- package/vite.config.js +22 -22
- package/dist/src/multiValue/plugins/OrdinalXAxis.d.ts +0 -0
- package/dist/src/multiValue/plugins/RankingAxis_legacy.d.ts +0 -0
- package/src/multiValue/plugins/OrdinalXAxis.ts +0 -0
- package/src/multiValue/plugins/RankingAxis_legacy.ts +0 -109
@@ -1,432 +1,524 @@
|
|
1
|
-
import type { ComputedDataTypeMap } from '../../lib/core-types'
|
2
|
-
import type {
|
3
|
-
MultiValueLegendParams,
|
4
|
-
MultiValueTooltipParams,
|
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
|
-
const
|
46
|
-
const
|
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
|
-
return
|
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
|
-
if (num === null || Number.isNaN(num) == true) {
|
399
|
-
return num || 0
|
400
|
-
}
|
401
|
-
const
|
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
|
-
|
1
|
+
import type { ComputedDataTypeMap } from '../../lib/core-types'
|
2
|
+
import type {
|
3
|
+
MultiValueLegendParams,
|
4
|
+
MultiValueTooltipParams,
|
5
|
+
OrdinalBubblesParams,
|
6
|
+
OrdinalAuxParams,
|
7
|
+
OrdinalAxisParams,
|
8
|
+
OrdinalZoomParams,
|
9
|
+
RacingBarsParams,
|
10
|
+
RacingCounterTextsParams,
|
11
|
+
RacingValueAxisParams,
|
12
|
+
ScatterParams,
|
13
|
+
ScatterBubblesParams,
|
14
|
+
XAxisParams,
|
15
|
+
XYAuxParams,
|
16
|
+
XYAxesParams,
|
17
|
+
XZoomParams
|
18
|
+
} from '../../lib/plugins-basic-types'
|
19
|
+
|
20
|
+
|
21
|
+
export const DEFAULT_MULTI_VALUE_LEGEND_PARAMS: MultiValueLegendParams = {
|
22
|
+
// position: 'right',
|
23
|
+
// justify: 'end',
|
24
|
+
placement: 'bottom',
|
25
|
+
padding: 28,
|
26
|
+
// offset: [0, 0],
|
27
|
+
backgroundFill: 'none',
|
28
|
+
backgroundStroke: 'none',
|
29
|
+
gap: 10,
|
30
|
+
listRectWidth: 14,
|
31
|
+
listRectHeight: 14,
|
32
|
+
listRectRadius: 0,
|
33
|
+
// highlightEvent: false
|
34
|
+
textColorType: 'primary'
|
35
|
+
}
|
36
|
+
|
37
|
+
export const DEFAULT_MULTI_VALUE_TOOLTIP_PARAMS: MultiValueTooltipParams = {
|
38
|
+
backgroundColorType: 'background',
|
39
|
+
strokeColorType: 'primary',
|
40
|
+
backgroundOpacity: 0.8,
|
41
|
+
textColorType: 'primary',
|
42
|
+
offset: [20, 5],
|
43
|
+
padding: 10,
|
44
|
+
renderFn: (eventData, { styles, utils }) => {
|
45
|
+
const hasCategoryLabel = eventData.categoryLabel === '' ? false : true
|
46
|
+
const hasDatumLabel = eventData.datum == null || eventData.datum.label.slice(0, 11) === 'multiValue_' ? false : true
|
47
|
+
const bulletWidth = styles.textSizePx * 0.7
|
48
|
+
const offset = (styles.textSizePx / 2) - (bulletWidth / 2)
|
49
|
+
const categorySvg = hasCategoryLabel
|
50
|
+
? `<rect width="${bulletWidth}" height="${bulletWidth}" x="${offset}" y="${offset - 1}" rx="${bulletWidth / 2}" fill="${eventData.datum.color}"></rect>
|
51
|
+
<text x="${styles.textSizePx * 1.5}" font-size="${styles.textSizePx}" dominant-baseline="hanging" fill="${styles.textColor}">
|
52
|
+
<tspan>${eventData.categoryLabel}</tspan>
|
53
|
+
</text>`
|
54
|
+
: ''
|
55
|
+
|
56
|
+
const datumLabelSvg = hasDatumLabel
|
57
|
+
? `<text font-size="${styles.textSizePx}" dominant-baseline="hanging" fill="${styles.textColor}">
|
58
|
+
<tspan>${eventData.datum.label}</tspan>
|
59
|
+
</text>`
|
60
|
+
: ''
|
61
|
+
|
62
|
+
const maxTextWidth = (() => {
|
63
|
+
const categoryLabelTextWidth = utils.measureTextWidth(eventData.categoryLabel, styles.textSizePx)
|
64
|
+
const datumLabelTextWidth = hasDatumLabel ? utils.measureTextWidth(eventData.datum.label, styles.textSizePx) : 0
|
65
|
+
const valueDetailTextWidth = eventData.valueDetail.reduce((acc, detail) => {
|
66
|
+
const text = `${detail.valueLabel}${utils.toCurrency(detail.value)}`
|
67
|
+
const _maxTextWidth = utils.measureTextWidth(text, styles.textSizePx)
|
68
|
+
return _maxTextWidth > acc ? _maxTextWidth : acc
|
69
|
+
}, 0)
|
70
|
+
return Math.max(categoryLabelTextWidth, datumLabelTextWidth, valueDetailTextWidth)
|
71
|
+
})()
|
72
|
+
|
73
|
+
const valueDetailSvg = eventData.valueDetail.map((detail, i) => {
|
74
|
+
const y = (i * styles.textSizePx * 1.5) + (datumLabelSvg ? styles.textSizePx * 2 : 0)
|
75
|
+
const lineEndX = maxTextWidth + styles.textSizePx * 3
|
76
|
+
return `<text x="0" y="${y}" font-weight="bold" font-size="${styles.textSizePx}" dominant-baseline="hanging" fill="${styles.textColor}">
|
77
|
+
<tspan>${detail.valueLabel}</tspan>
|
78
|
+
<tspan text-anchor="end" x="${lineEndX}">${utils.toCurrency(detail.value)}</tspan>
|
79
|
+
</text>`
|
80
|
+
}).join('')
|
81
|
+
|
82
|
+
const datumDetailSvg = datumLabelSvg || valueDetailSvg
|
83
|
+
? `<g ${hasCategoryLabel ? `transform="translate(0, ${styles.textSizePx * 2})"` : ''}>
|
84
|
+
${datumLabelSvg}
|
85
|
+
${valueDetailSvg}
|
86
|
+
</g>`
|
87
|
+
: ''
|
88
|
+
|
89
|
+
return `${categorySvg}
|
90
|
+
${datumDetailSvg}`
|
91
|
+
},
|
92
|
+
}
|
93
|
+
DEFAULT_MULTI_VALUE_TOOLTIP_PARAMS.renderFn.toString = () => `(eventData, { styles, utils }) => {
|
94
|
+
const hasCategoryLabel = eventData.categoryLabel === '' ? false : true
|
95
|
+
const hasDatumLabel = eventData.datum == null || eventData.datum.label.slice(0, 11) === 'multiValue_' ? false : true
|
96
|
+
const bulletWidth = styles.textSizePx * 0.7
|
97
|
+
const offset = (styles.textSizePx / 2) - (bulletWidth / 2)
|
98
|
+
const categorySvg = hasCategoryLabel
|
99
|
+
? \`<rect width="\${bulletWidth}" height="\${bulletWidth}" x="\${offset}" y="\${offset - 1}" rx="\${bulletWidth / 2}" fill="\${eventData.datum.color}"></rect>
|
100
|
+
<text x="\${styles.textSizePx * 1.5}" font-size="\${styles.textSizePx}" dominant-baseline="hanging" fill="\${styles.textColor}">
|
101
|
+
<tspan>\${eventData.categoryLabel}</tspan>
|
102
|
+
</text>\`
|
103
|
+
: ''
|
104
|
+
|
105
|
+
const datumLabelSvg = hasDatumLabel
|
106
|
+
? \`<text font-size="\${styles.textSizePx}" dominant-baseline="hanging" fill="\${styles.textColor}">
|
107
|
+
<tspan>\${eventData.datum.label}</tspan>
|
108
|
+
</text>\`
|
109
|
+
: ''
|
110
|
+
|
111
|
+
const maxTextWidth = (() => {
|
112
|
+
const categoryLabelTextWidth = utils.measureTextWidth(eventData.categoryLabel, styles.textSizePx)
|
113
|
+
const datumLabelTextWidth = hasDatumLabel ? utils.measureTextWidth(eventData.datum.label, styles.textSizePx) : 0
|
114
|
+
const valueDetailTextWidth = eventData.valueDetail.reduce((acc, detail) => {
|
115
|
+
const text = \`\${detail.valueLabel}\${utils.toCurrency(detail.value)}\`
|
116
|
+
const _maxTextWidth = utils.measureTextWidth(text, styles.textSizePx)
|
117
|
+
return _maxTextWidth > acc ? _maxTextWidth : acc
|
118
|
+
}, 0)
|
119
|
+
return Math.max(categoryLabelTextWidth, datumLabelTextWidth, valueDetailTextWidth)
|
120
|
+
})()
|
121
|
+
|
122
|
+
const valueDetailSvg = eventData.valueDetail.map((detail, i) => {
|
123
|
+
const y = (i * styles.textSizePx * 1.5) + (datumLabelSvg ? styles.textSizePx * 2 : 0)
|
124
|
+
const lineEndX = maxTextWidth + styles.textSizePx * 3
|
125
|
+
return \`<text x="0" y="\${y}" font-weight="bold" font-size="\${styles.textSizePx}" dominant-baseline="hanging" fill="\${styles.textColor}">
|
126
|
+
<tspan>\${detail.valueLabel}</tspan>
|
127
|
+
<tspan text-anchor="end" x="\${lineEndX}">\${utils.toCurrency(detail.value)}</tspan>
|
128
|
+
</text>\`
|
129
|
+
}).join('')
|
130
|
+
|
131
|
+
const datumDetailSvg = datumLabelSvg || valueDetailSvg
|
132
|
+
? \`<g \${hasCategoryLabel ? \`transform="translate(0, \${styles.textSizePx * 2})"\` : ''}>
|
133
|
+
\${datumLabelSvg}
|
134
|
+
\${valueDetailSvg}
|
135
|
+
</g>\`
|
136
|
+
: ''
|
137
|
+
|
138
|
+
return \`\${categorySvg}
|
139
|
+
\${datumDetailSvg}\`
|
140
|
+
}`
|
141
|
+
|
142
|
+
export const DEFAULT_ORDINAL_BUBBLES_PARAMS: OrdinalBubblesParams = {
|
143
|
+
bubble: {
|
144
|
+
sizeAdjust: 1,
|
145
|
+
arcScaleType: 'area',
|
146
|
+
valueLinearOpacity: [0.8, 0.8]
|
147
|
+
|
148
|
+
},
|
149
|
+
itemLabel: {
|
150
|
+
padding: 20,
|
151
|
+
colorType: 'primary'
|
152
|
+
},
|
153
|
+
axisLabel: {
|
154
|
+
offset: [0, 0],
|
155
|
+
colorType: 'primary'
|
156
|
+
},
|
157
|
+
rankingAmount: 10
|
158
|
+
}
|
159
|
+
|
160
|
+
export const DEFAULT_ORDINAL_AUX_PARAMS: OrdinalAuxParams = {
|
161
|
+
showLine: true,
|
162
|
+
showLabel: true,
|
163
|
+
lineDashArray: '3, 3',
|
164
|
+
lineColorType: 'primary',
|
165
|
+
labelColorType: 'primary',
|
166
|
+
labelTextColorType: 'background',
|
167
|
+
// labelTextFormat: text => text,
|
168
|
+
// labelTextFormat: (value: number) => String(Math.round(value)),
|
169
|
+
labelTextFormat: v => v,
|
170
|
+
labelPadding: 20,
|
171
|
+
// labelRotate: 0
|
172
|
+
}
|
173
|
+
DEFAULT_ORDINAL_AUX_PARAMS.labelTextFormat.toString = () => `v => v`
|
174
|
+
|
175
|
+
export const DEFAULT_ORDINAL_AXIS_PARAMS: OrdinalAxisParams = {
|
176
|
+
labelOffset: [0, 0],
|
177
|
+
labelColorType: 'primary',
|
178
|
+
axisLineVisible: false,
|
179
|
+
axisLineColorType: 'secondary',
|
180
|
+
ticks: 4,
|
181
|
+
// ticks: 'all',
|
182
|
+
// tickFormat: ',.0f',
|
183
|
+
tickFormat: v => v,
|
184
|
+
tickLineVisible: true,
|
185
|
+
tickPadding: 20,
|
186
|
+
tickFullLine: true,
|
187
|
+
tickFullLineDasharray: 'none',
|
188
|
+
tickColorType: 'secondary',
|
189
|
+
tickTextRotate: 0,
|
190
|
+
tickTextColorType: 'primary'
|
191
|
+
}
|
192
|
+
DEFAULT_ORDINAL_AXIS_PARAMS.tickFormat.toString = () => `v => v`
|
193
|
+
|
194
|
+
export const DEFAULT_ORDINAL_ZOOM_PARAMS: OrdinalZoomParams = {
|
195
|
+
|
196
|
+
}
|
197
|
+
|
198
|
+
export const DEFAULT_RACING_BARS_PARAMS: RacingBarsParams = {
|
199
|
+
bar: {
|
200
|
+
barWidth: 0,
|
201
|
+
barPadding: 8,
|
202
|
+
barRadius: false,
|
203
|
+
},
|
204
|
+
barLabel: {
|
205
|
+
position: 'inside',
|
206
|
+
padding: 20,
|
207
|
+
// rotate: 0,
|
208
|
+
colorType: 'labelContrast'
|
209
|
+
},
|
210
|
+
valueLabel: {
|
211
|
+
padding: 20,
|
212
|
+
colorType: 'primary',
|
213
|
+
// format: num => {
|
214
|
+
// if (num === null || Number.isNaN(num) == true) {
|
215
|
+
// return num || 0
|
216
|
+
// }
|
217
|
+
// const parts = num.toString().split('.')
|
218
|
+
// parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ',')
|
219
|
+
// return parts.join('.')
|
220
|
+
// }
|
221
|
+
format: v => v
|
222
|
+
},
|
223
|
+
axisLabel: {
|
224
|
+
offset: [0, 0],
|
225
|
+
colorType: 'primary'
|
226
|
+
},
|
227
|
+
// rankingAmount: 'auto'
|
228
|
+
rankingAmount: 10,
|
229
|
+
autorun: false,
|
230
|
+
loop: false
|
231
|
+
}
|
232
|
+
// DEFAULT_RACING_BARS_PARAMS.valueLabel.format.toString = () => `num => {
|
233
|
+
// if (num === null || Number.isNaN(num) == true) {
|
234
|
+
// return num || 0
|
235
|
+
// }
|
236
|
+
// const parts = num.toString().split('.')
|
237
|
+
// parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ',')
|
238
|
+
// return parts.join('.')
|
239
|
+
// }
|
240
|
+
// }`
|
241
|
+
DEFAULT_RACING_BARS_PARAMS.valueLabel.format.toString = () => `v => v`
|
242
|
+
|
243
|
+
export const DEFAULT_RACING_COUNTER_TEXTS_PARAMS: RacingCounterTextsParams = {
|
244
|
+
renderFn: (valueLabel: string, valueIndex: number, data: ComputedDataTypeMap<'multiValue'>) => {
|
245
|
+
return valueLabel
|
246
|
+
},
|
247
|
+
textAttrs: [
|
248
|
+
{
|
249
|
+
"transform": "translate(0, 0)"
|
250
|
+
}
|
251
|
+
],
|
252
|
+
textStyles: [
|
253
|
+
{
|
254
|
+
"font-weight": "bold",
|
255
|
+
"text-anchor": "end",
|
256
|
+
"pointer-events": "none",
|
257
|
+
"dominant-baseline": "auto",
|
258
|
+
"font-size": 64,
|
259
|
+
"fill": "#bebebe"
|
260
|
+
},
|
261
|
+
{
|
262
|
+
"text-anchor": "end",
|
263
|
+
"pointer-events": "none",
|
264
|
+
"dominant-baseline": "auto",
|
265
|
+
"font-size": 24,
|
266
|
+
"fill": "#bebebe"
|
267
|
+
},
|
268
|
+
],
|
269
|
+
paddingRight: 0,
|
270
|
+
paddingBottom: 0
|
271
|
+
}
|
272
|
+
DEFAULT_RACING_COUNTER_TEXTS_PARAMS.renderFn.toString = () => `(valueLabel, valueIndex, data) => {
|
273
|
+
return valueLabel
|
274
|
+
}`
|
275
|
+
|
276
|
+
export const DEFAULT_RACING_VALUE_AXIS_PARAMS: RacingValueAxisParams = {
|
277
|
+
labelOffset: [0, 0],
|
278
|
+
labelColorType: 'primary',
|
279
|
+
axisLineVisible: false,
|
280
|
+
axisLineColorType: 'secondary',
|
281
|
+
ticks: null,
|
282
|
+
// tickFormat: ',.0f',
|
283
|
+
// tickFormat: v => v,
|
284
|
+
tickFormat: num => {
|
285
|
+
if (num === null || Number.isNaN(num) == true) {
|
286
|
+
return num || 0
|
287
|
+
}
|
288
|
+
const parts = num.toString().split('.')
|
289
|
+
parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ',')
|
290
|
+
return parts.join('.')
|
291
|
+
},
|
292
|
+
tickLineVisible: true,
|
293
|
+
tickPadding: 20,
|
294
|
+
tickFullLine: true,
|
295
|
+
tickFullLineDasharray: 'none',
|
296
|
+
tickColorType: 'secondary',
|
297
|
+
tickTextColorType: 'primary'
|
298
|
+
}
|
299
|
+
DEFAULT_RACING_VALUE_AXIS_PARAMS.tickFormat.toString = () => `num => {
|
300
|
+
if (num === null || Number.isNaN(num) == true) {
|
301
|
+
return num || 0
|
302
|
+
}
|
303
|
+
const parts = num.toString().split('.')
|
304
|
+
parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ',')
|
305
|
+
return parts.join('.')
|
306
|
+
}`
|
307
|
+
|
308
|
+
export const DEFAULT_SCATTER_PARAMS: ScatterParams = {
|
309
|
+
radius: 5,
|
310
|
+
fillColorType: 'label',
|
311
|
+
strokeColorType: 'label',
|
312
|
+
strokeWidth: 0,
|
313
|
+
}
|
314
|
+
|
315
|
+
export const DEFAULT_SCATTER_BUBBLES_PARAMS: ScatterBubblesParams = {
|
316
|
+
// radius: 5,
|
317
|
+
fillColorType: 'label',
|
318
|
+
strokeColorType: 'label',
|
319
|
+
strokeWidth: 0,
|
320
|
+
valueLinearOpacity: [0.8, 0.8],
|
321
|
+
arcScaleType: 'area',
|
322
|
+
sizeAdjust: 0.5
|
323
|
+
}
|
324
|
+
|
325
|
+
export const DEFAULT_X_AXIS_PARAMS: XAxisParams = {
|
326
|
+
labelOffset: [0, 0],
|
327
|
+
labelColorType: 'primary',
|
328
|
+
axisLineVisible: false,
|
329
|
+
axisLineColorType: 'secondary',
|
330
|
+
ticks: null,
|
331
|
+
// tickFormat: ',.0f',
|
332
|
+
// tickFormat: v => v,
|
333
|
+
tickFormat: num => {
|
334
|
+
if (num === null || Number.isNaN(num) == true) {
|
335
|
+
return num || 0
|
336
|
+
}
|
337
|
+
const parts = num.toString().split('.')
|
338
|
+
parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ',')
|
339
|
+
return parts.join('.')
|
340
|
+
},
|
341
|
+
tickLineVisible: true,
|
342
|
+
tickPadding: 20,
|
343
|
+
tickFullLine: true,
|
344
|
+
tickFullLineDasharray: 'none',
|
345
|
+
tickColorType: 'secondary',
|
346
|
+
tickTextColorType: 'primary'
|
347
|
+
}
|
348
|
+
DEFAULT_X_AXIS_PARAMS.tickFormat.toString = () => `num => {
|
349
|
+
if (num === null || Number.isNaN(num) == true) {
|
350
|
+
return num || 0
|
351
|
+
}
|
352
|
+
const parts = num.toString().split('.')
|
353
|
+
parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ',')
|
354
|
+
return parts.join('.')
|
355
|
+
}`
|
356
|
+
|
357
|
+
export const DEFAULT_X_Y_AUX_PARAMS: XYAuxParams = {
|
358
|
+
xAxis: {
|
359
|
+
showLine: true,
|
360
|
+
showLabel: true,
|
361
|
+
lineDashArray: '3, 3',
|
362
|
+
lineColorType: 'primary',
|
363
|
+
labelColorType: 'primary',
|
364
|
+
labelTextColorType: 'background',
|
365
|
+
// labelTextFormat: text => text,
|
366
|
+
// labelTextFormat: (value: number) => String(Math.round(value)),
|
367
|
+
labelTextFormat: num => {
|
368
|
+
if (num === null || Number.isNaN(num) == true) {
|
369
|
+
return num || 0
|
370
|
+
}
|
371
|
+
const absNum = Math.abs(num)
|
372
|
+
if (absNum > 0 && absNum < 1) {
|
373
|
+
const strNum = num.toString()
|
374
|
+
const match = strNum.match(/0\.(0*)([1-9])/)
|
375
|
+
if (match) {
|
376
|
+
const precision = match[1].length + 1
|
377
|
+
return num.toFixed(precision)
|
378
|
+
}
|
379
|
+
return num.toString()
|
380
|
+
}
|
381
|
+
const parts = num.toString().split('.')
|
382
|
+
parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ',')
|
383
|
+
return parts[0]
|
384
|
+
},
|
385
|
+
labelPadding: 20,
|
386
|
+
// labelRotate: 0
|
387
|
+
},
|
388
|
+
yAxis: {
|
389
|
+
showLine: true,
|
390
|
+
showLabel: true,
|
391
|
+
lineDashArray: '3, 3',
|
392
|
+
lineColorType: 'primary',
|
393
|
+
labelColorType: 'primary',
|
394
|
+
labelTextColorType: 'background',
|
395
|
+
// labelTextFormat: text => text,
|
396
|
+
// labelTextFormat: (value: number) => String(Math.round(value)),
|
397
|
+
labelTextFormat: num => {
|
398
|
+
if (num === null || Number.isNaN(num) == true) {
|
399
|
+
return num || 0
|
400
|
+
}
|
401
|
+
const absNum = Math.abs(num)
|
402
|
+
if (absNum > 0 && absNum < 1) {
|
403
|
+
const strNum = num.toString()
|
404
|
+
const match = strNum.match(/0\.(0*)([1-9])/)
|
405
|
+
if (match) {
|
406
|
+
const precision = match[1].length + 1
|
407
|
+
return num.toFixed(precision)
|
408
|
+
}
|
409
|
+
return num.toString()
|
410
|
+
}
|
411
|
+
const parts = num.toString().split('.')
|
412
|
+
parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ',')
|
413
|
+
return parts[0]
|
414
|
+
},
|
415
|
+
labelPadding: 20,
|
416
|
+
// labelRotate: 0
|
417
|
+
}
|
418
|
+
}
|
419
|
+
DEFAULT_X_Y_AUX_PARAMS.xAxis.labelTextFormat.toString = () => `num => {
|
420
|
+
if (num === null || Number.isNaN(num) == true) {
|
421
|
+
return num || 0
|
422
|
+
}
|
423
|
+
const absNum = Math.abs(num)
|
424
|
+
if (absNum > 0 && absNum < 1) {
|
425
|
+
const strNum = num.toString()
|
426
|
+
const match = strNum.match(/0\.(0*)([1-9])/)
|
427
|
+
if (match) {
|
428
|
+
const precision = match[1].length + 1
|
429
|
+
return num.toFixed(precision)
|
430
|
+
}
|
431
|
+
return num.toString()
|
432
|
+
}
|
433
|
+
const parts = num.toString().split('.')
|
434
|
+
parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ',')
|
435
|
+
return parts[0]
|
436
|
+
}`
|
437
|
+
DEFAULT_X_Y_AUX_PARAMS.yAxis.labelTextFormat.toString = () => `num => {
|
438
|
+
if (num === null || Number.isNaN(num) == true) {
|
439
|
+
return num || 0
|
440
|
+
}
|
441
|
+
const absNum = Math.abs(num)
|
442
|
+
if (absNum > 0 && absNum < 1) {
|
443
|
+
const strNum = num.toString()
|
444
|
+
const match = strNum.match(/0\.(0*)([1-9])/)
|
445
|
+
if (match) {
|
446
|
+
const precision = match[1].length + 1
|
447
|
+
return num.toFixed(precision)
|
448
|
+
}
|
449
|
+
return num.toString()
|
450
|
+
}
|
451
|
+
const parts = num.toString().split('.')
|
452
|
+
parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ',')
|
453
|
+
return parts[0]
|
454
|
+
}`
|
455
|
+
|
456
|
+
|
457
|
+
export const DEFAULT_X_Y_AXES_PARAMS: XYAxesParams = {
|
458
|
+
xAxis: {
|
459
|
+
labelOffset: [0, 0],
|
460
|
+
labelColorType: 'primary',
|
461
|
+
axisLineVisible: false,
|
462
|
+
axisLineColorType: 'primary',
|
463
|
+
ticks: null,
|
464
|
+
// tickFormat: ',.0f',
|
465
|
+
// tickFormat: v => v,
|
466
|
+
tickFormat: num => {
|
467
|
+
if (num === null || Number.isNaN(num) == true) {
|
468
|
+
return num || 0
|
469
|
+
}
|
470
|
+
const parts = num.toString().split('.')
|
471
|
+
parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ',')
|
472
|
+
return parts.join('.')
|
473
|
+
},
|
474
|
+
tickLineVisible: true,
|
475
|
+
tickPadding: 20,
|
476
|
+
tickFullLine: true,
|
477
|
+
tickFullLineDasharray: 'none',
|
478
|
+
tickColorType: 'secondary',
|
479
|
+
tickTextColorType: 'primary'
|
480
|
+
},
|
481
|
+
yAxis: {
|
482
|
+
labelOffset: [0, 0],
|
483
|
+
labelColorType: 'primary',
|
484
|
+
axisLineVisible: false,
|
485
|
+
axisLineColorType: 'primary',
|
486
|
+
ticks: null,
|
487
|
+
// tickFormat: ',.0f',
|
488
|
+
// tickFormat: v => v,
|
489
|
+
tickFormat: num => {
|
490
|
+
if (num === null || Number.isNaN(num) == true) {
|
491
|
+
return num || 0
|
492
|
+
}
|
493
|
+
const parts = num.toString().split('.')
|
494
|
+
parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ',')
|
495
|
+
return parts.join('.')
|
496
|
+
},
|
497
|
+
tickLineVisible: true,
|
498
|
+
tickPadding: 20,
|
499
|
+
tickFullLine: true,
|
500
|
+
tickFullLineDasharray: 'none',
|
501
|
+
tickColorType: 'secondary',
|
502
|
+
tickTextColorType: 'primary'
|
503
|
+
}
|
504
|
+
}
|
505
|
+
DEFAULT_X_Y_AXES_PARAMS.xAxis.tickFormat.toString = () => `num => {
|
506
|
+
if (num === null || Number.isNaN(num) == true) {
|
507
|
+
return num || 0
|
508
|
+
}
|
509
|
+
const parts = num.toString().split('.')
|
510
|
+
parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ',')
|
511
|
+
return parts.join('.')
|
512
|
+
}`
|
513
|
+
DEFAULT_X_Y_AXES_PARAMS.yAxis.tickFormat.toString = () => `num => {
|
514
|
+
if (num === null || Number.isNaN(num) == true) {
|
515
|
+
return num || 0
|
516
|
+
}
|
517
|
+
const parts = num.toString().split('.')
|
518
|
+
parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ',')
|
519
|
+
return parts.join('.')
|
520
|
+
}`
|
521
|
+
|
522
|
+
export const DEFAULT_X_ZOOM_PARAMS: XZoomParams = {
|
523
|
+
|
432
524
|
}
|