@orbcharts/plugins-basic 3.0.6 → 3.0.8

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 (117) hide show
  1. package/LICENSE +200 -200
  2. package/dist/orbcharts-plugins-basic.es.js +3830 -3806
  3. package/dist/orbcharts-plugins-basic.umd.js +33 -33
  4. package/dist/src/base/BaseStackedBars.d.ts +2 -0
  5. package/lib/core-types.ts +7 -7
  6. package/lib/core.ts +6 -6
  7. package/lib/gridObservables.ts +6 -6
  8. package/lib/plugins-basic-types.ts +6 -6
  9. package/package.json +48 -48
  10. package/src/base/BaseBars.ts +765 -765
  11. package/src/base/BaseBarsTriangle.ts +676 -676
  12. package/src/base/BaseDots.ts +464 -464
  13. package/src/base/BaseGroupAxis.ts +691 -691
  14. package/src/base/BaseLegend.ts +684 -684
  15. package/src/base/BaseLineAreas.ts +629 -629
  16. package/src/base/BaseLines.ts +706 -706
  17. package/src/base/BaseOrdinalBubbles.ts +729 -729
  18. package/src/base/BaseRacingBars.ts +582 -582
  19. package/src/base/BaseRacingLabels.ts +404 -404
  20. package/src/base/BaseRacingValueLabels.ts +403 -403
  21. package/src/base/BaseStackedBars.ts +793 -782
  22. package/src/base/BaseTooltip.ts +408 -386
  23. package/src/base/BaseValueAxis.ts +600 -600
  24. package/src/base/BaseXAxis.ts +427 -427
  25. package/src/base/BaseXZoom.ts +241 -241
  26. package/src/base/BaseYAxis.ts +389 -389
  27. package/src/base/types.ts +2 -2
  28. package/src/const.ts +30 -30
  29. package/src/grid/defaults.ts +213 -213
  30. package/src/grid/gridObservables.ts +635 -635
  31. package/src/grid/index.ts +16 -16
  32. package/src/grid/plugins/Bars.ts +69 -69
  33. package/src/grid/plugins/BarsPN.ts +66 -66
  34. package/src/grid/plugins/BarsTriangle.ts +73 -73
  35. package/src/grid/plugins/Dots.ts +68 -68
  36. package/src/grid/plugins/GridLegend.ts +107 -107
  37. package/src/grid/plugins/GridTooltip.ts +66 -66
  38. package/src/grid/plugins/GroupAux.ts +1095 -1095
  39. package/src/grid/plugins/GroupAxis.ts +73 -73
  40. package/src/grid/plugins/GroupZoom.ts +218 -218
  41. package/src/grid/plugins/LineAreas.ts +65 -65
  42. package/src/grid/plugins/Lines.ts +59 -59
  43. package/src/grid/plugins/StackedBars.ts +66 -64
  44. package/src/grid/plugins/StackedValueAxis.ts +97 -96
  45. package/src/grid/plugins/ValueAxis.ts +94 -94
  46. package/src/index.ts +6 -6
  47. package/src/multiGrid/defaults.ts +244 -244
  48. package/src/multiGrid/index.ts +14 -14
  49. package/src/multiGrid/multiGridObservables.ts +50 -50
  50. package/src/multiGrid/plugins/MultiBars.ts +108 -108
  51. package/src/multiGrid/plugins/MultiBarsTriangle.ts +114 -114
  52. package/src/multiGrid/plugins/MultiDots.ts +102 -102
  53. package/src/multiGrid/plugins/MultiGridLegend.ts +169 -169
  54. package/src/multiGrid/plugins/MultiGridTooltip.ts +66 -66
  55. package/src/multiGrid/plugins/MultiGroupAxis.ts +137 -137
  56. package/src/multiGrid/plugins/MultiLineAreas.ts +107 -107
  57. package/src/multiGrid/plugins/MultiLines.ts +101 -101
  58. package/src/multiGrid/plugins/MultiStackedBars.ts +109 -106
  59. package/src/multiGrid/plugins/MultiStackedValueAxis.ts +135 -134
  60. package/src/multiGrid/plugins/MultiValueAxis.ts +134 -134
  61. package/src/multiGrid/plugins/OverlappingStackedValueAxes.ts +300 -300
  62. package/src/multiGrid/plugins/OverlappingValueAxes.ts +300 -300
  63. package/src/multiValue/defaults.ts +523 -523
  64. package/src/multiValue/index.ts +16 -16
  65. package/src/multiValue/multiValueObservables.ts +781 -781
  66. package/src/multiValue/plugins/MultiValueLegend.ts +107 -107
  67. package/src/multiValue/plugins/MultiValueTooltip.ts +66 -66
  68. package/src/multiValue/plugins/OrdinalAux.ts +660 -660
  69. package/src/multiValue/plugins/OrdinalAxis.ts +524 -524
  70. package/src/multiValue/plugins/OrdinalBubbles.ts +226 -226
  71. package/src/multiValue/plugins/OrdinalZoom.ts +57 -57
  72. package/src/multiValue/plugins/RacingBars.ts +375 -375
  73. package/src/multiValue/plugins/RacingCounterTexts.ts +300 -300
  74. package/src/multiValue/plugins/RacingValueAxis.ts +114 -114
  75. package/src/multiValue/plugins/Scatter.ts +486 -486
  76. package/src/multiValue/plugins/ScatterBubbles.ts +635 -635
  77. package/src/multiValue/plugins/XAxis.ts +107 -107
  78. package/src/multiValue/plugins/XYAux.ts +683 -683
  79. package/src/multiValue/plugins/XYAxes.ts +194 -194
  80. package/src/multiValue/plugins/XYAxes_legacy.ts +683 -683
  81. package/src/multiValue/plugins/XZoom.ts +40 -40
  82. package/src/noneData/defaults.ts +102 -102
  83. package/src/noneData/index.ts +3 -3
  84. package/src/noneData/plugins/Container.ts +27 -27
  85. package/src/noneData/plugins/Tooltip.ts +373 -373
  86. package/src/relationship/defaults.ts +221 -221
  87. package/src/relationship/index.ts +5 -5
  88. package/src/relationship/plugins/ForceDirected.ts +1056 -1056
  89. package/src/relationship/plugins/ForceDirectedBubbles.ts +1294 -1294
  90. package/src/relationship/plugins/RelationshipLegend.ts +100 -100
  91. package/src/relationship/plugins/RelationshipTooltip.ts +66 -66
  92. package/src/relationship/relationshipObservables.ts +49 -49
  93. package/src/series/defaults.ts +223 -223
  94. package/src/series/index.ts +9 -9
  95. package/src/series/plugins/Bubbles.ts +784 -781
  96. package/src/series/plugins/Pie.ts +622 -622
  97. package/src/series/plugins/PieEventTexts.ts +283 -283
  98. package/src/series/plugins/PieLabels.ts +639 -639
  99. package/src/series/plugins/Rose.ts +515 -515
  100. package/src/series/plugins/RoseLabels.ts +599 -599
  101. package/src/series/plugins/SeriesLegend.ts +107 -107
  102. package/src/series/plugins/SeriesTooltip.ts +66 -66
  103. package/src/series/seriesObservables.ts +168 -168
  104. package/src/series/seriesUtils.ts +51 -51
  105. package/src/tree/defaults.ts +102 -102
  106. package/src/tree/index.ts +4 -4
  107. package/src/tree/plugins/TreeLegend.ts +100 -100
  108. package/src/tree/plugins/TreeMap.ts +341 -341
  109. package/src/tree/plugins/TreeTooltip.ts +66 -66
  110. package/src/utils/commonUtils.ts +31 -31
  111. package/src/utils/d3Graphics.ts +176 -176
  112. package/src/utils/d3Utils.ts +92 -92
  113. package/src/utils/observables.ts +14 -14
  114. package/src/utils/orbchartsUtils.ts +129 -129
  115. package/tsconfig.base.json +13 -13
  116. package/tsconfig.json +2 -2
  117. package/vite.config.js +22 -22
