@orbcharts/plugins-basic 3.0.0-alpha.42 → 3.0.0-alpha.43

Sign up to get free protection for your applications and to get access to all the features.
Files changed (84) hide show
  1. package/LICENSE +200 -200
  2. package/dist/orbcharts-plugins-basic.es.js +5477 -5426
  3. package/dist/orbcharts-plugins-basic.umd.js +8 -8
  4. package/dist/src/base/BaseBarStack.d.ts +1 -1
  5. package/dist/src/base/BaseBars.d.ts +1 -1
  6. package/dist/src/base/BaseBarsTriangle.d.ts +1 -1
  7. package/dist/src/base/BaseDots.d.ts +1 -1
  8. package/dist/src/base/BaseLineAreas.d.ts +1 -1
  9. package/dist/src/base/BaseLines.d.ts +1 -1
  10. package/dist/src/multiGrid/defaults.d.ts +2 -1
  11. package/dist/src/multiGrid/index.d.ts +1 -0
  12. package/dist/src/multiGrid/plugins/MultiLineAreas.d.ts +1 -0
  13. package/dist/src/multiGrid/types.d.ts +4 -4
  14. package/package.json +42 -42
  15. package/src/base/BaseBarStack.ts +881 -879
  16. package/src/base/BaseBars.ts +750 -748
  17. package/src/base/BaseBarsTriangle.ts +659 -657
  18. package/src/base/BaseDots.ts +639 -637
  19. package/src/base/BaseGroupAxis.ts +496 -496
  20. package/src/base/BaseLegend.ts +636 -636
  21. package/src/base/BaseLineAreas.ts +621 -624
  22. package/src/base/BaseLines.ts +692 -695
  23. package/src/base/BaseValueAxis.ts +479 -479
  24. package/src/base/types.ts +2 -2
  25. package/src/grid/defaults.ts +121 -121
  26. package/src/grid/gridObservables.ts +263 -263
  27. package/src/grid/index.ts +15 -15
  28. package/src/grid/plugins/BarStack.ts +37 -37
  29. package/src/grid/plugins/Bars.ts +37 -37
  30. package/src/grid/plugins/BarsDiverging.ts +39 -39
  31. package/src/grid/plugins/BarsTriangle.ts +34 -34
  32. package/src/grid/plugins/Dots.ts +35 -35
  33. package/src/grid/plugins/GridLegend.ts +58 -58
  34. package/src/grid/plugins/GroupAux.ts +643 -643
  35. package/src/grid/plugins/GroupAxis.ts +30 -30
  36. package/src/grid/plugins/LineAreas.ts +36 -36
  37. package/src/grid/plugins/Lines.ts +35 -35
  38. package/src/grid/plugins/ScalingArea.ts +174 -174
  39. package/src/grid/plugins/ValueAxis.ts +31 -31
  40. package/src/grid/plugins/ValueStackAxis.ts +70 -70
  41. package/src/grid/types.ts +120 -120
  42. package/src/index.ts +9 -9
  43. package/src/multiGrid/defaults.ts +147 -140
  44. package/src/multiGrid/index.ts +11 -10
  45. package/src/multiGrid/multiGridObservables.ts +289 -278
  46. package/src/multiGrid/plugins/MultiBarStack.ts +60 -60
  47. package/src/multiGrid/plugins/MultiBars.ts +59 -59
  48. package/src/multiGrid/plugins/MultiBarsTriangle.ts +58 -58
  49. package/src/multiGrid/plugins/MultiDots.ts +58 -58
  50. package/src/multiGrid/plugins/MultiGridLegend.ts +88 -88
  51. package/src/multiGrid/plugins/MultiGroupAxis.ts +53 -53
  52. package/src/multiGrid/plugins/MultiLineAreas.ts +59 -0
  53. package/src/multiGrid/plugins/MultiLines.ts +58 -58
  54. package/src/multiGrid/plugins/MultiValueAxis.ts +53 -53
  55. package/src/multiGrid/plugins/OverlappingValueAxes.ts +164 -165
  56. package/src/multiGrid/types.ts +67 -67
  57. package/src/noneData/defaults.ts +61 -61
  58. package/src/noneData/index.ts +3 -3
  59. package/src/noneData/plugins/Container.ts +10 -10
  60. package/src/noneData/plugins/Tooltip.ts +304 -304
  61. package/src/noneData/types.ts +26 -26
  62. package/src/series/defaults.ts +99 -99
  63. package/src/series/index.ts +6 -6
  64. package/src/series/plugins/Bubbles.ts +551 -549
  65. package/src/series/plugins/Pie.ts +600 -598
  66. package/src/series/plugins/PieEventTexts.ts +194 -194
  67. package/src/series/plugins/PieLabels.ts +288 -285
  68. package/src/series/plugins/SeriesLegend.ts +58 -58
  69. package/src/series/seriesUtils.ts +50 -50
  70. package/src/series/types.ts +67 -67
  71. package/src/tree/defaults.ts +22 -22
  72. package/src/tree/index.ts +3 -3
  73. package/src/tree/plugins/TreeLegend.ts +58 -58
  74. package/src/tree/plugins/TreeMap.ts +302 -300
  75. package/src/tree/types.ts +23 -23
  76. package/src/utils/commonUtils.ts +21 -21
  77. package/src/utils/d3Graphics.ts +124 -124
  78. package/src/utils/d3Utils.ts +73 -73
  79. package/src/utils/observables.ts +14 -14
  80. package/src/utils/orbchartsUtils.ts +100 -100
  81. package/tsconfig.dev.json +16 -16
  82. package/tsconfig.json +13 -13
  83. package/tsconfig.prod.json +13 -13
  84. package/vite.config.js +49 -49
