@orbcharts/plugins-basic 3.0.7 → 3.0.9

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