@@ -1,224 +1,224 @@
1
- import type { ComputedDatumSeries, EventSeries, EventName, ColorType } from '../../lib/core-types'
2
- import type {
3
- BubblesParams,
4
- PieParams,
5
- PieEventTextsParams,
6
- PieLabelsParams,
7
- RoseParams,
8
- RoseLabelsParams,
9
- SeriesLegendParams,
10
- SeriesTooltipParams
11
- } from '../../lib/plugins-basic-types'
12
-
13
-
14
- export const DEFAULT_BUBBLES_PARAMS: BubblesParams = {
15
- force: {
16
- strength: 0.08, // 泡泡引力
17
- velocityDecay: 0.3, // 衰減數
18
- collisionSpacing: 2 // 泡泡間距
19
- },
20
- bubbleLabel: {
21
- labelFn: d => String(d.label),
22
- colorType: 'labelContrast',
23
- fillRate: 0.6,
24
- lineHeight: 1,
25
- maxLineLength: 6,
26
- wordBreakAll: true,
27
- },
28
- // highlightRIncrease: 0,
29
- arcScaleType: 'area'
30
- }
31
- DEFAULT_BUBBLES_PARAMS.bubbleLabel.labelFn.toString = () => `d => String(d.label)`
32
-
33
- export const DEFAULT_PIE_PARAMS: PieParams = {
34
- outerRadius: 0.85,
35
- innerRadius: 0,
36
- outerRadiusWhileHighlight: 0.9,
37
- startAngle: 0,
38
- endAngle: Math.PI * 2,
39
- padAngle: 0,
40
- strokeColorType: 'background',
41
- strokeWidth: 1,
42
- // padRadius: 100,
43
- cornerRadius: 0,
44
- }
45
-
46
- export const DEFAULT_PIE_EVENT_TEXTS_PARAMS: PieEventTextsParams = {
47
- renderFn: (eventData: EventSeries) => {
48
- if (eventData.eventName === 'mouseover' || eventData.eventName === 'mousemove') {
49
- return [String(eventData.datum!.value)]
50
- }
51
- return [
52
- String(
53
- Math.round(
54
- eventData.data.reduce((acc, seriesData) => {
55
- return acc + seriesData.reduce((_acc, data) => {
56
- return _acc + (data.value ?? 0)
57
- }, 0)
58
- }, 0) * (eventData.tween ?? 1)
59
- )
60
- )
61
- ]
62
- },
63
- textAttrs: [
64
- {
65
- "transform": "translate(0, 0)"
66
- }
67
- ],
68
- textStyles: [
69
- {
70
- "font-weight": "bold",
71
- "text-anchor": "middle",
72
- "pointer-events": "none",
73
- "dominant-baseline": "middle",
74
- "font-size": 64,
75
- "fill": "#000"
76
- }
77
- ]
78
- }
79
- DEFAULT_PIE_EVENT_TEXTS_PARAMS.renderFn.toString = () => `(eventData) => {
80
- if (eventData.eventName === 'mouseover' || eventData.eventName === 'mousemove') {
81
- return [String(eventData.datum.value)]
82
- }
83
- return [
84
- String(
85
- Math.round(
86
- eventData.data.reduce((acc, seriesData) => {
87
- return acc + seriesData.reduce((_acc, data) => {
88
- return _acc + (data.value ?? 0)
89
- }, 0)
90
- }, 0) * (eventData.tween ?? 1)
91
- )
92
- )
93
- ]
94
- }`
95
-
96
- export const DEFAULT_PIE_LABELS_PARAMS: PieLabelsParams = {
97
- // solidColor: undefined,
98
- // colors: DEFAULT_COLORS,
99
- outerRadius: 0.85,
100
- outerRadiusWhileHighlight: 0.9,
101
- // innerRadius: 0,
102
- // enterDuration: 800,
103
- startAngle: 0,
104
- endAngle: Math.PI * 2,
105
- labelCentroid: 2.1,
106
- // fontSize: 12,
107
- labelColorType: 'primary',
108
- labelFn: d => String(d.label),
109
- }
110
- DEFAULT_PIE_LABELS_PARAMS.labelFn.toString = () => `d => String(d.label)`
111
-
112
- export const DEFAULT_ROSE_PARAMS: RoseParams = {
113
- outerRadius: 0.95,
114
- padAngle: 0,
115
- strokeColorType: 'background',
116
- strokeWidth: 0.5,
117
- cornerRadius: 0,
118
- arcScaleType: 'area',
119
- angleIncreaseWhileHighlight: 0.05
120
- }
121
-
122
- export const DEFAULT_ROSE_LABELS_PARAMS: RoseLabelsParams = {
123
- outerRadius: 0.95,
124
- labelCentroid: 2.1,
125
- labelFn: d => String(d.label),
126
- labelColorType: 'primary',
127
- arcScaleType: 'area'
128
- }
129
- DEFAULT_ROSE_LABELS_PARAMS.labelFn.toString = () => `d => String(d.label)`
130
-
131
- export const DEFAULT_SERIES_LEGEND_PARAMS: SeriesLegendParams = {
132
- // position: 'right',
133
- // justify: 'end',
134
- placement: 'right-end',
135
- padding: 28,
136
- // offset: [0, 0],
137
- backgroundFill: 'none',
138
- backgroundStroke: 'none',
139
- gap: 10,
140
- listRectWidth: 14,
141
- listRectHeight: 14,
142
- listRectRadius: 0,
143
- // highlightEvent: false
144
- textColorType: 'primary'
145
- }
146
-
147
- export const DEFAULT_SERIES_TOOLTIP_PARAMS: SeriesTooltipParams = {
148
- backgroundColorType: 'background',
149
- strokeColorType: 'primary',
150
- backgroundOpacity: 0.8,
151
- textColorType: 'primary',
152
- offset: [20, 5],
153
- padding: 10,
154
- renderFn: (eventData, { styles, utils }) => {
155
- const hasSeriesLabel = eventData.seriesLabel.slice(0, 7) === 'series_' ? false : true
156
- const hasDatumLabel = eventData.datum.label.slice(0, 7) === 'series_' ? false : true
157
- const valueText = utils.toCurrency(eventData.datum.value)
158
- const bulletWidth = styles.textSizePx * 0.7
159
- const offset = (styles.textSizePx / 2) - (bulletWidth / 2)
160
- const seriesSvg = hasSeriesLabel
161
- ? `<rect width="${bulletWidth}" height="${bulletWidth}" x="${offset}" y="${offset - 1}" rx="${bulletWidth / 2}" fill="${eventData.datum.color}"></rect>
162
- <text x="${styles.textSizePx * 1.5}" font-size="${styles.textSizePx}" dominant-baseline="hanging" fill="${styles.textColor}">
163
- <tspan>${eventData.seriesLabel}</tspan>
164
- </text>`
165
- : ''
166
- const datumLabelSvg = hasDatumLabel
167
- ? `<tspan>${eventData.datum.label}</tspan> `
168
- : ''
169
- const seriesLabelTextWidth = hasSeriesLabel
170
- ? utils.measureTextWidth(`${eventData.seriesLabel}${valueText}`, styles.textSizePx) + styles.textSizePx * 1.5
171
- : 0
172
- const datumLabelTextWidth = hasDatumLabel
173
- ? utils.measureTextWidth(`${eventData.datum.label}${valueText}`, styles.textSizePx)
174
- : 0
175
- const maxTextWidth = Math.max(seriesLabelTextWidth, datumLabelTextWidth)
176
- const lineEndX = hasDatumLabel
177
- ? maxTextWidth + styles.textSizePx * 1.5
178
- : 0
179
- const valueTextAnchor = hasDatumLabel ? 'end' : 'start'
180
- const datumSvg = `<text font-size="${styles.textSizePx}" dominant-baseline="hanging" fill="${styles.textColor}">
181
- ${datumLabelSvg}<tspan font-weight="bold" text-anchor="${valueTextAnchor}" x="${lineEndX}">${valueText}</tspan>
182
- </text>`
183
-
184
- return `${seriesSvg}
185
- <g ${hasSeriesLabel ? `transform="translate(0, ${styles.textSizePx * 2})"` : ''}>
186
- ${datumSvg}
187
- </g>`
188
- },
189
- }
190
- DEFAULT_SERIES_TOOLTIP_PARAMS.renderFn.toString = () => `(eventData, { styles, utils }) => {
191
- const hasSeriesLabel = eventData.seriesLabel.slice(0, 7) === 'series_' ? false : true
192
- const hasDatumLabel = eventData.datum.label.slice(0, 7) === 'series_' ? false : true
193
- const valueText = utils.toCurrency(eventData.datum.value)
194
- const bulletWidth = styles.textSizePx * 0.7
195
- const offset = (styles.textSizePx / 2) - (bulletWidth / 2)
196
- const seriesSvg = hasSeriesLabel
197
- ? \`<rect width="\${bulletWidth}" height="\${bulletWidth}" x="\${offset}" y="\${offset - 1}" rx="\${bulletWidth / 2}" fill="\${eventData.datum.color}"></rect>
198
- <text x="\${styles.textSizePx * 1.5}" font-size="\${styles.textSizePx}" dominant-baseline="hanging" fill="\${styles.textColor}">
199
- <tspan>\${eventData.seriesLabel}</tspan>
200
- </text>\`
201
- : ''
202
- const datumLabelSvg = hasDatumLabel
203
- ? \`<tspan>\${eventData.datum.label}</tspan> \`
204
- : ''
205
- const seriesLabelTextWidth = hasSeriesLabel
206
- ? utils.measureTextWidth(\`\${eventData.seriesLabel}\${valueText}\`, styles.textSizePx) + styles.textSizePx * 1.5
207
- : 0
208
- const datumLabelTextWidth = hasDatumLabel
209
- ? utils.measureTextWidth(\`\${eventData.datum.label}\${valueText}\`, styles.textSizePx)
210
- : 0
211
- const maxTextWidth = Math.max(seriesLabelTextWidth, datumLabelTextWidth)
212
- const lineEndX = hasDatumLabel
213
- ? maxTextWidth + styles.textSizePx * 1.5
214
- : 0
215
- const valueTextAnchor = hasDatumLabel ? 'end' : 'start'
216
- const datumSvg = \`<text font-size="\${styles.textSizePx}" dominant-baseline="hanging" fill="\${styles.textColor}">
217
- \${datumLabelSvg}<tspan font-weight="bold" text-anchor="\${valueTextAnchor}" x="\${lineEndX}">\${valueText}</tspan>
218
- </text>\`
219
-
220
- return \`\${seriesSvg}
221
- <g \${hasSeriesLabel ? \`transform="translate(0, \${styles.textSizePx * 2})"\` : ''}>
222
- \${datumSvg}
223
- </g>\`
1
+ import type { ComputedDatumSeries, EventSeries, EventName, ColorType } from '../../lib/core-types'
2
+ import type {
3
+ BubblesParams,
4
+ PieParams,
5
+ PieEventTextsParams,
6
+ PieLabelsParams,
7
+ RoseParams,
8
+ RoseLabelsParams,
9
+ SeriesLegendParams,
10
+ SeriesTooltipParams
11
+ } from '../../lib/plugins-basic-types'
12
+
13
+
14
+ export const DEFAULT_BUBBLES_PARAMS: BubblesParams = {
15
+ force: {
16
+ strength: 0.08, // 泡泡引力
17
+ velocityDecay: 0.3, // 衰減數
18
+ collisionSpacing: 2 // 泡泡間距
19
+ },
20
+ bubbleLabel: {
21
+ labelFn: d => String(d.label),
22
+ colorType: 'labelContrast',
23
+ fillRate: 0.6,
24
+ lineHeight: 1,
25
+ maxLineLength: 6,
26
+ wordBreakAll: true,
27
+ },
28
+ // highlightRIncrease: 0,
29
+ arcScaleType: 'area'
30
+ }
31
+ DEFAULT_BUBBLES_PARAMS.bubbleLabel.labelFn.toString = () => `d => String(d.label)`
32
+
33
+ export const DEFAULT_PIE_PARAMS: PieParams = {
34
+ outerRadius: 0.85,
35
+ innerRadius: 0,
36
+ outerRadiusWhileHighlight: 0.9,
37
+ startAngle: 0,
38
+ endAngle: Math.PI * 2,
39
+ padAngle: 0,
40
+ strokeColorType: 'background',
41
+ strokeWidth: 1,
42
+ // padRadius: 100,
43
+ cornerRadius: 0,
44
+ }
45
+
46
+ export const DEFAULT_PIE_EVENT_TEXTS_PARAMS: PieEventTextsParams = {
47
+ renderFn: (eventData: EventSeries) => {
48
+ if (eventData.eventName === 'mouseover' || eventData.eventName === 'mousemove') {
49
+ return [String(eventData.datum!.value)]
50
+ }
51
+ return [
52
+ String(
53
+ Math.round(
54
+ eventData.data.reduce((acc, seriesData) => {
55
+ return acc + seriesData.reduce((_acc, data) => {
56
+ return _acc + (data.value ?? 0)
57
+ }, 0)
58
+ }, 0) * (eventData.tween ?? 1)
59
+ )
60
+ )
61
+ ]
62
+ },
63
+ textAttrs: [
64
+ {
65
+ "transform": "translate(0, 0)"
66
+ }
67
+ ],
68
+ textStyles: [
69
+ {
70
+ "font-weight": "bold",
71
+ "text-anchor": "middle",
72
+ "pointer-events": "none",
73
+ "dominant-baseline": "middle",
74
+ "font-size": 64,
75
+ "fill": "#000"
76
+ }
77
+ ]
78
+ }
79
+ DEFAULT_PIE_EVENT_TEXTS_PARAMS.renderFn.toString = () => `(eventData) => {
80
+ if (eventData.eventName === 'mouseover' || eventData.eventName === 'mousemove') {
81
+ return [String(eventData.datum.value)]
82
+ }
83
+ return [
84
+ String(
85
+ Math.round(
86
+ eventData.data.reduce((acc, seriesData) => {
87
+ return acc + seriesData.reduce((_acc, data) => {
88
+ return _acc + (data.value ?? 0)
89
+ }, 0)
90
+ }, 0) * (eventData.tween ?? 1)
91
+ )
92
+ )
93
+ ]
94
+ }`
95
+
96
+ export const DEFAULT_PIE_LABELS_PARAMS: PieLabelsParams = {
97
+ // solidColor: undefined,
98
+ // colors: DEFAULT_COLORS,
99
+ outerRadius: 0.85,
100
+ outerRadiusWhileHighlight: 0.9,
101
+ // innerRadius: 0,
102
+ // enterDuration: 800,
103
+ startAngle: 0,
104
+ endAngle: Math.PI * 2,
105
+ labelCentroid: 2.1,
106
+ // fontSize: 12,
107
+ labelColorType: 'primary',
108
+ labelFn: d => String(d.label),
109
+ }
110
+ DEFAULT_PIE_LABELS_PARAMS.labelFn.toString = () => `d => String(d.label)`
111
+
112
+ export const DEFAULT_ROSE_PARAMS: RoseParams = {
113
+ outerRadius: 0.95,
114
+ padAngle: 0,
115
+ strokeColorType: 'background',
116
+ strokeWidth: 0.5,
117
+ cornerRadius: 0,
118
+ arcScaleType: 'area',
119
+ angleIncreaseWhileHighlight: 0.05
120
+ }
121
+
122
+ export const DEFAULT_ROSE_LABELS_PARAMS: RoseLabelsParams = {
123
+ outerRadius: 0.95,
124
+ labelCentroid: 2.1,
125
+ labelFn: d => String(d.label),
126
+ labelColorType: 'primary',
127
+ arcScaleType: 'area'
128
+ }
129
+ DEFAULT_ROSE_LABELS_PARAMS.labelFn.toString = () => `d => String(d.label)`
130
+
131
+ export const DEFAULT_SERIES_LEGEND_PARAMS: SeriesLegendParams = {
132
+ // position: 'right',
133
+ // justify: 'end',
134
+ placement: 'right-end',
135
+ padding: 28,
136
+ // offset: [0, 0],
137
+ backgroundFill: 'none',
138
+ backgroundStroke: 'none',
139
+ gap: 10,
140
+ listRectWidth: 14,
141
+ listRectHeight: 14,
142
+ listRectRadius: 0,
143
+ // highlightEvent: false
144
+ textColorType: 'primary'
145
+ }
146
+
147
+ export const DEFAULT_SERIES_TOOLTIP_PARAMS: SeriesTooltipParams = {
148
+ backgroundColorType: 'background',
149
+ strokeColorType: 'primary',
150
+ backgroundOpacity: 0.8,
151
+ textColorType: 'primary',
152
+ offset: [20, 5],
153
+ padding: 10,
154
+ renderFn: (eventData, { styles, utils }) => {
155
+ const hasSeriesLabel = eventData.seriesLabel.slice(0, 7) === 'series_' ? false : true
156
+ const hasDatumLabel = eventData.datum.label.slice(0, 7) === 'series_' ? false : true
157
+ const valueText = utils.toCurrency(eventData.datum.value)
158
+ const bulletWidth = styles.textSizePx * 0.7
159
+ const offset = (styles.textSizePx / 2) - (bulletWidth / 2)
160
+ const seriesSvg = hasSeriesLabel
161
+ ? `<rect width="${bulletWidth}" height="${bulletWidth}" x="${offset}" y="${offset - 1}" rx="${bulletWidth / 2}" fill="${eventData.datum.color}"></rect>
162
+ <text x="${styles.textSizePx * 1.5}" font-size="${styles.textSizePx}" dominant-baseline="hanging" fill="${styles.textColor}">
163
+ <tspan>${eventData.seriesLabel}</tspan>
164
+ </text>`
165
+ : ''
166
+ const datumLabelSvg = hasDatumLabel
167
+ ? `<tspan>${eventData.datum.label}</tspan> `
168
+ : ''
169
+ const seriesLabelTextWidth = hasSeriesLabel
170
+ ? utils.measureTextWidth(`${eventData.seriesLabel}${valueText}`, styles.textSizePx) + styles.textSizePx * 1.5
171
+ : 0
172
+ const datumLabelTextWidth = hasDatumLabel
173
+ ? utils.measureTextWidth(`${eventData.datum.label}${valueText}`, styles.textSizePx)
174
+ : 0
175
+ const maxTextWidth = Math.max(seriesLabelTextWidth, datumLabelTextWidth)
176
+ const lineEndX = hasDatumLabel
177
+ ? maxTextWidth + styles.textSizePx * 1.5
178
+ : 0
179
+ const valueTextAnchor = hasDatumLabel ? 'end' : 'start'
180
+ const datumSvg = `<text font-size="${styles.textSizePx}" dominant-baseline="hanging" fill="${styles.textColor}">
181
+ ${datumLabelSvg}<tspan font-weight="bold" text-anchor="${valueTextAnchor}" x="${lineEndX}">${valueText}</tspan>
182
+ </text>`
183
+
184
+ return `${seriesSvg}
185
+ <g ${hasSeriesLabel ? `transform="translate(0, ${styles.textSizePx * 2})"` : ''}>
186
+ ${datumSvg}
187
+ </g>`
188
+ },
189
+ }
190
+ DEFAULT_SERIES_TOOLTIP_PARAMS.renderFn.toString = () => `(eventData, { styles, utils }) => {
191
+ const hasSeriesLabel = eventData.seriesLabel.slice(0, 7) === 'series_' ? false : true
192
+ const hasDatumLabel = eventData.datum.label.slice(0, 7) === 'series_' ? false : true
193
+ const valueText = utils.toCurrency(eventData.datum.value)
194
+ const bulletWidth = styles.textSizePx * 0.7
195
+ const offset = (styles.textSizePx / 2) - (bulletWidth / 2)
196
+ const seriesSvg = hasSeriesLabel
197
+ ? \`<rect width="\${bulletWidth}" height="\${bulletWidth}" x="\${offset}" y="\${offset - 1}" rx="\${bulletWidth / 2}" fill="\${eventData.datum.color}"></rect>
198
+ <text x="\${styles.textSizePx * 1.5}" font-size="\${styles.textSizePx}" dominant-baseline="hanging" fill="\${styles.textColor}">
199
+ <tspan>\${eventData.seriesLabel}</tspan>
200
+ </text>\`
201
+ : ''
202
+ const datumLabelSvg = hasDatumLabel
203
+ ? \`<tspan>\${eventData.datum.label}</tspan> \`
204
+ : ''
205
+ const seriesLabelTextWidth = hasSeriesLabel
206
+ ? utils.measureTextWidth(\`\${eventData.seriesLabel}\${valueText}\`, styles.textSizePx) + styles.textSizePx * 1.5
207
+ : 0
208
+ const datumLabelTextWidth = hasDatumLabel
209
+ ? utils.measureTextWidth(\`\${eventData.datum.label}\${valueText}\`, styles.textSizePx)
210
+ : 0
211
+ const maxTextWidth = Math.max(seriesLabelTextWidth, datumLabelTextWidth)
212
+ const lineEndX = hasDatumLabel
213
+ ? maxTextWidth + styles.textSizePx * 1.5
214
+ : 0
215
+ const valueTextAnchor = hasDatumLabel ? 'end' : 'start'
216
+ const datumSvg = \`<text font-size="\${styles.textSizePx}" dominant-baseline="hanging" fill="\${styles.textColor}">
217
+ \${datumLabelSvg}<tspan font-weight="bold" text-anchor="\${valueTextAnchor}" x="\${lineEndX}">\${valueText}</tspan>
218
+ </text>\`
219
+
220
+ return \`\${seriesSvg}
221
+ <g \${hasSeriesLabel ? \`transform="translate(0, \${styles.textSizePx * 2})"\` : ''}>
222
+ \${datumSvg}
223
+ </g>\`
224
224
  }`
@@ -1,10 +1,10 @@
1
- export * from './defaults'
2
- // export * from './types'
3
- export { Bubbles } from './plugins/Bubbles'
4
- export { Pie } from './plugins/Pie'
5
- export { PieEventTexts } from './plugins/PieEventTexts'
6
- export { PieLabels } from './plugins/PieLabels'
7
- export { Rose } from './plugins/Rose'
8
- export { RoseLabels } from './plugins/RoseLabels'
9
- export { SeriesLegend } from './plugins/SeriesLegend'
1
+ export * from './defaults'
2
+ // export * from './types'
3
+ export { Bubbles } from './plugins/Bubbles'
4
+ export { Pie } from './plugins/Pie'
5
+ export { PieEventTexts } from './plugins/PieEventTexts'
6
+ export { PieLabels } from './plugins/PieLabels'
7
+ export { Rose } from './plugins/Rose'
8
+ export { RoseLabels } from './plugins/RoseLabels'
9
+ export { SeriesLegend } from './plugins/SeriesLegend'
10
10
  export { SeriesTooltip } from './plugins/SeriesTooltip'