@@ -1,285 +1,288 @@
1
- import * as d3 from 'd3'
2
- import {
3
- combineLatest,
4
- switchMap,
5
- first,
6
- takeUntil,
7
- Subject,
8
- BehaviorSubject } from 'rxjs'
9
- import {
10
- defineSeriesPlugin } from '@orbcharts/core'
11
- import type {
12
- ChartParams } from '@orbcharts/core'
13
- import type { PieLabelsParams } from '../types'
14
- import type { PieDatum } from '../seriesUtils'
15
- import { DEFAULT_PIE_LABELS_PARAMS } from '../defaults'
16
- import { makePieData } from '../seriesUtils'
17
- import { makeD3Arc } from '../../utils/d3Utils'
18
- import { getDatumColor, getClassName } from '../../utils/orbchartsUtils'
19
-
20
- interface RenderDatum {
21
- pieDatum: PieDatum
22
- arcIndex: number
23
- arcLabel: string
24
- x: number
25
- y: number
26
- mouseoverX: number
27
- mouseoverY: number
28
- }
29
-
30
- const pluginName = 'PieLabels'
31
- const textClassName = getClassName(pluginName, 'text')
32
-
33
- function makeRenderData (pieData: PieDatum[], arc: d3.Arc<any, d3.DefaultArcObject>, mouseoverArc: d3.Arc<any, d3.DefaultArcObject>, centroid: number): RenderDatum[] {
34
- return pieData
35
- .map((d, i) => {
36
- const [_x, _y] = arc!.centroid(d as any)
37
- const [_mouseoverX, _mouseoverY] = mouseoverArc!.centroid(d as any)
38
- return {
39
- pieDatum: d,
40
- arcIndex: i,
41
- arcLabel: d.data.label,
42
- x: _x * centroid!,
43
- y: _y * centroid!,
44
- mouseoverX: _mouseoverX * centroid!,
45
- mouseoverY: _mouseoverY * centroid!
46
- }
47
- })
48
- .filter(d => d.pieDatum.data.visible)
49
- }
50
-
51
- // 繪製圓餅圖
52
- function renderLabel (selection: d3.Selection<SVGGElement, undefined, any, any>, data: RenderDatum[], pluginParams: PieLabelsParams, fullChartParams: ChartParams) {
53
- // console.log(data)
54
- // let update = this.gSelection.selectAll('g').data(pieData)
55
- let update: d3.Selection<SVGPathElement, RenderDatum, any, any> = selection
56
- .selectAll<SVGPathElement, RenderDatum>('text')
57
- .data(data, d => d.pieDatum.id)
58
- let enter = update.enter()
59
- .append<SVGPathElement>('text')
60
- .classed(textClassName, true)
61
- let exit = update.exit()
62
-
63
- enter
64
- .append('text')
65
-
66
- const labelSelection = update.merge(enter)
67
- labelSelection
68
- .attr('font-weight', 'bold')
69
- .attr('text-anchor', 'middle')
70
- .style('dominant-baseline', 'middle')
71
- // .style('pointer-events', 'none')
72
- .style('cursor', d => fullChartParams.highlightTarget && fullChartParams.highlightTarget != 'none'
73
- ? 'pointer'
74
- : 'none')
75
- // .text((d, i) => d.arcLabel)
76
- .text(d => pluginParams.labelFn(d.pieDatum.data))
77
- .attr('font-size', fullChartParams.styles.textSize)
78
- .attr('fill', (d, i) => getDatumColor({ datum: d.pieDatum.data, colorType: pluginParams.labelColorType, fullChartParams }))
79
- .transition()
80
- .attr('transform', (d) => {
81
- // console.log('transform', d)
82
- return 'translate(' + d.x + ',' + d.y + ')'
83
- })
84
- // .on('end', () => initHighlight({ labelSelection, data, fullChartParams }))
85
- exit.remove()
86
-
87
- // 如無新增資料則不用等動畫
88
- // if (enter.size() == 0) {
89
- // this.initHighlight()
90
- // }
91
-
92
- return labelSelection
93
- }
94
-
95
- // function initHighlight ({ labelSelection, data, fullChartParams }: {
96
- // labelSelection: (d3.Selection<SVGPathElement, RenderDatum, any, any>)
97
- // data: RenderDatum[]
98
- // fullChartParams: ChartParams
99
- // }) {
100
- // removeHighlight({ labelSelection })
101
- // // if (fullParams.highlightSeriesId || fullParams.highlightDatumId) {
102
- // highlight({
103
- // labelSelection,
104
- // data,
105
- // id: fullChartParams.highlightDefault,
106
- // label: fullChartParams.highlightDefault,
107
- // fullChartParams
108
- // })
109
- // // }
110
- // }
111
-
112
- function highlight ({ labelSelection, ids, fullChartParams }: {
113
- labelSelection: (d3.Selection<SVGPathElement, RenderDatum, any, any>)
114
- ids: string[]
115
- fullChartParams: ChartParams
116
- }) {
117
- labelSelection.interrupt('highlight')
118
-
119
- if (!ids.length) {
120
- labelSelection
121
- .transition()
122
- .duration(200)
123
- .attr('transform', (d) => {
124
- return 'translate(' + d.x + ',' + d.y + ')'
125
- })
126
- .style('opacity', 1)
127
- return
128
- }
129
-
130
- labelSelection.each((d, i, n) => {
131
- const segment = d3.select<SVGPathElement, RenderDatum>(n[i])
132
-
133
- if (ids.includes(d.pieDatum.id)) {
134
- segment
135
- .style('opacity', 1)
136
- .transition()
137
- .duration(200)
138
- .attr('transform', (d) => {
139
- return 'translate(' + d.mouseoverX + ',' + d.mouseoverY + ')'
140
- })
141
- } else {
142
- segment
143
- .style('opacity', fullChartParams.styles.unhighlightedOpacity)
144
- .transition()
145
- .duration(200)
146
- .attr('transform', (d) => {
147
- return 'translate(' + d.x + ',' + d.y + ')'
148
- })
149
- }
150
- })
151
- }
152
-
153
-
154
- // function removeHighlight ({ labelSelection }: {
155
- // labelSelection: (d3.Selection<SVGPathElement, RenderDatum, any, any> | undefined)
156
- // }) {
157
- // if (!labelSelection) {
158
- // return
159
- // }
160
-
161
- // // 取消放大
162
- // labelSelection
163
- // .transition()
164
- // .duration(200)
165
- // .attr('transform', (d) => {
166
- // return 'translate(' + d.x + ',' + d.y + ')'
167
- // })
168
- // .style('opacity', 1)
169
-
170
- // }
171
-
172
-
173
- export const PieLabels = defineSeriesPlugin(pluginName, DEFAULT_PIE_LABELS_PARAMS)(({ selection, observer, subject }) => {
174
-
175
- const destroy$ = new Subject()
176
-
177
- const graphicSelection: d3.Selection<SVGGElement, any, any, any> = selection.append('g')
178
- let labelSelection$: Subject<d3.Selection<SVGPathElement, RenderDatum, any, any>> = new Subject()
179
- let renderData: RenderDatum[] = []
180
- // let highlightTarget: HighlightTarget | undefined
181
- // let fullChartParams: ChartParams | undefined
182
-
183
- observer.layout$
184
- .pipe(
185
- first()
186
- )
187
- .subscribe(size => {
188
- selection
189
- .attr('transform', `translate(${size.width / 2}, ${size.height / 2})`)
190
- observer.layout$
191
- .pipe(
192
- takeUntil(destroy$)
193
- )
194
- .subscribe(size => {
195
- selection
196
- .transition()
197
- .attr('transform', `translate(${size.width / 2}, ${size.height / 2})`)
198
- })
199
- })
200
-
201
-
202
-
203
- // combineLatest({
204
- // event: store.event$,
205
- // fullChartParams: fullChartParams$
206
- // }).pipe(
207
- // // 轉換後會退訂前一個未完成的訂閱事件,因此可以取到「同時間」最後一次的訂閱事件
208
- // switchMap(async (d) => d),
209
- // ).subscribe(d => {
210
- // if (d.event.eventName === 'mouseover' && d.event.datum) {
211
- // highlight({
212
- // labelSelection,
213
- // data: renderData,
214
- // id: d.fullChartParams.highlightTarget === 'datum' ? d.event.datum!.id : undefined,
215
- // label: d.fullChartParams.highlightTarget === 'series' ? d.event.datum!.label : undefined,
216
- // fullChartParams: d.fullChartParams
217
- // })
218
- // } else if (d.event.eventName === 'mouseout') {
219
- // removeHighlight({ labelSelection })
220
- // }
221
- // })
222
-
223
- combineLatest({
224
- layout: observer.layout$,
225
- computedData: observer.computedData$,
226
- fullParams: observer.fullParams$,
227
- fullChartParams: observer.fullChartParams$
228
- }).pipe(
229
- takeUntil(destroy$),
230
- // 轉換後會退訂前一個未完成的訂閱事件,因此可以取到「同時間」最後一次的訂閱事件
231
- switchMap(async (d) => d),
232
- ).subscribe(data => {
233
-
234
- const shorterSideWith = data.layout.width < data.layout.height ? data.layout.width : data.layout.height
235
-
236
- // 弧產生器 (d3.arc())
237
- const arc = makeD3Arc({
238
- axisWidth: shorterSideWith,
239
- innerRadius: 0,
240
- outerRadius: data.fullParams.outerRadius,
241
- padAngle: 0,
242
- cornerRadius: 0
243
- })
244
-
245
- const arcMouseover = makeD3Arc({
246
- axisWidth: shorterSideWith,
247
- innerRadius: 0,
248
- outerRadius: data.fullParams.outerMouseoverRadius, // 外半徑變化
249
- padAngle: 0,
250
- cornerRadius: 0
251
- })
252
-
253
- const pieData = makePieData({
254
- computedDataSeries: data.computedData,
255
- startAngle: data.fullParams.startAngle,
256
- endAngle: data.fullParams.endAngle
257
- })
258
-
259
- renderData = makeRenderData(pieData, arc, arcMouseover, data.fullParams.labelCentroid)
260
-
261
- const labelSelection = renderLabel(graphicSelection, renderData, data.fullParams, data.fullChartParams)
262
-
263
- labelSelection$.next(labelSelection)
264
-
265
- })
266
-
267
- combineLatest({
268
- labelSelection: labelSelection$,
269
- highlight: observer.seriesHighlight$,
270
- fullChartParams: observer.fullChartParams$,
271
- }).pipe(
272
- takeUntil(destroy$),
273
- switchMap(async d => d)
274
- ).subscribe(data => {
275
- highlight({
276
- labelSelection: data.labelSelection,
277
- ids: data.highlight,
278
- fullChartParams: data.fullChartParams,
279
- })
280
- })
281
-
282
- return () => {
283
- destroy$.next(undefined)
284
- }
285
- })
1
+ import * as d3 from 'd3'
2
+ import {
3
+ combineLatest,
4
+ switchMap,
5
+ first,
6
+ map,
7
+ takeUntil,
8
+ Subject,
9
+ BehaviorSubject } from 'rxjs'
10
+ import {
11
+ defineSeriesPlugin } from '@orbcharts/core'
12
+ import type {
13
+ ChartParams } from '@orbcharts/core'
14
+ import type { PieLabelsParams } from '../types'
15
+ import type { PieDatum } from '../seriesUtils'
16
+ import { DEFAULT_PIE_LABELS_PARAMS } from '../defaults'
17
+ import { makePieData } from '../seriesUtils'
18
+ import { makeD3Arc } from '../../utils/d3Utils'
19
+ import { getDatumColor, getClassName } from '../../utils/orbchartsUtils'
20
+
21
+ interface RenderDatum {
22
+ pieDatum: PieDatum
23
+ arcIndex: number
24
+ arcLabel: string
25
+ x: number
26
+ y: number
27
+ mouseoverX: number
28
+ mouseoverY: number
29
+ }
30
+
31
+ const pluginName = 'PieLabels'
32
+ const textClassName = getClassName(pluginName, 'text')
33
+
34
+ function makeRenderData (pieData: PieDatum[], arc: d3.Arc<any, d3.DefaultArcObject>, mouseoverArc: d3.Arc<any, d3.DefaultArcObject>, centroid: number): RenderDatum[] {
35
+ return pieData
36
+ .map((d, i) => {
37
+ const [_x, _y] = arc!.centroid(d as any)
38
+ const [_mouseoverX, _mouseoverY] = mouseoverArc!.centroid(d as any)
39
+ return {
40
+ pieDatum: d,
41
+ arcIndex: i,
42
+ arcLabel: d.data.label,
43
+ x: _x * centroid!,
44
+ y: _y * centroid!,
45
+ mouseoverX: _mouseoverX * centroid!,
46
+ mouseoverY: _mouseoverY * centroid!
47
+ }
48
+ })
49
+ .filter(d => d.pieDatum.data.visible)
50
+ }
51
+
52
+ // 繪製圓餅圖
53
+ function renderLabel (selection: d3.Selection<SVGGElement, undefined, any, any>, data: RenderDatum[], pluginParams: PieLabelsParams, fullChartParams: ChartParams) {
54
+ // console.log(data)
55
+ // let update = this.gSelection.selectAll('g').data(pieData)
56
+ let update: d3.Selection<SVGPathElement, RenderDatum, any, any> = selection
57
+ .selectAll<SVGPathElement, RenderDatum>('text')
58
+ .data(data, d => d.pieDatum.id)
59
+ let enter = update.enter()
60
+ .append<SVGPathElement>('text')
61
+ .classed(textClassName, true)
62
+ let exit = update.exit()
63
+
64
+ enter
65
+ .append('text')
66
+
67
+ const labelSelection = update.merge(enter)
68
+ labelSelection
69
+ .attr('font-weight', 'bold')
70
+ .attr('text-anchor', 'middle')
71
+ .style('dominant-baseline', 'middle')
72
+ // .style('pointer-events', 'none')
73
+ .style('cursor', d => fullChartParams.highlightTarget && fullChartParams.highlightTarget != 'none'
74
+ ? 'pointer'
75
+ : 'none')
76
+ // .text((d, i) => d.arcLabel)
77
+ .text(d => pluginParams.labelFn(d.pieDatum.data))
78
+ .attr('font-size', fullChartParams.styles.textSize)
79
+ .attr('fill', (d, i) => getDatumColor({ datum: d.pieDatum.data, colorType: pluginParams.labelColorType, fullChartParams }))
80
+ .transition()
81
+ .attr('transform', (d) => {
82
+ // console.log('transform', d)
83
+ return 'translate(' + d.x + ',' + d.y + ')'
84
+ })
85
+ // .on('end', () => initHighlight({ labelSelection, data, fullChartParams }))
86
+ exit.remove()
87
+
88
+ // 如無新增資料則不用等動畫
89
+ // if (enter.size() == 0) {
90
+ // this.initHighlight()
91
+ // }
92
+
93
+ return labelSelection
94
+ }
95
+
96
+ // function initHighlight ({ labelSelection, data, fullChartParams }: {
97
+ // labelSelection: (d3.Selection<SVGPathElement, RenderDatum, any, any>)
98
+ // data: RenderDatum[]
99
+ // fullChartParams: ChartParams
100
+ // }) {
101
+ // removeHighlight({ labelSelection })
102
+ // // if (fullParams.highlightSeriesId || fullParams.highlightDatumId) {
103
+ // highlight({
104
+ // labelSelection,
105
+ // data,
106
+ // id: fullChartParams.highlightDefault,
107
+ // label: fullChartParams.highlightDefault,
108
+ // fullChartParams
109
+ // })
110
+ // // }
111
+ // }
112
+
113
+ function highlight ({ labelSelection, ids, fullChartParams }: {
114
+ labelSelection: (d3.Selection<SVGPathElement, RenderDatum, any, any>)
115
+ ids: string[]
116
+ fullChartParams: ChartParams
117
+ }) {
118
+ labelSelection.interrupt('highlight')
119
+
120
+ if (!ids.length) {
121
+ labelSelection
122
+ .transition()
123
+ .duration(200)
124
+ .attr('transform', (d) => {
125
+ return 'translate(' + d.x + ',' + d.y + ')'
126
+ })
127
+ .style('opacity', 1)
128
+ return
129
+ }
130
+
131
+ labelSelection.each((d, i, n) => {
132
+ const segment = d3.select<SVGPathElement, RenderDatum>(n[i])
133
+
134
+ if (ids.includes(d.pieDatum.id)) {
135
+ segment
136
+ .style('opacity', 1)
137
+ .transition()
138
+ .duration(200)
139
+ .attr('transform', (d) => {
140
+ return 'translate(' + d.mouseoverX + ',' + d.mouseoverY + ')'
141
+ })
142
+ } else {
143
+ segment
144
+ .style('opacity', fullChartParams.styles.unhighlightedOpacity)
145
+ .transition()
146
+ .duration(200)
147
+ .attr('transform', (d) => {
148
+ return 'translate(' + d.x + ',' + d.y + ')'
149
+ })
150
+ }
151
+ })
152
+ }
153
+
154
+
155
+ // function removeHighlight ({ labelSelection }: {
156
+ // labelSelection: (d3.Selection<SVGPathElement, RenderDatum, any, any> | undefined)
157
+ // }) {
158
+ // if (!labelSelection) {
159
+ // return
160
+ // }
161
+
162
+ // // 取消放大
163
+ // labelSelection
164
+ // .transition()
165
+ // .duration(200)
166
+ // .attr('transform', (d) => {
167
+ // return 'translate(' + d.x + ',' + d.y + ')'
168
+ // })
169
+ // .style('opacity', 1)
170
+
171
+ // }
172
+
173
+
174
+ export const PieLabels = defineSeriesPlugin(pluginName, DEFAULT_PIE_LABELS_PARAMS)(({ selection, observer, subject }) => {
175
+
176
+ const destroy$ = new Subject()
177
+
178
+ const graphicSelection: d3.Selection<SVGGElement, any, any, any> = selection.append('g')
179
+ let labelSelection$: Subject<d3.Selection<SVGPathElement, RenderDatum, any, any>> = new Subject()
180
+ let renderData: RenderDatum[] = []
181
+ // let highlightTarget: HighlightTarget | undefined
182
+ // let fullChartParams: ChartParams | undefined
183
+
184
+ observer.layout$
185
+ .pipe(
186
+ first()
187
+ )
188
+ .subscribe(size => {
189
+ selection
190
+ .attr('transform', `translate(${size.width / 2}, ${size.height / 2})`)
191
+ observer.layout$
192
+ .pipe(
193
+ takeUntil(destroy$)
194
+ )
195
+ .subscribe(size => {
196
+ selection
197
+ .transition()
198
+ .attr('transform', `translate(${size.width / 2}, ${size.height / 2})`)
199
+ })
200
+ })
201
+
202
+
203
+
204
+ // combineLatest({
205
+ // event: store.event$,
206
+ // fullChartParams: fullChartParams$
207
+ // }).pipe(
208
+ // // 轉換後會退訂前一個未完成的訂閱事件,因此可以取到「同時間」最後一次的訂閱事件
209
+ // switchMap(async (d) => d),
210
+ // ).subscribe(d => {
211
+ // if (d.event.eventName === 'mouseover' && d.event.datum) {
212
+ // highlight({
213
+ // labelSelection,
214
+ // data: renderData,
215
+ // id: d.fullChartParams.highlightTarget === 'datum' ? d.event.datum!.id : undefined,
216
+ // label: d.fullChartParams.highlightTarget === 'series' ? d.event.datum!.label : undefined,
217
+ // fullChartParams: d.fullChartParams
218
+ // })
219
+ // } else if (d.event.eventName === 'mouseout') {
220
+ // removeHighlight({ labelSelection })
221
+ // }
222
+ // })
223
+
224
+ combineLatest({
225
+ layout: observer.layout$,
226
+ computedData: observer.computedData$,
227
+ fullParams: observer.fullParams$,
228
+ fullChartParams: observer.fullChartParams$
229
+ }).pipe(
230
+ takeUntil(destroy$),
231
+ // 轉換後會退訂前一個未完成的訂閱事件,因此可以取到「同時間」最後一次的訂閱事件
232
+ switchMap(async (d) => d),
233
+ ).subscribe(data => {
234
+
235
+ const shorterSideWith = data.layout.width < data.layout.height ? data.layout.width : data.layout.height
236
+
237
+ // 弧產生器 (d3.arc())
238
+ const arc = makeD3Arc({
239
+ axisWidth: shorterSideWith,
240
+ innerRadius: 0,
241
+ outerRadius: data.fullParams.outerRadius,
242
+ padAngle: 0,
243
+ cornerRadius: 0
244
+ })
245
+
246
+ const arcMouseover = makeD3Arc({
247
+ axisWidth: shorterSideWith,
248
+ innerRadius: 0,
249
+ outerRadius: data.fullParams.outerMouseoverRadius, // 外半徑變化
250
+ padAngle: 0,
251
+ cornerRadius: 0
252
+ })
253
+
254
+ const pieData = makePieData({
255
+ computedDataSeries: data.computedData,
256
+ startAngle: data.fullParams.startAngle,
257
+ endAngle: data.fullParams.endAngle
258
+ })
259
+
260
+ renderData = makeRenderData(pieData, arc, arcMouseover, data.fullParams.labelCentroid)
261
+
262
+ const labelSelection = renderLabel(graphicSelection, renderData, data.fullParams, data.fullChartParams)
263
+
264
+ labelSelection$.next(labelSelection)
265
+
266
+ })
267
+
268
+ combineLatest({
269
+ labelSelection: labelSelection$,
270
+ highlight: observer.seriesHighlight$.pipe(
271
+ map(data => data.map(d => d.id))
272
+ ),
273
+ fullChartParams: observer.fullChartParams$,
274
+ }).pipe(
275
+ takeUntil(destroy$),
276
+ switchMap(async d => d)
277
+ ).subscribe(data => {
278
+ highlight({
279
+ labelSelection: data.labelSelection,
280
+ ids: data.highlight,
281
+ fullChartParams: data.fullChartParams,
282
+ })
283
+ })
284
+
285
+ return () => {
286
+ destroy$.next(undefined)
287
+ }
288
+ })