@orbcharts/plugins-basic 3.0.0-beta.8 → 3.0.0
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/dist/orbcharts-plugins-basic.es.js +13170 -10984
- package/dist/orbcharts-plugins-basic.umd.js +266 -98
- package/dist/{orbcharts-plugins-basic/src → src}/base/BaseBars.d.ts +3 -3
- package/dist/{orbcharts-plugins-basic/src → src}/base/BaseBarsTriangle.d.ts +3 -3
- package/dist/{orbcharts-plugins-basic/src → src}/base/BaseDots.d.ts +3 -3
- package/dist/{orbcharts-plugins-basic/src → src}/base/BaseLineAreas.d.ts +3 -3
- package/dist/{orbcharts-plugins-basic/src → src}/base/BaseLines.d.ts +3 -3
- package/dist/src/base/BaseRacingBars.d.ts +23 -0
- package/dist/src/base/BaseRacingLabels.d.ts +20 -0
- package/dist/src/base/BaseRacingValueLabels.d.ts +20 -0
- package/dist/{orbcharts-plugins-basic/src/base/BaseStackedBar.d.ts → src/base/BaseStackedBars.d.ts} +7 -7
- package/dist/{orbcharts-plugins-basic/src → src}/base/BaseValueAxis.d.ts +4 -7
- package/dist/src/base/BaseXAxis.d.ts +20 -0
- package/dist/src/base/BaseYAxis.d.ts +18 -0
- package/dist/{orbcharts-plugins-basic/src → src}/grid/defaults.d.ts +3 -3
- package/dist/{orbcharts-plugins-basic/src → src}/grid/gridObservables.d.ts +8 -1
- package/dist/{orbcharts-plugins-basic/src → src}/grid/index.d.ts +2 -2
- package/dist/src/grid/plugins/GroupZoom.d.ts +1 -0
- package/dist/src/grid/plugins/StackedBars.d.ts +1 -0
- package/dist/src/index.d.ts +7 -1
- package/dist/{orbcharts-plugins-basic/src → src}/multiGrid/defaults.d.ts +2 -2
- package/dist/{orbcharts-plugins-basic/src → src}/multiGrid/index.d.ts +1 -1
- package/dist/src/multiGrid/plugins/MultiStackedBars.d.ts +1 -0
- package/dist/src/multiValue/defaults.d.ts +13 -0
- package/dist/{orbcharts-plugins-basic/src → src}/multiValue/index.d.ts +5 -1
- package/dist/src/multiValue/multiValueObservables.d.ts +56 -0
- package/dist/src/multiValue/plugins/RacingBars.d.ts +1 -0
- package/dist/src/multiValue/plugins/RacingCounterTexts.d.ts +3 -0
- package/dist/src/multiValue/plugins/RacingValueAxis.d.ts +1 -0
- package/dist/src/multiValue/plugins/XAxis.d.ts +1 -0
- package/dist/src/multiValue/plugins/XYAxes.d.ts +1 -0
- package/dist/src/multiValue/plugins/XZoom.d.ts +1 -0
- package/dist/{orbcharts-plugins-basic/src → src}/relationship/defaults.d.ts +2 -1
- package/dist/{orbcharts-plugins-basic/src → src}/relationship/index.d.ts +1 -0
- package/dist/src/relationship/plugins/ForceDirectedBubbles.d.ts +3 -0
- package/dist/{orbcharts-plugins-basic/src → src}/utils/commonUtils.d.ts +1 -0
- package/dist/{orbcharts-plugins-basic/src → src}/utils/d3Graphics.d.ts +2 -1
- package/dist/{orbcharts-plugins-basic/src → src}/utils/d3Utils.d.ts +1 -0
- package/lib/core.ts +1 -1
- package/package.json +4 -4
- package/src/base/BaseBars.ts +15 -15
- package/src/base/BaseBarsTriangle.ts +15 -15
- package/src/base/BaseDots.ts +14 -14
- package/src/base/BaseGroupAxis.ts +18 -6
- package/src/base/BaseLineAreas.ts +12 -12
- package/src/base/BaseLines.ts +11 -11
- package/src/base/BaseRacingBars.ts +552 -0
- package/src/base/BaseRacingLabels.ts +396 -0
- package/src/base/BaseRacingValueLabels.ts +403 -0
- package/src/base/{BaseStackedBar.ts → BaseStackedBars.ts} +26 -26
- package/src/base/BaseTooltip.ts +2 -1
- package/src/base/BaseValueAxis.ts +70 -53
- package/src/base/BaseXAxis.ts +427 -0
- package/src/base/BaseYAxis.ts +389 -0
- package/src/grid/defaults.ts +44 -77
- package/src/grid/gridObservables.ts +58 -0
- package/src/grid/index.ts +2 -2
- package/src/grid/plugins/Bars.ts +2 -2
- package/src/grid/plugins/BarsPN.ts +2 -2
- package/src/grid/plugins/BarsTriangle.ts +2 -2
- package/src/grid/plugins/Dots.ts +2 -2
- package/src/grid/plugins/GridLegend.ts +7 -7
- package/src/grid/plugins/GroupAux.ts +41 -24
- package/src/grid/plugins/GroupAxis.ts +0 -24
- package/src/grid/plugins/{GridZoom.ts → GroupZoom.ts} +5 -5
- package/src/grid/plugins/LineAreas.ts +2 -2
- package/src/grid/plugins/Lines.ts +2 -2
- package/src/grid/plugins/{StackedBar.ts → StackedBars.ts} +9 -9
- package/src/multiGrid/defaults.ts +44 -24
- package/src/multiGrid/index.ts +1 -1
- package/src/multiGrid/multiGridObservables.ts +1 -0
- package/src/multiGrid/plugins/MultiBars.ts +3 -3
- package/src/multiGrid/plugins/MultiBarsTriangle.ts +3 -3
- package/src/multiGrid/plugins/MultiDots.ts +3 -3
- package/src/multiGrid/plugins/MultiGridLegend.ts +20 -10
- package/src/multiGrid/plugins/MultiLineAreas.ts +3 -3
- package/src/multiGrid/plugins/MultiLines.ts +3 -3
- package/src/multiGrid/plugins/{MultiStackedBar.ts → MultiStackedBars.ts} +10 -10
- package/src/multiGrid/plugins/OverlappingStackedValueAxes.ts +1 -0
- package/src/multiValue/defaults.ts +277 -12
- package/src/multiValue/index.ts +5 -1
- package/src/multiValue/multiValueObservables.ts +414 -44
- package/src/multiValue/plugins/OrdinalXAxis.ts +0 -0
- package/src/multiValue/plugins/RacingBars.ts +373 -0
- package/src/multiValue/plugins/RacingCounterAxis.ts +0 -0
- package/src/multiValue/plugins/RacingCounterTexts.ts +300 -0
- package/src/multiValue/plugins/RacingValueAxis.ts +115 -0
- package/src/multiValue/plugins/RankingAxis_legacy.ts +109 -0
- package/src/multiValue/plugins/Scatter.ts +13 -13
- package/src/multiValue/plugins/ScatterBubbles.ts +13 -13
- package/src/multiValue/plugins/XAxis.ts +108 -0
- package/src/multiValue/plugins/XYAux.ts +15 -14
- package/src/multiValue/plugins/XYAxes.ts +38 -528
- package/src/multiValue/plugins/XYAxes_legacy.ts +684 -0
- package/src/multiValue/plugins/{XYZoom.ts → XZoom.ts} +17 -17
- package/src/relationship/defaults.ts +129 -20
- package/src/relationship/index.ts +1 -0
- package/src/relationship/plugins/ForceDirected.ts +113 -87
- package/src/relationship/plugins/ForceDirectedBubbles.ts +1412 -0
- package/src/series/defaults.ts +52 -37
- package/src/series/plugins/Bubbles.ts +71 -39
- package/src/series/plugins/Pie.ts +5 -5
- package/src/series/plugins/PieEventTexts.ts +3 -3
- package/src/series/plugins/PieLabels.ts +5 -5
- package/src/series/plugins/Rose.ts +11 -11
- package/src/series/plugins/RoseLabels.ts +9 -9
- package/src/tree/defaults.ts +46 -22
- package/src/tree/plugins/TreeMap.ts +11 -3
- package/src/utils/commonUtils.ts +10 -1
- package/src/utils/d3Graphics.ts +4 -2
- package/src/utils/d3Utils.ts +18 -0
- package/src/utils/orbchartsUtils.ts +30 -16
- package/dist/orbcharts-plugins-basic/src/grid/plugins/GridZoom.d.ts +0 -1
- package/dist/orbcharts-plugins-basic/src/grid/plugins/StackedBar.d.ts +0 -1
- package/dist/orbcharts-plugins-basic/src/index.d.ts +0 -7
- package/dist/orbcharts-plugins-basic/src/multiGrid/plugins/MultiStackedBar.d.ts +0 -1
- package/dist/orbcharts-plugins-basic/src/multiValue/defaults.d.ts +0 -9
- package/dist/orbcharts-plugins-basic/src/multiValue/multiValueObservables.d.ts +0 -33
- package/dist/orbcharts-plugins-basic/src/multiValue/plugins/XYZoom.d.ts +0 -1
- /package/dist/{orbcharts-plugins-basic/lib → lib}/core-types.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/lib → lib}/core.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/lib → lib}/plugins-basic-types.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/base/BaseGroupAxis.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/base/BaseLegend.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/base/BaseTooltip.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/base/types.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/const.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/grid/plugins/Bars.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/grid/plugins/BarsPN.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/grid/plugins/BarsTriangle.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/grid/plugins/Dots.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/grid/plugins/GridLegend.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/grid/plugins/GridTooltip.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/grid/plugins/GroupAux.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/grid/plugins/GroupAxis.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/grid/plugins/LineAreas.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/grid/plugins/Lines.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/grid/plugins/StackedValueAxis.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/grid/plugins/ValueAxis.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/multiGrid/multiGridObservables.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/multiGrid/plugins/MultiBars.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/multiGrid/plugins/MultiBarsTriangle.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/multiGrid/plugins/MultiDots.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/multiGrid/plugins/MultiGridLegend.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/multiGrid/plugins/MultiGridTooltip.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/multiGrid/plugins/MultiGroupAxis.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/multiGrid/plugins/MultiLineAreas.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/multiGrid/plugins/MultiLines.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/multiGrid/plugins/MultiStackedValueAxis.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/multiGrid/plugins/MultiValueAxis.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/multiGrid/plugins/OverlappingStackedValueAxes.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/multiGrid/plugins/OverlappingValueAxes.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/multiValue/plugins/MultiValueLegend.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/multiValue/plugins/MultiValueTooltip.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src/multiValue/plugins/Ranking.d.ts → src/multiValue/plugins/OrdinalBubbles.d.ts} +0 -0
- /package/dist/{orbcharts-plugins-basic/src/multiValue/plugins/RankingAxis.d.ts → src/multiValue/plugins/OrdinalXAxis.d.ts} +0 -0
- /package/dist/{orbcharts-plugins-basic/src/noneData/plugins/Container.d.ts → src/multiValue/plugins/RacingCounterAxis.d.ts} +0 -0
- /package/dist/{orbcharts-plugins-basic/src/noneData/plugins/Tooltip.d.ts → src/multiValue/plugins/RankingAxis_legacy.d.ts} +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/multiValue/plugins/Scatter.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/multiValue/plugins/ScatterBubbles.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/multiValue/plugins/XYAux.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src/multiValue/plugins/XYAxes.d.ts → src/multiValue/plugins/XYAxes_legacy.d.ts} +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/noneData/defaults.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/noneData/index.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src/relationship/plugins/ForceDirectedBubbles.d.ts → src/noneData/plugins/Container.d.ts} +0 -0
- /package/dist/{orbcharts-plugins-basic/src/series/plugins/Waffle.d.ts → src/noneData/plugins/Tooltip.d.ts} +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/relationship/plugins/ForceDirected.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/relationship/plugins/RelationshipLegend.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/relationship/plugins/RelationshipTooltip.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/relationship/relationshipObservables.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/series/defaults.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/series/index.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/series/plugins/Bubbles.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/series/plugins/Pie.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/series/plugins/PieEventTexts.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/series/plugins/PieLabels.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/series/plugins/Rose.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/series/plugins/RoseLabels.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/series/plugins/SeriesLegend.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/series/plugins/SeriesTooltip.d.ts +0 -0
- /package/{src/multiValue/plugins/Ranking.ts → dist/src/series/plugins/Waffle.d.ts} +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/series/seriesObservables.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/series/seriesUtils.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/tree/defaults.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/tree/index.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/tree/plugins/TreeLegend.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/tree/plugins/TreeMap.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/tree/plugins/TreeTooltip.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/utils/observables.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/utils/orbchartsUtils.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/vite.config.d.ts → vite.config.d.ts} +0 -0
- /package/src/multiValue/plugins/{RankingAxis.ts → OrdinalBubbles.ts} +0 -0
package/src/series/defaults.ts
CHANGED
@@ -18,26 +18,20 @@ export const DEFAULT_BUBBLES_PARAMS: BubblesParams = {
|
|
18
18
|
collisionSpacing: 2 // 泡泡間距
|
19
19
|
},
|
20
20
|
bubbleLabel: {
|
21
|
+
colorType: 'labelContrast',
|
21
22
|
fillRate: 0.6,
|
22
|
-
lineHeight:
|
23
|
-
|
23
|
+
lineHeight: 1,
|
24
|
+
maxLineLength: 6,
|
25
|
+
wordBreakAll: true,
|
24
26
|
},
|
25
27
|
// highlightRIncrease: 0,
|
26
28
|
arcScaleType: 'area'
|
27
29
|
}
|
28
30
|
|
29
31
|
export const DEFAULT_PIE_PARAMS: PieParams = {
|
30
|
-
// padding: {
|
31
|
-
// top: 50,
|
32
|
-
// right: 70,
|
33
|
-
// bottom: 50,
|
34
|
-
// left: 70
|
35
|
-
// },
|
36
32
|
outerRadius: 0.85,
|
37
33
|
innerRadius: 0,
|
38
34
|
outerRadiusWhileHighlight: 0.9,
|
39
|
-
// label?: LabelStyle
|
40
|
-
// enterDuration: 800,
|
41
35
|
startAngle: 0,
|
42
36
|
endAngle: Math.PI * 2,
|
43
37
|
padAngle: 0,
|
@@ -45,9 +39,6 @@ export const DEFAULT_PIE_PARAMS: PieParams = {
|
|
45
39
|
strokeWidth: 1,
|
46
40
|
// padRadius: 100,
|
47
41
|
cornerRadius: 0,
|
48
|
-
// highlightTarget: 'datum',
|
49
|
-
// highlightId: null,
|
50
|
-
// highlightLabel: null,
|
51
42
|
}
|
52
43
|
|
53
44
|
export const DEFAULT_PIE_EVENT_TEXTS_PARAMS: PieEventTextsParams = {
|
@@ -117,17 +108,17 @@ export const DEFAULT_PIE_LABELS_PARAMS: PieLabelsParams = {
|
|
117
108
|
DEFAULT_PIE_LABELS_PARAMS.labelFn.toString = () => `d => String(d.label)`
|
118
109
|
|
119
110
|
export const DEFAULT_ROSE_PARAMS: RoseParams = {
|
120
|
-
outerRadius: 0.
|
111
|
+
outerRadius: 0.95,
|
121
112
|
padAngle: 0,
|
122
113
|
strokeColorType: 'background',
|
123
|
-
strokeWidth: 0,
|
114
|
+
strokeWidth: 0.5,
|
124
115
|
cornerRadius: 0,
|
125
116
|
arcScaleType: 'area',
|
126
117
|
angleIncreaseWhileHighlight: 0.05
|
127
118
|
}
|
128
119
|
|
129
120
|
export const DEFAULT_ROSE_LABELS_PARAMS: RoseLabelsParams = {
|
130
|
-
outerRadius: 0.
|
121
|
+
outerRadius: 0.95,
|
131
122
|
labelCentroid: 2.1,
|
132
123
|
labelFn: d => String(d.label),
|
133
124
|
labelColorType: 'primary',
|
@@ -161,6 +152,7 @@ export const DEFAULT_SERIES_TOOLTIP_PARAMS: SeriesTooltipParams = {
|
|
161
152
|
renderFn: (eventData, { styles, utils }) => {
|
162
153
|
const hasSeriesLabel = eventData.seriesLabel.slice(0, 7) === 'series_' ? false : true
|
163
154
|
const hasDatumLabel = eventData.datum.label.slice(0, 7) === 'series_' ? false : true
|
155
|
+
const valueText = utils.toCurrency(eventData.datum.value)
|
164
156
|
const bulletWidth = styles.textSizePx * 0.7
|
165
157
|
const offset = (styles.textSizePx / 2) - (bulletWidth / 2)
|
166
158
|
const seriesSvg = hasSeriesLabel
|
@@ -172,8 +164,19 @@ export const DEFAULT_SERIES_TOOLTIP_PARAMS: SeriesTooltipParams = {
|
|
172
164
|
const datumLabelSvg = hasDatumLabel
|
173
165
|
? `<tspan>${eventData.datum.label}</tspan> `
|
174
166
|
: ''
|
167
|
+
const seriesLabelTextWidth = hasSeriesLabel
|
168
|
+
? utils.measureTextWidth(`${eventData.seriesLabel}${valueText}`, styles.textSizePx) + styles.textSizePx * 1.5
|
169
|
+
: 0
|
170
|
+
const datumLabelTextWidth = hasDatumLabel
|
171
|
+
? utils.measureTextWidth(`${eventData.datum.label}${valueText}`, styles.textSizePx)
|
172
|
+
: 0
|
173
|
+
const maxTextWidth = Math.max(seriesLabelTextWidth, datumLabelTextWidth)
|
174
|
+
const lineEndX = hasDatumLabel
|
175
|
+
? maxTextWidth + styles.textSizePx * 1.5
|
176
|
+
: 0
|
177
|
+
const valueTextAnchor = hasDatumLabel ? 'end' : 'start'
|
175
178
|
const datumSvg = `<text font-size="${styles.textSizePx}" dominant-baseline="hanging" fill="${styles.textColor}">
|
176
|
-
${datumLabelSvg}<tspan font-weight="bold">${
|
179
|
+
${datumLabelSvg}<tspan font-weight="bold" text-anchor="${valueTextAnchor}" x="${lineEndX}">${valueText}</tspan>
|
177
180
|
</text>`
|
178
181
|
|
179
182
|
return `${seriesSvg}
|
@@ -183,25 +186,37 @@ export const DEFAULT_SERIES_TOOLTIP_PARAMS: SeriesTooltipParams = {
|
|
183
186
|
},
|
184
187
|
}
|
185
188
|
DEFAULT_SERIES_TOOLTIP_PARAMS.renderFn.toString = () => `(eventData, { styles, utils }) => {
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
</
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
189
|
+
const hasSeriesLabel = eventData.seriesLabel.slice(0, 7) === 'series_' ? false : true
|
190
|
+
const hasDatumLabel = eventData.datum.label.slice(0, 7) === 'series_' ? false : true
|
191
|
+
const valueText = utils.toCurrency(eventData.datum.value)
|
192
|
+
const bulletWidth = styles.textSizePx * 0.7
|
193
|
+
const offset = (styles.textSizePx / 2) - (bulletWidth / 2)
|
194
|
+
const seriesSvg = hasSeriesLabel
|
195
|
+
? \`<rect width="\${bulletWidth}" height="\${bulletWidth}" x="\${offset}" y="\${offset - 1}" rx="\${bulletWidth / 2}" fill="\${eventData.datum.color}"></rect>
|
196
|
+
<text x="\${styles.textSizePx * 1.5}" font-size="\${styles.textSizePx}" dominant-baseline="hanging" fill="\${styles.textColor}">
|
197
|
+
<tspan>\${eventData.seriesLabel}</tspan>
|
198
|
+
</text>\`
|
199
|
+
: ''
|
200
|
+
const datumLabelSvg = hasDatumLabel
|
201
|
+
? \`<tspan>\${eventData.datum.label}</tspan> \`
|
202
|
+
: ''
|
203
|
+
const seriesLabelTextWidth = hasSeriesLabel
|
204
|
+
? utils.measureTextWidth(\`\${eventData.seriesLabel}\${valueText}\`, styles.textSizePx) + styles.textSizePx * 1.5
|
205
|
+
: 0
|
206
|
+
const datumLabelTextWidth = hasDatumLabel
|
207
|
+
? utils.measureTextWidth(\`\${eventData.datum.label}\${valueText}\`, styles.textSizePx)
|
208
|
+
: 0
|
209
|
+
const maxTextWidth = Math.max(seriesLabelTextWidth, datumLabelTextWidth)
|
210
|
+
const lineEndX = hasDatumLabel
|
211
|
+
? maxTextWidth + styles.textSizePx * 1.5
|
212
|
+
: 0
|
213
|
+
const valueTextAnchor = hasDatumLabel ? 'end' : 'start'
|
214
|
+
const datumSvg = \`<text font-size="\${styles.textSizePx}" dominant-baseline="hanging" fill="\${styles.textColor}">
|
215
|
+
\${datumLabelSvg}<tspan font-weight="bold" text-anchor="\${valueTextAnchor}" x="\${lineEndX}">\${valueText}</tspan>
|
216
|
+
</text>\`
|
202
217
|
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
218
|
+
return \`\${seriesSvg}
|
219
|
+
<g \${hasSeriesLabel ? \`transform="translate(0, \${styles.textSizePx * 2})"\` : ''}>
|
220
|
+
\${datumSvg}
|
221
|
+
</g>\`
|
207
222
|
}`
|
@@ -5,6 +5,7 @@ import {
|
|
5
5
|
switchMap,
|
6
6
|
first,
|
7
7
|
takeUntil,
|
8
|
+
debounceTime,
|
8
9
|
Subject,
|
9
10
|
Observable,
|
10
11
|
distinctUntilChanged,
|
@@ -24,6 +25,7 @@ import type { BubblesParams, ArcScaleType } from '../../../lib/plugins-basic-typ
|
|
24
25
|
import { DEFAULT_BUBBLES_PARAMS } from '../defaults'
|
25
26
|
import { renderCircleText } from '../../utils/d3Graphics'
|
26
27
|
import { LAYER_INDEX_OF_GRAPHIC } from '../../const'
|
28
|
+
import { getDatumColor } from '../../utils/orbchartsUtils'
|
27
29
|
|
28
30
|
interface BubblesDatum extends ComputedDatumSeries {
|
29
31
|
x: number
|
@@ -36,6 +38,8 @@ type BubblesSimulationDatum = BubblesDatum & d3.SimulationNodeDatum
|
|
36
38
|
|
37
39
|
const pluginName = 'Bubbles'
|
38
40
|
|
41
|
+
const baseLineHeight = 12 // 未變形前的字體大小(代入計算用而已,數字多少都不會有影響)
|
42
|
+
|
39
43
|
const pluginConfig: DefinePluginConfig<typeof pluginName, typeof DEFAULT_BUBBLES_PARAMS> = {
|
40
44
|
name: pluginName,
|
41
45
|
defaultParams: DEFAULT_BUBBLES_PARAMS,
|
@@ -71,13 +75,16 @@ const pluginConfig: DefinePluginConfig<typeof pluginName, typeof DEFAULT_BUBBLES
|
|
71
75
|
}
|
72
76
|
if (params.bubbleLabel) {
|
73
77
|
const bubbleLabelResult = validateColumns(params.bubbleLabel, {
|
78
|
+
colorType: {
|
79
|
+
toBeOption: 'ColorType'
|
80
|
+
},
|
74
81
|
fillRate: {
|
75
82
|
toBeTypes: ['number']
|
76
83
|
},
|
77
84
|
lineHeight: {
|
78
85
|
toBeTypes: ['number']
|
79
86
|
},
|
80
|
-
|
87
|
+
maxLineLength: {
|
81
88
|
toBeTypes: ['number']
|
82
89
|
},
|
83
90
|
})
|
@@ -89,9 +96,10 @@ const pluginConfig: DefinePluginConfig<typeof pluginName, typeof DEFAULT_BUBBLES
|
|
89
96
|
}
|
90
97
|
}
|
91
98
|
|
92
|
-
let force: d3.Simulation<d3.SimulationNodeDatum, undefined> | undefined
|
93
99
|
|
94
|
-
|
100
|
+
// let isRunning = false
|
101
|
+
|
102
|
+
function createSimulation (bubblesSelection: d3.Selection<SVGGElement, BubblesDatum, any, any>, fullParams: BubblesParams) {
|
95
103
|
return d3.forceSimulation()
|
96
104
|
.velocityDecay(fullParams.force!.velocityDecay!)
|
97
105
|
// .alphaDecay(0.2)
|
@@ -120,7 +128,12 @@ function makeForce (bubblesSelection: d3.Selection<SVGGElement, BubblesDatum, an
|
|
120
128
|
})
|
121
129
|
// .attr("cx", (d) => d.x)
|
122
130
|
// .attr("cy", (d) => d.y)
|
131
|
+
|
132
|
+
|
123
133
|
})
|
134
|
+
// .on("end", () => {
|
135
|
+
|
136
|
+
// })
|
124
137
|
|
125
138
|
}
|
126
139
|
|
@@ -143,8 +156,8 @@ function makeForce (bubblesSelection: d3.Selection<SVGGElement, BubblesDatum, an
|
|
143
156
|
// return maxR * modifier
|
144
157
|
// }
|
145
158
|
|
146
|
-
function createBubblesData ({
|
147
|
-
|
159
|
+
function createBubblesData ({ visibleComputedSortedData, LastBubbleDataMap, graphicWidth, graphicHeight, SeriesContainerPositionMap, scaleType }: {
|
160
|
+
visibleComputedSortedData: ComputedDataSeries
|
148
161
|
LastBubbleDataMap: Map<string, BubblesDatum>
|
149
162
|
graphicWidth: number
|
150
163
|
graphicHeight: number
|
@@ -155,7 +168,7 @@ function createBubblesData ({ visibleComputedLayoutData, LastBubbleDataMap, grap
|
|
155
168
|
// 虛擬大圓(所有小圓聚合起來的大圓)的半徑
|
156
169
|
const totalR = Math.min(...[graphicWidth, graphicHeight]) / 2
|
157
170
|
|
158
|
-
const data =
|
171
|
+
const data = visibleComputedSortedData.flat()
|
159
172
|
|
160
173
|
const totalValue = data.reduce((acc, current) => acc + current.value, 0)
|
161
174
|
|
@@ -202,10 +215,11 @@ function createBubblesData ({ visibleComputedLayoutData, LastBubbleDataMap, grap
|
|
202
215
|
})
|
203
216
|
}
|
204
217
|
|
205
|
-
function renderBubbles ({ selection, bubblesData, fullParams, sumSeries }: {
|
218
|
+
function renderBubbles ({ selection, bubblesData, fullParams, fullChartParams, sumSeries }: {
|
206
219
|
selection: d3.Selection<SVGGElement, any, any, any>
|
207
220
|
bubblesData: BubblesDatum[]
|
208
221
|
fullParams: BubblesParams
|
222
|
+
fullChartParams: ChartParams
|
209
223
|
sumSeries: boolean
|
210
224
|
}) {
|
211
225
|
const bubblesSelection = selection.selectAll<SVGGElement, BubblesDatum>("g")
|
@@ -215,7 +229,7 @@ function renderBubbles ({ selection, bubblesData, fullParams, sumSeries }: {
|
|
215
229
|
const enterSelection = enter
|
216
230
|
.append('g')
|
217
231
|
.attr('cursor', 'pointer')
|
218
|
-
.attr('font-size',
|
232
|
+
.attr('font-size', baseLineHeight)
|
219
233
|
.style('fill', '#ffffff')
|
220
234
|
.attr("text-anchor", "middle")
|
221
235
|
|
@@ -259,17 +273,24 @@ function renderBubbles ({ selection, bubblesData, fullParams, sumSeries }: {
|
|
259
273
|
bubblesSelection
|
260
274
|
.each((d,i,g) => {
|
261
275
|
const gSelection = d3.select(g[i])
|
262
|
-
|
263
|
-
|
264
|
-
breakAll = false
|
265
|
-
}
|
276
|
+
const text = d[textDataColumn] ?? ''
|
277
|
+
|
266
278
|
gSelection.call(renderCircleText, {
|
267
|
-
text
|
279
|
+
text,
|
268
280
|
radius: d.r * fullParams.bubbleLabel.fillRate,
|
269
|
-
lineHeight: fullParams.bubbleLabel.lineHeight,
|
270
|
-
isBreakAll:
|
281
|
+
lineHeight: baseLineHeight * fullParams.bubbleLabel.lineHeight,
|
282
|
+
isBreakAll: text.length <= fullParams.bubbleLabel.maxLineLength
|
283
|
+
? false
|
284
|
+
: fullParams.bubbleLabel.wordBreakAll
|
271
285
|
})
|
272
286
|
|
287
|
+
// -- text color --
|
288
|
+
gSelection.select('text').attr('fill', _ => getDatumColor({
|
289
|
+
datum: d,
|
290
|
+
colorType: fullParams.bubbleLabel.colorType,
|
291
|
+
fullChartParams: fullChartParams
|
292
|
+
}))
|
293
|
+
|
273
294
|
})
|
274
295
|
|
275
296
|
return bubblesSelection
|
@@ -297,18 +318,18 @@ function setHighlightData ({ data, highlightRIncrease, highlightIds }: {
|
|
297
318
|
})
|
298
319
|
}
|
299
320
|
|
300
|
-
function drag (): d3.DragBehavior<Element, unknown, unknown> {
|
321
|
+
function drag (_simulation: d3.Simulation<d3.SimulationNodeDatum, undefined>): d3.DragBehavior<Element, unknown, unknown> {
|
301
322
|
return d3.drag()
|
302
323
|
.on("start", (event, d: any) => {
|
303
324
|
if (!event.active) {
|
304
|
-
|
325
|
+
_simulation!.alpha(1).restart()
|
305
326
|
}
|
306
327
|
d.fx = d.x
|
307
328
|
d.fy = d.y
|
308
329
|
})
|
309
330
|
.on("drag", (event, d: any) => {
|
310
331
|
if (!event.active) {
|
311
|
-
|
332
|
+
_simulation!.alphaTarget(0)
|
312
333
|
}
|
313
334
|
d.fx = event.x
|
314
335
|
d.fy = event.y
|
@@ -316,6 +337,7 @@ function drag (): d3.DragBehavior<Element, unknown, unknown> {
|
|
316
337
|
.on("end", (event, d: any) => {
|
317
338
|
d.fx = null
|
318
339
|
d.fy = null
|
340
|
+
_simulation!.alpha(1).restart()
|
319
341
|
})
|
320
342
|
}
|
321
343
|
|
@@ -327,14 +349,15 @@ function drag (): d3.DragBehavior<Element, unknown, unknown> {
|
|
327
349
|
// return typeCenter ? typeCenter.x : 0
|
328
350
|
// }
|
329
351
|
|
330
|
-
function groupBubbles ({ fullParams, SeriesContainerPositionMap }: {
|
352
|
+
function groupBubbles ({ _simulation, fullParams, SeriesContainerPositionMap }: {
|
353
|
+
_simulation: d3.Simulation<d3.SimulationNodeDatum, undefined>
|
331
354
|
fullParams: BubblesParams
|
332
355
|
// graphicWidth: number
|
333
356
|
// graphicHeight: number
|
334
357
|
SeriesContainerPositionMap: Map<string, ContainerPosition>
|
335
358
|
}) {
|
336
359
|
// console.log('groupBubbles')
|
337
|
-
|
360
|
+
_simulation!
|
338
361
|
// .force('x', d3.forceX().strength(fullParams.force.strength).x(graphicWidth / 2))
|
339
362
|
// .force('y', d3.forceY().strength(fullParams.force.strength).y(graphicHeight / 2))
|
340
363
|
.force('x', d3.forceX().strength(fullParams.force.strength).x((data: BubblesSimulationDatum) => {
|
@@ -344,7 +367,7 @@ function groupBubbles ({ fullParams, SeriesContainerPositionMap }: {
|
|
344
367
|
return SeriesContainerPositionMap.get(data.seriesLabel)!.centerY
|
345
368
|
}))
|
346
369
|
|
347
|
-
force!.alpha(1).restart()
|
370
|
+
// force!.alpha(1).restart()
|
348
371
|
}
|
349
372
|
|
350
373
|
function highlight ({ bubblesSelection, highlightIds, fullChartParams }: {
|
@@ -383,6 +406,8 @@ export const Bubbles = defineSeriesPlugin(pluginConfig)(({ selection, name, obse
|
|
383
406
|
|
384
407
|
const destroy$ = new Subject()
|
385
408
|
|
409
|
+
let simulation: d3.Simulation<d3.SimulationNodeDatum, undefined> | undefined
|
410
|
+
|
386
411
|
// 紀錄前一次bubble data
|
387
412
|
let LastBubbleDataMap: Map<string, BubblesDatum> = new Map()
|
388
413
|
|
@@ -401,15 +426,15 @@ export const Bubbles = defineSeriesPlugin(pluginConfig)(({ selection, name, obse
|
|
401
426
|
const bubblesData$ = combineLatest({
|
402
427
|
layout: observer.layout$,
|
403
428
|
SeriesContainerPositionMap: observer.SeriesContainerPositionMap$,
|
404
|
-
|
429
|
+
visibleComputedSortedData: observer.visibleComputedSortedData$,
|
405
430
|
scaleType: scaleType$
|
406
431
|
}).pipe(
|
407
432
|
takeUntil(destroy$),
|
408
433
|
switchMap(async (d) => d),
|
409
434
|
map(data => {
|
410
|
-
// console.log(data.
|
435
|
+
// console.log(data.visibleComputedSortedData)
|
411
436
|
return createBubblesData({
|
412
|
-
|
437
|
+
visibleComputedSortedData: data.visibleComputedSortedData,
|
413
438
|
LastBubbleDataMap,
|
414
439
|
graphicWidth: data.layout.width,
|
415
440
|
graphicHeight: data.layout.height,
|
@@ -434,41 +459,43 @@ export const Bubbles = defineSeriesPlugin(pluginConfig)(({ selection, name, obse
|
|
434
459
|
const bubblesSelection$ = combineLatest({
|
435
460
|
bubblesData: bubblesData$,
|
436
461
|
fullParams: observer.fullParams$,
|
462
|
+
fullChartParams: observer.fullChartParams$,
|
437
463
|
SeriesContainerPositionMap: observer.SeriesContainerPositionMap$,
|
438
464
|
sumSeries: sumSeries$
|
439
465
|
}).pipe(
|
440
466
|
takeUntil(destroy$),
|
441
467
|
switchMap(async (d) => d),
|
442
468
|
map(data => {
|
443
|
-
if (
|
444
|
-
|
469
|
+
if (simulation) {
|
470
|
+
// 先停止,重新計算之後再restart
|
471
|
+
simulation.stop()
|
445
472
|
}
|
446
473
|
|
447
474
|
const bubblesSelection = renderBubbles({
|
448
475
|
selection,
|
449
476
|
bubblesData: data.bubblesData,
|
450
477
|
fullParams: data.fullParams,
|
478
|
+
fullChartParams: data.fullChartParams,
|
451
479
|
sumSeries: data.sumSeries
|
452
480
|
})
|
453
481
|
|
454
|
-
|
482
|
+
simulation = createSimulation(bubblesSelection, data.fullParams)
|
455
483
|
|
456
|
-
|
484
|
+
simulation.nodes(data.bubblesData)
|
457
485
|
|
458
486
|
groupBubbles({
|
487
|
+
_simulation: simulation,
|
459
488
|
fullParams: data.fullParams,
|
460
489
|
SeriesContainerPositionMap: data.SeriesContainerPositionMap
|
461
490
|
// graphicWidth: data.layout.width,
|
462
491
|
// graphicHeight: data.layout.height
|
463
492
|
})
|
464
493
|
|
465
|
-
|
466
|
-
// force!.alphaTarget(0)
|
467
|
-
// force!.alpha(1).restart()
|
468
|
-
// }, 2000)
|
494
|
+
simulation!.alpha(1).restart()
|
469
495
|
|
470
496
|
return bubblesSelection
|
471
|
-
})
|
497
|
+
}),
|
498
|
+
shareReplay(1)
|
472
499
|
)
|
473
500
|
|
474
501
|
combineLatest({
|
@@ -552,22 +579,22 @@ export const Bubbles = defineSeriesPlugin(pluginConfig)(({ selection, name, obse
|
|
552
579
|
data: data.computedData
|
553
580
|
})
|
554
581
|
})
|
555
|
-
.call(drag() as any)
|
582
|
+
.call(drag(simulation) as any)
|
556
583
|
|
557
584
|
|
558
585
|
})
|
559
586
|
|
560
587
|
combineLatest({
|
561
588
|
bubblesSelection: bubblesSelection$,
|
562
|
-
bubblesData: bubblesData$,
|
589
|
+
// bubblesData: bubblesData$,
|
563
590
|
highlight: observer.seriesHighlight$.pipe(
|
564
591
|
map(data => data.map(d => d.id))
|
565
592
|
),
|
566
593
|
fullChartParams: observer.fullChartParams$,
|
567
|
-
fullParams: observer.fullParams$,
|
568
|
-
sumSeries: sumSeries$,
|
569
|
-
// layout: observer.layout$,
|
570
|
-
SeriesContainerPositionMap: observer.SeriesContainerPositionMap$,
|
594
|
+
// fullParams: observer.fullParams$,
|
595
|
+
// sumSeries: sumSeries$,
|
596
|
+
// // layout: observer.layout$,
|
597
|
+
// SeriesContainerPositionMap: observer.SeriesContainerPositionMap$,
|
571
598
|
}).pipe(
|
572
599
|
takeUntil(destroy$),
|
573
600
|
switchMap(async d => d)
|
@@ -598,8 +625,13 @@ export const Bubbles = defineSeriesPlugin(pluginConfig)(({ selection, name, obse
|
|
598
625
|
// }
|
599
626
|
|
600
627
|
})
|
628
|
+
|
601
629
|
|
602
630
|
return () => {
|
603
631
|
destroy$.next(undefined)
|
632
|
+
if (simulation) {
|
633
|
+
simulation.stop()
|
634
|
+
simulation = undefined
|
635
|
+
}
|
604
636
|
}
|
605
637
|
})
|
@@ -205,7 +205,7 @@ function highlight ({ pathSelection, ids, fullChartParams, arc, arcHighlight }:
|
|
205
205
|
function createEachPie (pluginName: string, context: {
|
206
206
|
containerSelection: d3.Selection<SVGGElement, any, any, unknown>
|
207
207
|
computedData$: Observable<ComputedDatumSeries[][]>
|
208
|
-
|
208
|
+
containerVisibleComputedSortedData$: Observable<ComputedDatumSeries[]>
|
209
209
|
SeriesDataMap$: Observable<Map<string, ComputedDatumSeries[]>>
|
210
210
|
fullParams$: Observable<PieParams>
|
211
211
|
fullChartParams$: Observable<ChartParams>
|
@@ -248,7 +248,7 @@ function createEachPie (pluginName: string, context: {
|
|
248
248
|
|
249
249
|
const pieData$: Observable<PieDatum[]> = new Observable(subscriber => {
|
250
250
|
combineLatest({
|
251
|
-
|
251
|
+
containerVisibleComputedSortedData: context.containerVisibleComputedSortedData$,
|
252
252
|
fullParams: context.fullParams$,
|
253
253
|
}).pipe(
|
254
254
|
takeUntil(destroy$),
|
@@ -256,7 +256,7 @@ function createEachPie (pluginName: string, context: {
|
|
256
256
|
).subscribe(data => {
|
257
257
|
// console.log('pieData', data)
|
258
258
|
const pieData: PieDatum[] = makePieData({
|
259
|
-
data: data.
|
259
|
+
data: data.containerVisibleComputedSortedData,
|
260
260
|
startAngle: data.fullParams.startAngle,
|
261
261
|
endAngle: data.fullParams.endAngle
|
262
262
|
})
|
@@ -592,7 +592,7 @@ export const Pie = defineSeriesPlugin(pluginConfig)(({ selection, name, subject,
|
|
592
592
|
// console.log('containerIndex', containerIndex)
|
593
593
|
const containerSelection = d3.select(g[containerIndex])
|
594
594
|
|
595
|
-
const
|
595
|
+
const containerVisibleComputedSortedData$ = observer.visibleComputedSortedData$.pipe(
|
596
596
|
takeUntil(destroy$),
|
597
597
|
map(data => data[containerIndex] ?? data[0])
|
598
598
|
)
|
@@ -605,7 +605,7 @@ export const Pie = defineSeriesPlugin(pluginConfig)(({ selection, name, subject,
|
|
605
605
|
unsubscribeFnArr[containerIndex] = createEachPie(pluginName, {
|
606
606
|
containerSelection: containerSelection,
|
607
607
|
computedData$: observer.computedData$,
|
608
|
-
|
608
|
+
containerVisibleComputedSortedData$: containerVisibleComputedSortedData$,
|
609
609
|
SeriesDataMap$: observer.SeriesDataMap$,
|
610
610
|
fullParams$: observer.fullParams$,
|
611
611
|
fullChartParams$: observer.fullChartParams$,
|
@@ -105,7 +105,7 @@ function createTextData ({ eventData, renderFn, textAttrs, textStyles }: {
|
|
105
105
|
function createEachPieEventTexts (pluginName: string, context: {
|
106
106
|
containerSelection: d3.Selection<SVGGElement, any, any, unknown>
|
107
107
|
computedData$: Observable<ComputedDatumSeries[][]>
|
108
|
-
|
108
|
+
containerComputedSortedData$: Observable<ComputedDatumSeries[]>
|
109
109
|
SeriesDataMap$: Observable<Map<string, ComputedDatumSeries[]>>
|
110
110
|
fullParams$: Observable<PieEventTextsParams>
|
111
111
|
fullChartParams$: Observable<ChartParams>
|
@@ -252,7 +252,7 @@ export const PieEventTexts = defineSeriesPlugin(pluginConfig)(({ selection, name
|
|
252
252
|
|
253
253
|
const containerSelection = d3.select(g[containerIndex])
|
254
254
|
|
255
|
-
const
|
255
|
+
const containerComputedSortedData$ = observer.computedSortedData$.pipe(
|
256
256
|
takeUntil(destroy$),
|
257
257
|
map(data => data[containerIndex] ?? data[0])
|
258
258
|
)
|
@@ -265,7 +265,7 @@ export const PieEventTexts = defineSeriesPlugin(pluginConfig)(({ selection, name
|
|
265
265
|
unsubscribeFnArr[containerIndex] = createEachPieEventTexts(pluginName, {
|
266
266
|
containerSelection: containerSelection,
|
267
267
|
computedData$: observer.computedData$,
|
268
|
-
|
268
|
+
containerComputedSortedData$: containerComputedSortedData$,
|
269
269
|
SeriesDataMap$: observer.SeriesDataMap$,
|
270
270
|
fullParams$: observer.fullParams$,
|
271
271
|
fullChartParams$: observer.fullChartParams$,
|
@@ -447,7 +447,7 @@ function highlight ({ textSelection, lineSelection, ids, fullChartParams }: {
|
|
447
447
|
function createEachPieLabel (pluginName: string, context: {
|
448
448
|
containerSelection: d3.Selection<SVGGElement, any, any, unknown>
|
449
449
|
// computedData$: Observable<ComputedDatumSeries[][]>
|
450
|
-
|
450
|
+
containerVisibleComputedSortedData$: Observable<ComputedDatumSeries[]>
|
451
451
|
// SeriesDataMap$: Observable<Map<string, ComputedDatumSeries[]>>
|
452
452
|
fullParams$: Observable<PieLabelsParams>
|
453
453
|
fullChartParams$: Observable<ChartParams>
|
@@ -488,7 +488,7 @@ function createEachPieLabel (pluginName: string, context: {
|
|
488
488
|
|
489
489
|
combineLatest({
|
490
490
|
shorterSideWith: shorterSideWith$,
|
491
|
-
|
491
|
+
containerVisibleComputedSortedData: context.containerVisibleComputedSortedData$,
|
492
492
|
fullParams: context.fullParams$,
|
493
493
|
fullChartParams: context.fullChartParams$,
|
494
494
|
textSizePx: context.textSizePx$,
|
@@ -516,7 +516,7 @@ function createEachPieLabel (pluginName: string, context: {
|
|
516
516
|
})
|
517
517
|
|
518
518
|
const pieData = makePieData({
|
519
|
-
data: data.
|
519
|
+
data: data.containerVisibleComputedSortedData,
|
520
520
|
startAngle: data.fullParams.startAngle,
|
521
521
|
endAngle: data.fullParams.endAngle
|
522
522
|
})
|
@@ -608,7 +608,7 @@ export const PieLabels = defineSeriesPlugin(pluginConfig)(({ selection, observer
|
|
608
608
|
|
609
609
|
const containerSelection = d3.select(g[containerIndex])
|
610
610
|
|
611
|
-
const
|
611
|
+
const containerVisibleComputedSortedData$ = observer.visibleComputedSortedData$.pipe(
|
612
612
|
takeUntil(destroy$),
|
613
613
|
map(data => data[containerIndex] ?? data[0])
|
614
614
|
)
|
@@ -621,7 +621,7 @@ export const PieLabels = defineSeriesPlugin(pluginConfig)(({ selection, observer
|
|
621
621
|
unsubscribeFnArr[containerIndex] = createEachPieLabel(pluginName, {
|
622
622
|
containerSelection: containerSelection,
|
623
623
|
// computedData$: observer.computedData$,
|
624
|
-
|
624
|
+
containerVisibleComputedSortedData$: containerVisibleComputedSortedData$,
|
625
625
|
// SeriesDataMap$: observer.SeriesDataMap$,
|
626
626
|
fullParams$: observer.fullParams$,
|
627
627
|
fullChartParams$: observer.fullChartParams$,
|
@@ -213,8 +213,8 @@ function createEachRose (pluginName: string, context: {
|
|
213
213
|
containerSelection: d3.Selection<SVGGElement, any, any, unknown>
|
214
214
|
computedData$: Observable<ComputedDatumSeries[][]>
|
215
215
|
visibleComputedData$: Observable<ComputedDatumSeries[][]>
|
216
|
-
|
217
|
-
|
216
|
+
visibleComputedSortedData$: Observable<ComputedDatumSeries[][]>
|
217
|
+
containerVisibleComputedSortedData$: Observable<ComputedDatumSeries[]>
|
218
218
|
SeriesDataMap$: Observable<Map<string, ComputedDatumSeries[]>>
|
219
219
|
fullParams$: Observable<RoseParams>
|
220
220
|
fullChartParams$: Observable<ChartParams>
|
@@ -235,14 +235,14 @@ function createEachRose (pluginName: string, context: {
|
|
235
235
|
)
|
236
236
|
|
237
237
|
const pieData$: Observable<PieDatum[]> = combineLatest({
|
238
|
-
|
238
|
+
containerVisibleComputedSortedData: context.containerVisibleComputedSortedData$,
|
239
239
|
fullParams: context.fullParams$,
|
240
240
|
}).pipe(
|
241
241
|
takeUntil(destroy$),
|
242
242
|
switchMap(async (d) => d),
|
243
243
|
map(data => {
|
244
|
-
const eachAngle = roseEndAngle / data.
|
245
|
-
return data.
|
244
|
+
const eachAngle = roseEndAngle / data.containerVisibleComputedSortedData.length
|
245
|
+
return data.containerVisibleComputedSortedData.map((d, i) => {
|
246
246
|
return {
|
247
247
|
id: d.id,
|
248
248
|
data: d,
|
@@ -263,13 +263,13 @@ function createEachRose (pluginName: string, context: {
|
|
263
263
|
distinctUntilChanged()
|
264
264
|
)
|
265
265
|
|
266
|
-
const maxValue$ = context.
|
266
|
+
const maxValue$ = context.visibleComputedSortedData$.pipe(
|
267
267
|
map(data => Math.max(...data.flat().map(d => d.value))),
|
268
268
|
distinctUntilChanged()
|
269
269
|
)
|
270
270
|
|
271
|
-
// context.
|
272
|
-
// console.log('
|
271
|
+
// context.visibleComputedSortedData$.subscribe(data => {
|
272
|
+
// console.log('visibleComputedSortedData$', data)
|
273
273
|
// })
|
274
274
|
|
275
275
|
const tweenArc$ = combineLatest({
|
@@ -483,7 +483,7 @@ export const Rose = defineSeriesPlugin(pluginConfig)(({ selection, name, subject
|
|
483
483
|
seriesCenterSelection.each((d, containerIndex, g) => {
|
484
484
|
const containerSelection = d3.select(g[containerIndex])
|
485
485
|
|
486
|
-
const
|
486
|
+
const containerVisibleComputedSortedData$ = observer.visibleComputedSortedData$.pipe(
|
487
487
|
takeUntil(destroy$),
|
488
488
|
map(data => JSON.parse(JSON.stringify(data[containerIndex] ?? data[0])))
|
489
489
|
)
|
@@ -497,8 +497,8 @@ export const Rose = defineSeriesPlugin(pluginConfig)(({ selection, name, subject
|
|
497
497
|
containerSelection: containerSelection,
|
498
498
|
computedData$: observer.computedData$,
|
499
499
|
visibleComputedData$: observer.visibleComputedData$,
|
500
|
-
|
501
|
-
|
500
|
+
visibleComputedSortedData$: observer.visibleComputedSortedData$,
|
501
|
+
containerVisibleComputedSortedData$: containerVisibleComputedSortedData$,
|
502
502
|
SeriesDataMap$: observer.SeriesDataMap$,
|
503
503
|
fullParams$: observer.fullParams$,
|
504
504
|
fullChartParams$: observer.fullChartParams$,
|