@orbcharts/plugins-basic 3.0.8 → 3.0.10

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.
Files changed (120) hide show
  1. package/LICENSE +200 -200
  2. package/dist/orbcharts-plugins-basic.es.js +6182 -6004
  3. package/dist/orbcharts-plugins-basic.umd.js +44 -44
  4. package/dist/src/series/defaults.d.ts +2 -1
  5. package/dist/src/series/index.d.ts +1 -0
  6. package/dist/src/series/plugins/Indicator.d.ts +3 -0
  7. package/lib/core-types.ts +7 -7
  8. package/lib/core.ts +6 -6
  9. package/lib/gridObservables.ts +6 -6
  10. package/lib/plugins-basic-types.ts +6 -6
  11. package/package.json +48 -48
  12. package/src/base/BaseBars.ts +765 -765
  13. package/src/base/BaseBarsTriangle.ts +676 -676
  14. package/src/base/BaseDots.ts +464 -464
  15. package/src/base/BaseGroupAxis.ts +691 -691
  16. package/src/base/BaseLegend.ts +684 -684
  17. package/src/base/BaseLineAreas.ts +629 -629
  18. package/src/base/BaseLines.ts +706 -706
  19. package/src/base/BaseOrdinalBubbles.ts +729 -729
  20. package/src/base/BaseRacingBars.ts +582 -582
  21. package/src/base/BaseRacingLabels.ts +404 -404
  22. package/src/base/BaseRacingValueLabels.ts +403 -403
  23. package/src/base/BaseStackedBars.ts +793 -793
  24. package/src/base/BaseTooltip.ts +408 -408
  25. package/src/base/BaseValueAxis.ts +600 -600
  26. package/src/base/BaseXAxis.ts +427 -427
  27. package/src/base/BaseXZoom.ts +241 -241
  28. package/src/base/BaseYAxis.ts +389 -389
  29. package/src/base/types.ts +2 -2
  30. package/src/const.ts +30 -30
  31. package/src/grid/defaults.ts +213 -213
  32. package/src/grid/gridObservables.ts +635 -635
  33. package/src/grid/index.ts +16 -16
  34. package/src/grid/plugins/Bars.ts +69 -69
  35. package/src/grid/plugins/BarsPN.ts +66 -66
  36. package/src/grid/plugins/BarsTriangle.ts +73 -73
  37. package/src/grid/plugins/Dots.ts +68 -68
  38. package/src/grid/plugins/GridLegend.ts +107 -107
  39. package/src/grid/plugins/GridTooltip.ts +66 -66
  40. package/src/grid/plugins/GroupAux.ts +1095 -1095
  41. package/src/grid/plugins/GroupAxis.ts +73 -73
  42. package/src/grid/plugins/GroupZoom.ts +218 -218
  43. package/src/grid/plugins/LineAreas.ts +65 -65
  44. package/src/grid/plugins/Lines.ts +59 -59
  45. package/src/grid/plugins/StackedBars.ts +66 -66
  46. package/src/grid/plugins/StackedValueAxis.ts +97 -97
  47. package/src/grid/plugins/ValueAxis.ts +94 -94
  48. package/src/index.ts +6 -6
  49. package/src/multiGrid/defaults.ts +244 -244
  50. package/src/multiGrid/index.ts +14 -14
  51. package/src/multiGrid/multiGridObservables.ts +50 -50
  52. package/src/multiGrid/plugins/MultiBars.ts +108 -108
  53. package/src/multiGrid/plugins/MultiBarsTriangle.ts +114 -114
  54. package/src/multiGrid/plugins/MultiDots.ts +102 -102
  55. package/src/multiGrid/plugins/MultiGridLegend.ts +169 -169
  56. package/src/multiGrid/plugins/MultiGridTooltip.ts +66 -66
  57. package/src/multiGrid/plugins/MultiGroupAxis.ts +137 -137
  58. package/src/multiGrid/plugins/MultiLineAreas.ts +107 -107
  59. package/src/multiGrid/plugins/MultiLines.ts +101 -101
  60. package/src/multiGrid/plugins/MultiStackedBars.ts +109 -109
  61. package/src/multiGrid/plugins/MultiStackedValueAxis.ts +135 -135
  62. package/src/multiGrid/plugins/MultiValueAxis.ts +134 -134
  63. package/src/multiGrid/plugins/OverlappingStackedValueAxes.ts +300 -300
  64. package/src/multiGrid/plugins/OverlappingValueAxes.ts +300 -300
  65. package/src/multiValue/defaults.ts +523 -523
  66. package/src/multiValue/index.ts +16 -16
  67. package/src/multiValue/multiValueObservables.ts +781 -781
  68. package/src/multiValue/plugins/MultiValueLegend.ts +107 -107
  69. package/src/multiValue/plugins/MultiValueTooltip.ts +66 -66
  70. package/src/multiValue/plugins/OrdinalAux.ts +660 -660
  71. package/src/multiValue/plugins/OrdinalAxis.ts +524 -524
  72. package/src/multiValue/plugins/OrdinalBubbles.ts +226 -226
  73. package/src/multiValue/plugins/OrdinalZoom.ts +57 -57
  74. package/src/multiValue/plugins/RacingBars.ts +375 -375
  75. package/src/multiValue/plugins/RacingCounterTexts.ts +300 -300
  76. package/src/multiValue/plugins/RacingValueAxis.ts +114 -114
  77. package/src/multiValue/plugins/Scatter.ts +486 -486
  78. package/src/multiValue/plugins/ScatterBubbles.ts +635 -635
  79. package/src/multiValue/plugins/XAxis.ts +107 -107
  80. package/src/multiValue/plugins/XYAux.ts +683 -683
  81. package/src/multiValue/plugins/XYAxes.ts +194 -194
  82. package/src/multiValue/plugins/XYAxes_legacy.ts +683 -683
  83. package/src/multiValue/plugins/XZoom.ts +40 -40
  84. package/src/noneData/defaults.ts +102 -102
  85. package/src/noneData/index.ts +3 -3
  86. package/src/noneData/plugins/Container.ts +27 -27
  87. package/src/noneData/plugins/Tooltip.ts +373 -373
  88. package/src/relationship/defaults.ts +221 -221
  89. package/src/relationship/index.ts +5 -5
  90. package/src/relationship/plugins/ForceDirected.ts +1056 -1056
  91. package/src/relationship/plugins/ForceDirectedBubbles.ts +1294 -1294
  92. package/src/relationship/plugins/RelationshipLegend.ts +100 -100
  93. package/src/relationship/plugins/RelationshipTooltip.ts +66 -66
  94. package/src/relationship/relationshipObservables.ts +49 -49
  95. package/src/series/defaults.ts +236 -224
  96. package/src/series/index.ts +10 -9
  97. package/src/series/plugins/Bubbles.ts +784 -784
  98. package/src/series/plugins/Indicator.ts +298 -0
  99. package/src/series/plugins/Pie.ts +622 -622
  100. package/src/series/plugins/PieEventTexts.ts +283 -283
  101. package/src/series/plugins/PieLabels.ts +639 -639
  102. package/src/series/plugins/Rose.ts +515 -515
  103. package/src/series/plugins/RoseLabels.ts +599 -599
  104. package/src/series/plugins/SeriesLegend.ts +107 -107
  105. package/src/series/plugins/SeriesTooltip.ts +66 -66
  106. package/src/series/seriesObservables.ts +168 -168
  107. package/src/series/seriesUtils.ts +51 -51
  108. package/src/tree/defaults.ts +102 -102
  109. package/src/tree/index.ts +4 -4
  110. package/src/tree/plugins/TreeLegend.ts +100 -100
  111. package/src/tree/plugins/TreeMap.ts +341 -341
  112. package/src/tree/plugins/TreeTooltip.ts +66 -66
  113. package/src/utils/commonUtils.ts +31 -31
  114. package/src/utils/d3Graphics.ts +176 -176
  115. package/src/utils/d3Utils.ts +92 -92
  116. package/src/utils/observables.ts +14 -14
  117. package/src/utils/orbchartsUtils.ts +129 -129
  118. package/tsconfig.base.json +13 -13
  119. package/tsconfig.json +2 -2
  120. package/vite.config.js +22 -22
@@ -1,524 +1,524 @@
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
-
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
+
524
524
  }