@orbcharts/plugins-basic 3.0.8 → 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 (120) hide show
  1. package/LICENSE +200 -200
  2. package/dist/orbcharts-plugins-basic.es.js +6177 -6004
  3. package/dist/orbcharts-plugins-basic.umd.js +44 -44
  4. package/dist/src/series/defaults.d.ts +2 -1
  5. package/dist/src/series/index.d.ts +1 -0
  6. package/dist/src/series/plugins/Indicator.d.ts +3 -0
  7. package/lib/core-types.ts +7 -7
  8. package/lib/core.ts +6 -6
  9. package/lib/gridObservables.ts +6 -6
  10. package/lib/plugins-basic-types.ts +6 -6
  11. package/package.json +48 -48
  12. package/src/base/BaseBars.ts +765 -765
  13. package/src/base/BaseBarsTriangle.ts +676 -676
  14. package/src/base/BaseDots.ts +464 -464
  15. package/src/base/BaseGroupAxis.ts +691 -691
  16. package/src/base/BaseLegend.ts +684 -684
  17. package/src/base/BaseLineAreas.ts +629 -629
  18. package/src/base/BaseLines.ts +706 -706
  19. package/src/base/BaseOrdinalBubbles.ts +729 -729
  20. package/src/base/BaseRacingBars.ts +582 -582
  21. package/src/base/BaseRacingLabels.ts +404 -404
  22. package/src/base/BaseRacingValueLabels.ts +403 -403
  23. package/src/base/BaseStackedBars.ts +793 -793
  24. package/src/base/BaseTooltip.ts +408 -408
  25. package/src/base/BaseValueAxis.ts +600 -600
  26. package/src/base/BaseXAxis.ts +427 -427
  27. package/src/base/BaseXZoom.ts +241 -241
  28. package/src/base/BaseYAxis.ts +389 -389
  29. package/src/base/types.ts +2 -2
  30. package/src/const.ts +30 -30
  31. package/src/grid/defaults.ts +213 -213
  32. package/src/grid/gridObservables.ts +635 -635
  33. package/src/grid/index.ts +16 -16
  34. package/src/grid/plugins/Bars.ts +69 -69
  35. package/src/grid/plugins/BarsPN.ts +66 -66
  36. package/src/grid/plugins/BarsTriangle.ts +73 -73
  37. package/src/grid/plugins/Dots.ts +68 -68
  38. package/src/grid/plugins/GridLegend.ts +107 -107
  39. package/src/grid/plugins/GridTooltip.ts +66 -66
  40. package/src/grid/plugins/GroupAux.ts +1095 -1095
  41. package/src/grid/plugins/GroupAxis.ts +73 -73
  42. package/src/grid/plugins/GroupZoom.ts +218 -218
  43. package/src/grid/plugins/LineAreas.ts +65 -65
  44. package/src/grid/plugins/Lines.ts +59 -59
  45. package/src/grid/plugins/StackedBars.ts +66 -66
  46. package/src/grid/plugins/StackedValueAxis.ts +97 -97
  47. package/src/grid/plugins/ValueAxis.ts +94 -94
  48. package/src/index.ts +6 -6
  49. package/src/multiGrid/defaults.ts +244 -244
  50. package/src/multiGrid/index.ts +14 -14
  51. package/src/multiGrid/multiGridObservables.ts +50 -50
  52. package/src/multiGrid/plugins/MultiBars.ts +108 -108
  53. package/src/multiGrid/plugins/MultiBarsTriangle.ts +114 -114
  54. package/src/multiGrid/plugins/MultiDots.ts +102 -102
  55. package/src/multiGrid/plugins/MultiGridLegend.ts +169 -169
  56. package/src/multiGrid/plugins/MultiGridTooltip.ts +66 -66
  57. package/src/multiGrid/plugins/MultiGroupAxis.ts +137 -137
  58. package/src/multiGrid/plugins/MultiLineAreas.ts +107 -107
  59. package/src/multiGrid/plugins/MultiLines.ts +101 -101
  60. package/src/multiGrid/plugins/MultiStackedBars.ts +109 -109
  61. package/src/multiGrid/plugins/MultiStackedValueAxis.ts +135 -135
  62. package/src/multiGrid/plugins/MultiValueAxis.ts +134 -134
  63. package/src/multiGrid/plugins/OverlappingStackedValueAxes.ts +300 -300
  64. package/src/multiGrid/plugins/OverlappingValueAxes.ts +300 -300
  65. package/src/multiValue/defaults.ts +523 -523
  66. package/src/multiValue/index.ts +16 -16
  67. package/src/multiValue/multiValueObservables.ts +781 -781
  68. package/src/multiValue/plugins/MultiValueLegend.ts +107 -107
  69. package/src/multiValue/plugins/MultiValueTooltip.ts +66 -66
  70. package/src/multiValue/plugins/OrdinalAux.ts +660 -660
  71. package/src/multiValue/plugins/OrdinalAxis.ts +524 -524
  72. package/src/multiValue/plugins/OrdinalBubbles.ts +226 -226
  73. package/src/multiValue/plugins/OrdinalZoom.ts +57 -57
  74. package/src/multiValue/plugins/RacingBars.ts +375 -375
  75. package/src/multiValue/plugins/RacingCounterTexts.ts +300 -300
  76. package/src/multiValue/plugins/RacingValueAxis.ts +114 -114
  77. package/src/multiValue/plugins/Scatter.ts +486 -486
  78. package/src/multiValue/plugins/ScatterBubbles.ts +635 -635
  79. package/src/multiValue/plugins/XAxis.ts +107 -107
  80. package/src/multiValue/plugins/XYAux.ts +683 -683
  81. package/src/multiValue/plugins/XYAxes.ts +194 -194
  82. package/src/multiValue/plugins/XYAxes_legacy.ts +683 -683
  83. package/src/multiValue/plugins/XZoom.ts +40 -40
  84. package/src/noneData/defaults.ts +102 -102
  85. package/src/noneData/index.ts +3 -3
  86. package/src/noneData/plugins/Container.ts +27 -27
  87. package/src/noneData/plugins/Tooltip.ts +373 -373
  88. package/src/relationship/defaults.ts +221 -221
  89. package/src/relationship/index.ts +5 -5
  90. package/src/relationship/plugins/ForceDirected.ts +1056 -1056
  91. package/src/relationship/plugins/ForceDirectedBubbles.ts +1294 -1294
  92. package/src/relationship/plugins/RelationshipLegend.ts +100 -100
  93. package/src/relationship/plugins/RelationshipTooltip.ts +66 -66
  94. package/src/relationship/relationshipObservables.ts +49 -49
  95. package/src/series/defaults.ts +236 -224
  96. package/src/series/index.ts +10 -9
  97. package/src/series/plugins/Bubbles.ts +784 -784
  98. package/src/series/plugins/Indicator.ts +292 -0
  99. package/src/series/plugins/Pie.ts +622 -622
  100. package/src/series/plugins/PieEventTexts.ts +283 -283
  101. package/src/series/plugins/PieLabels.ts +639 -639
  102. package/src/series/plugins/Rose.ts +515 -515
  103. package/src/series/plugins/RoseLabels.ts +599 -599
  104. package/src/series/plugins/SeriesLegend.ts +107 -107
  105. package/src/series/plugins/SeriesTooltip.ts +66 -66
  106. package/src/series/seriesObservables.ts +168 -168
  107. package/src/series/seriesUtils.ts +51 -51
  108. package/src/tree/defaults.ts +102 -102
  109. package/src/tree/index.ts +4 -4
  110. package/src/tree/plugins/TreeLegend.ts +100 -100
  111. package/src/tree/plugins/TreeMap.ts +341 -341
  112. package/src/tree/plugins/TreeTooltip.ts +66 -66
  113. package/src/utils/commonUtils.ts +31 -31
  114. package/src/utils/d3Graphics.ts +176 -176
  115. package/src/utils/d3Utils.ts +92 -92
  116. package/src/utils/observables.ts +14 -14
  117. package/src/utils/orbchartsUtils.ts +129 -129
  118. package/tsconfig.base.json +13 -13
  119. package/tsconfig.json +2 -2
  120. package/vite.config.js +22 -22
@@ -1,583 +1,583 @@
1
- import * as d3 from 'd3'
2
- import {
3
- combineLatest,
4
- map,
5
- switchMap,
6
- takeUntil,
7
- distinctUntilChanged,
8
- shareReplay,
9
- Observable,
10
- Subject } from 'rxjs'
11
- import type { BasePluginFn } from './types'
12
- import type {
13
- ComputedDatumMultiValue,
14
- ComputedDataMultiValue,
15
- // ComputedLayoutDataGrid,
16
- DataFormatterMultiValue,
17
- ContainerPositionScaled,
18
- ContainerSize,
19
- EventMultiValue,
20
- ChartParams,
21
- Layout,
22
- TransformData } from '../../lib/core-types'
23
- import type { BaseRacingBarsParams } from '../../lib/plugins-basic-types'
24
- import { getD3TransitionEase } from '../utils/d3Utils'
25
- import { getClassName, getUniID } from '../utils/orbchartsUtils'
26
- import { multiValueContainerSelectionsObservable } from '../multiValue/multiValueObservables'
27
-
28
- // export interface BaseBarsParams {
29
- // // barType: BarType
30
- // barWidth: number
31
- // barPadding: number
32
- // barGroupPadding: number // 群組和群組間的間隔
33
- // barRadius: number | boolean
34
- // }
35
-
36
- interface BaseRacingBarsContext {
37
- selection: d3.Selection<any, unknown, any, unknown>
38
- computedData$: Observable<ComputedDataMultiValue>
39
- visibleComputedRankingData$: Observable<ComputedDatumMultiValue[][]>
40
- CategoryDataMap$: Observable<Map<string, ComputedDatumMultiValue[]>>
41
- fullParams$: Observable<BaseRacingBarsParams>
42
- fullChartParams$: Observable<ChartParams>
43
- fullDataFormatter$: Observable<DataFormatterMultiValue>
44
- // xyValueIndex$: Observable<[number, number]>
45
- highlight$: Observable<ComputedDatumMultiValue[]>
46
- rankingItemHeight$: Observable<number>
47
- rankingScaleList$: Observable<d3.ScalePoint<string>[]>
48
- containerPosition$: Observable<ContainerPositionScaled[]>
49
- containerSize$: Observable<ContainerSize>
50
- xScale$: Observable<(n: number) => number>
51
- isCategorySeprate$: Observable<boolean>
52
- event$: Subject<EventMultiValue>
53
- }
54
-
55
- interface RenderGraphicGParams {
56
- containerSelection: d3.Selection<SVGGElement, ComputedDatumMultiValue[], any, any>
57
- visibleComputedRankingData: ComputedDatumMultiValue[][]
58
- rankingScaleList: d3.ScalePoint<string>[]
59
- transitionDuration: number
60
- }
61
-
62
- interface RenderBarParams {
63
- graphicGSelection: d3.Selection<SVGGElement, ComputedDatumMultiValue, any, any>
64
- rectClassName: string
65
- // xyValueIndex: [number, number]
66
- xScale: (n: number) => number
67
- fullParams: BaseRacingBarsParams
68
- barWidth: number
69
- transitionDuration: number
70
- }
71
-
72
- type ClipPathDatum = {
73
- id: string;
74
- // x: number;
75
- // y: number;
76
- width: number;
77
- height: number;
78
- }
79
-
80
-
81
- function renderGraphicG ({ containerSelection, visibleComputedRankingData, rankingScaleList, transitionDuration }: RenderGraphicGParams) {
82
- containerSelection
83
- .each((_, categoryIndex, g) => {
84
- const container = d3.select(g[categoryIndex])
85
- const graphicG = container.selectAll<SVGGElement, ComputedDatumMultiValue>(`g`)
86
- .data(visibleComputedRankingData[categoryIndex] ?? [], d => d.id)
87
- .join(
88
- enter => {
89
- return enter
90
- .append('g')
91
- .attr('cursor', 'pointer')
92
- .attr('transform', d => {
93
- return `translate(0, ${rankingScaleList[categoryIndex] && rankingScaleList[categoryIndex](d.label)})`
94
- })
95
- },
96
- update => {
97
- return update
98
- .transition()
99
- .duration(transitionDuration)
100
- .ease(d3.easeLinear)
101
- .attr('transform', d => {
102
- return `translate(0, ${rankingScaleList[categoryIndex] && rankingScaleList[categoryIndex](d.label)})`
103
- })
104
- },
105
- exit => exit.remove()
106
- )
107
- })
108
-
109
- const graphicBarSelection: d3.Selection<SVGRectElement, ComputedDatumMultiValue, SVGGElement, unknown> = containerSelection.selectAll(`g`)
110
-
111
- return graphicBarSelection
112
- }
113
-
114
- function renderRectBars ({ graphicGSelection, rectClassName, xScale, fullParams, barWidth, transitionDuration }: RenderBarParams) {
115
-
116
- graphicGSelection
117
- .each((datum, i, g) => {
118
- // const containerIndex = isCategorySeprate ? datum.categoryIndex : 0
119
- // const barWidth = barWidthList[containerIndex]
120
- const barHalfWidth = barWidth / 2
121
- const radius = fullParams.bar.barRadius === true ? barHalfWidth
122
- : fullParams.bar.barRadius === false ? 0
123
- : typeof fullParams.bar.barRadius == 'number' ? fullParams.bar.barRadius
124
- : 0
125
-
126
- const gSelection = d3.select(g[i])
127
- gSelection.selectAll<SVGRectElement, ComputedDatumMultiValue>(`rect.${rectClassName}`)
128
- .data([datum], d => d.id)
129
- .join(
130
- enter => {
131
- return enter
132
- .append('rect')
133
- .classed(rectClassName, true)
134
- .attr('cursor', 'pointer')
135
- // .attr('width', d => 1)
136
- .attr('width', d => xScale(d.value[d.xValueIndex]) ?? 1)
137
- .attr('height', barWidth)
138
- },
139
- update => {
140
- return update
141
- .transition()
142
- .duration(transitionDuration)
143
- .ease(d3.easeLinear)
144
- .attr('width', d => xScale(d.value[d.xValueIndex]) ?? 1)
145
- .attr('height', barWidth)
146
- },
147
- exit => exit.remove()
148
- )
149
- .attr('transform', `translate(0, ${-barHalfWidth})`)
150
- .attr('fill', d => d.color)
151
- .attr('rx', radius)
152
- .attr('ry', radius)
153
- })
154
-
155
- const graphicBarSelection: d3.Selection<SVGRectElement, ComputedDatumMultiValue, SVGGElement, unknown> = graphicGSelection.selectAll(`rect.${rectClassName}`)
156
-
157
- return graphicBarSelection
158
- }
159
-
160
- function renderClipPath ({ defsSelection, clipPathData }: {
161
- defsSelection: d3.Selection<SVGDefsElement, any, any, any>
162
- clipPathData: ClipPathDatum[]
163
- }) {
164
- const clipPath = defsSelection
165
- .selectAll<SVGClipPathElement, Layout>('clipPath')
166
- .data(clipPathData)
167
- .join(
168
- enter => {
169
- return enter
170
- .append('clipPath')
171
- },
172
- update => update,
173
- exit => exit.remove()
174
- )
175
- .attr('id', d => d.id)
176
- .each((d, i, g) => {
177
- const rect = d3.select(g[i])
178
- .selectAll<SVGRectElement, typeof d>('rect')
179
- .data([d])
180
- .join(
181
- enter => {
182
- return enter
183
- .append('rect')
184
- },
185
- update => update,
186
- exit => exit.remove()
187
- )
188
- .attr('x', 0)
189
- .attr('y', 0)
190
- .attr('width', _d => _d.width)
191
- .attr('height', _d => _d.height)
192
- })
193
- }
194
-
195
- function highlight ({ selection, ids, fullChartParams }: {
196
- selection: d3.Selection<any, ComputedDatumMultiValue, any, any>
197
- ids: string[]
198
- fullChartParams: ChartParams
199
- }) {
200
- selection.interrupt('highlight')
201
-
202
- if (!ids.length) {
203
- // remove highlight
204
- selection
205
- .transition('highlight')
206
- .duration(200)
207
- .style('opacity', 1)
208
- return
209
- }
210
-
211
- selection
212
- .each((d, i, n) => {
213
- if (ids.includes(d.id)) {
214
- d3.select(n[i])
215
- .style('opacity', 1)
216
- } else {
217
- d3.select(n[i])
218
- .style('opacity', fullChartParams.styles.unhighlightedOpacity)
219
- }
220
- })
221
- }
222
-
223
-
224
- export const createBaseRacingBars: BasePluginFn<BaseRacingBarsContext> = (pluginName: string, {
225
- selection,
226
- computedData$,
227
- visibleComputedRankingData$,
228
- // xyValueIndex$,
229
- // categoryLabels$,
230
- CategoryDataMap$,
231
- fullParams$,
232
- fullDataFormatter$,
233
- fullChartParams$,
234
- // layout$,
235
- // graphicTransform$,
236
- // graphicReverseScale$,
237
- highlight$,
238
- // computedRankingAmountList$,
239
- rankingItemHeight$,
240
- rankingScaleList$,
241
- containerPosition$,
242
- containerSize$,
243
- // layout$,
244
- xScale$,
245
- isCategorySeprate$,
246
- event$
247
- }) => {
248
-
249
- const destroy$ = new Subject()
250
-
251
- const clipPathID = getUniID(pluginName, 'clipPath-box')
252
- const rectClassName = getClassName(pluginName, 'rect')
253
- // const containerClassName = getClassName(pluginName, 'container')
254
-
255
- // const {
256
- // categorySelection$,
257
- // axesSelection$,
258
- // defsSelection$,
259
- // graphicGSelection$
260
- // } = multiValueSelectionsObservable({
261
- // selection,
262
- // pluginName,
263
- // clipPathID,
264
- // categoryLabels$: categoryLabels$,
265
- // containerPosition$: containerPosition$,
266
- // graphicTransform$: graphicTransform$
267
- // })
268
-
269
- // const clipPathSubscription = combineLatest({
270
- // defsSelection: defsSelection$,
271
- // layout: layout$,
272
- // }).pipe(
273
- // takeUntil(destroy$),
274
- // switchMap(async (d) => d),
275
- // ).subscribe(data => {
276
- // // 外層的遮罩
277
- // const clipPathData = [{
278
- // id: clipPathID,
279
- // width: data.layout.width,
280
- // height: data.layout.height
281
- // }]
282
- // renderClipPath({
283
- // defsSelection: data.defsSelection,
284
- // clipPathData,
285
- // })
286
- // })
287
-
288
- const containerSelection$ = multiValueContainerSelectionsObservable({
289
- selection,
290
- pluginName,
291
- clipPathID,
292
- computedData$,
293
- containerPosition$,
294
- isCategorySeprate$,
295
- }).pipe(
296
- takeUntil(destroy$),
297
- )
298
-
299
- // const containerSelection$ = combineLatest({
300
- // computedData: computedData$.pipe(
301
- // distinctUntilChanged((a, b) => {
302
- // // 只有當series的數量改變時,才重新計算
303
- // return a.length === b.length
304
- // }),
305
- // ),
306
- // isCategorySeprate: isCategorySeprate$
307
- // }).pipe(
308
- // takeUntil(destroy$),
309
- // switchMap(async (d) => d),
310
- // map(data => {
311
- // return data.isCategorySeprate
312
- // // category分開的時候顯示各別axis
313
- // ? data.computedData
314
- // // category合併的時候只顯示第一個axis
315
- // : [data.computedData[0]]
316
- // }),
317
- // map((computedData, i) => {
318
- // return selection
319
- // .selectAll<SVGGElement, ComputedDatumMultiValue[]>(`g.${containerClassName}`)
320
- // .data(computedData, d => d[0] ? d[0].categoryIndex : i)
321
- // .join('g')
322
- // .classed(containerClassName, true)
323
- // .attr('clip-path', `url(#${clipPathID})`)
324
- // })
325
- // )
326
-
327
- containerSize$.subscribe(data => {
328
- const defsSelection = selection.selectAll<SVGDefsElement, any>('defs')
329
- .data([clipPathID])
330
- .join('defs')
331
- const clipPathData = [{
332
- id: clipPathID,
333
- width: data.width,
334
- height: data.height
335
- }]
336
- renderClipPath({
337
- defsSelection: defsSelection,
338
- clipPathData,
339
- // textReverseTransform: data.textReverseTransform
340
- })
341
- })
342
-
343
- // combineLatest({
344
- // containerSelection: containerSelection$,
345
- // containerPosition: containerPosition$
346
- // }).pipe(
347
- // takeUntil(destroy$),
348
- // switchMap(async d => d)
349
- // ).subscribe(data => {
350
- // data.containerSelection
351
- // .attr('transform', (d, i) => {
352
- // const containerPosition = data.containerPosition[i] ?? data.containerPosition[0]
353
- // const translate = containerPosition.translate
354
- // const scale = containerPosition.scale
355
- // // return `translate(${translate[0]}, ${translate[1]}) scale(${scale[0]}, ${scale[1]})`
356
- // return `translate(${translate[0]}, ${translate[1]})`
357
- // })
358
- // // .attr('opacity', 0)
359
- // // .transition()
360
- // // .attr('opacity', 1)
361
- // })
362
-
363
- const barWidth$ = combineLatest({
364
- fullParams: fullParams$,
365
- rankingItemHeight: rankingItemHeight$,
366
- }).pipe(
367
- takeUntil(destroy$),
368
- switchMap(async d => d),
369
- map(data => {
370
- if (data.fullParams.bar.barWidth) {
371
- return data.fullParams.bar.barWidth
372
- } else {
373
- return data.rankingItemHeight - data.fullParams.bar.barPadding
374
- }
375
- }),
376
- distinctUntilChanged()
377
- )
378
-
379
- const transitionDuration$ = fullChartParams$.pipe(
380
- takeUntil(destroy$),
381
- map(d => d.transitionDuration),
382
- distinctUntilChanged()
383
- )
384
-
385
- const graphicGSelection$ = combineLatest({
386
- containerSelection: containerSelection$,
387
- visibleComputedRankingData: visibleComputedRankingData$,
388
- rankingScaleList: rankingScaleList$,
389
- transitionDuration: transitionDuration$,
390
- }).pipe(
391
- takeUntil(destroy$),
392
- switchMap(async (d) => d),
393
- map(data => {
394
-
395
- return renderGraphicG({
396
- containerSelection: data.containerSelection,
397
- visibleComputedRankingData: data.visibleComputedRankingData,
398
- rankingScaleList: data.rankingScaleList,
399
- transitionDuration: data.transitionDuration
400
- })
401
- })
402
- )
403
-
404
- const graphicSelection$ = combineLatest({
405
- graphicGSelection: graphicGSelection$,
406
- // xyValueIndex: xyValueIndex$,
407
- xScale: xScale$,
408
- barWidth: barWidth$,
409
- transitionDuration: transitionDuration$,
410
- fullParams: fullParams$,
411
- }).pipe(
412
- takeUntil(destroy$),
413
- switchMap(async (d) => d),
414
- map(data => {
415
-
416
- return renderRectBars({
417
- graphicGSelection: data.graphicGSelection,
418
- rectClassName,
419
- // xyValueIndex: data.xyValueIndex,
420
- xScale: data.xScale,
421
- fullParams: data.fullParams,
422
- barWidth: data.barWidth,
423
- transitionDuration: data.transitionDuration,
424
- })
425
- }),
426
- shareReplay(1)
427
- )
428
-
429
- const highlightTarget$ = fullChartParams$.pipe(
430
- takeUntil(destroy$),
431
- map(d => d.highlightTarget),
432
- distinctUntilChanged()
433
- )
434
-
435
- combineLatest({
436
- graphicSelection: graphicSelection$,
437
- computedData: computedData$,
438
- CategoryDataMap: CategoryDataMap$,
439
- highlightTarget: highlightTarget$,
440
- fullDataFormatter: fullDataFormatter$
441
- }).pipe(
442
- takeUntil(destroy$),
443
- switchMap(async (d) => d),
444
- ).subscribe(data => {
445
-
446
- data.graphicSelection
447
- .on('mouseover', (event, datum) => {
448
- // event.stopPropagation()
449
- // console.log({
450
- // type: 'multiValue',
451
- // eventName: 'mouseover',
452
- // pluginName,
453
- // highlightTarget: data.highlightTarget,
454
- // datum,
455
- // category: data.CategoryDataMap.get(datum.categoryLabel)!,
456
- // categoryIndex: datum.categoryIndex,
457
- // categoryLabel: datum.categoryLabel,
458
- // data: data.computedData,
459
- // event,
460
- // })
461
-
462
- // 只顯示目前的值
463
- // datum._visibleValue = [datum.value[datum.xValueIndex]]
464
-
465
- event$.next({
466
- type: 'multiValue',
467
- eventName: 'mouseover',
468
- pluginName,
469
- highlightTarget: data.highlightTarget,
470
- valueDetail: [
471
- {
472
- value: datum.value[datum.xValueIndex],
473
- valueIndex: datum.xValueIndex,
474
- valueLabel: data.fullDataFormatter.valueLabels[datum.xValueIndex] ?? String(datum.xValueIndex)
475
- },
476
- ],
477
- datum,
478
- category: data.CategoryDataMap.get(datum.categoryLabel)!,
479
- categoryIndex: datum.categoryIndex,
480
- categoryLabel: datum.categoryLabel,
481
- data: data.computedData,
482
- event,
483
- })
484
- })
485
- .on('mousemove', (event, datum) => {
486
- // event.stopPropagation()
487
-
488
- // 只顯示目前的值
489
- // datum._visibleValue = [datum.value[datum.xValueIndex]]
490
-
491
- event$.next({
492
- type: 'multiValue',
493
- eventName: 'mousemove',
494
- pluginName,
495
- highlightTarget: data.highlightTarget,
496
- valueDetail: [
497
- {
498
- value: datum.value[datum.xValueIndex],
499
- valueIndex: datum.xValueIndex,
500
- valueLabel: data.fullDataFormatter.valueLabels[datum.xValueIndex] ?? String(datum.xValueIndex)
501
- },
502
- ],
503
- datum,
504
- category: data.CategoryDataMap.get(datum.categoryLabel)!,
505
- categoryIndex: datum.categoryIndex,
506
- categoryLabel: datum.categoryLabel,
507
- data: data.computedData,
508
- event,
509
- })
510
- })
511
- .on('mouseout', (event, datum) => {
512
- // event.stopPropagation()
513
-
514
- event$.next({
515
- type: 'multiValue',
516
- eventName: 'mouseout',
517
- pluginName,
518
- highlightTarget: data.highlightTarget,
519
- valueDetail: [
520
- {
521
- value: datum.value[datum.xValueIndex],
522
- valueIndex: datum.xValueIndex,
523
- valueLabel: data.fullDataFormatter.valueLabels[datum.xValueIndex] ?? String(datum.xValueIndex)
524
- },
525
- ],
526
- datum,
527
- category: data.CategoryDataMap.get(datum.categoryLabel)!,
528
- categoryIndex: datum.categoryIndex,
529
- categoryLabel: datum.categoryLabel,
530
- data: data.computedData,
531
- event,
532
- })
533
- })
534
- .on('click', (event, datum) => {
535
- // event.stopPropagation()
536
-
537
- // 只顯示目前的值
538
- // datum._visibleValue = [datum.value[datum.xValueIndex]]
539
-
540
- event$.next({
541
- type: 'multiValue',
542
- eventName: 'click',
543
- pluginName,
544
- highlightTarget: data.highlightTarget,
545
- valueDetail: [
546
- {
547
- value: datum.value[datum.xValueIndex],
548
- valueIndex: datum.xValueIndex,
549
- valueLabel: data.fullDataFormatter.valueLabels[datum.xValueIndex] ?? String(datum.xValueIndex)
550
- },
551
- ],
552
- datum,
553
- category: data.CategoryDataMap.get(datum.categoryLabel)!,
554
- categoryIndex: datum.categoryIndex,
555
- categoryLabel: datum.categoryLabel,
556
- data: data.computedData,
557
- event,
558
- })
559
- })
560
-
561
- })
562
-
563
- combineLatest({
564
- graphicSelection: graphicSelection$,
565
- highlight: highlight$.pipe(
566
- map(data => data.map(d => d.id))
567
- ),
568
- fullChartParams: fullChartParams$
569
- }).pipe(
570
- takeUntil(destroy$),
571
- switchMap(async d => d)
572
- ).subscribe(data => {
573
- highlight({
574
- selection: data.graphicSelection,
575
- ids: data.highlight,
576
- fullChartParams: data.fullChartParams
577
- })
578
- })
579
-
580
- return () => {
581
- destroy$.next(undefined)
582
- }
1
+ import * as d3 from 'd3'
2
+ import {
3
+ combineLatest,
4
+ map,
5
+ switchMap,
6
+ takeUntil,
7
+ distinctUntilChanged,
8
+ shareReplay,
9
+ Observable,
10
+ Subject } from 'rxjs'
11
+ import type { BasePluginFn } from './types'
12
+ import type {
13
+ ComputedDatumMultiValue,
14
+ ComputedDataMultiValue,
15
+ // ComputedLayoutDataGrid,
16
+ DataFormatterMultiValue,
17
+ ContainerPositionScaled,
18
+ ContainerSize,
19
+ EventMultiValue,
20
+ ChartParams,
21
+ Layout,
22
+ TransformData } from '../../lib/core-types'
23
+ import type { BaseRacingBarsParams } from '../../lib/plugins-basic-types'
24
+ import { getD3TransitionEase } from '../utils/d3Utils'
25
+ import { getClassName, getUniID } from '../utils/orbchartsUtils'
26
+ import { multiValueContainerSelectionsObservable } from '../multiValue/multiValueObservables'
27
+
28
+ // export interface BaseBarsParams {
29
+ // // barType: BarType
30
+ // barWidth: number
31
+ // barPadding: number
32
+ // barGroupPadding: number // 群組和群組間的間隔
33
+ // barRadius: number | boolean
34
+ // }
35
+
36
+ interface BaseRacingBarsContext {
37
+ selection: d3.Selection<any, unknown, any, unknown>
38
+ computedData$: Observable<ComputedDataMultiValue>
39
+ visibleComputedRankingData$: Observable<ComputedDatumMultiValue[][]>
40
+ CategoryDataMap$: Observable<Map<string, ComputedDatumMultiValue[]>>
41
+ fullParams$: Observable<BaseRacingBarsParams>
42
+ fullChartParams$: Observable<ChartParams>
43
+ fullDataFormatter$: Observable<DataFormatterMultiValue>
44
+ // xyValueIndex$: Observable<[number, number]>
45
+ highlight$: Observable<ComputedDatumMultiValue[]>
46
+ rankingItemHeight$: Observable<number>
47
+ rankingScaleList$: Observable<d3.ScalePoint<string>[]>
48
+ containerPosition$: Observable<ContainerPositionScaled[]>
49
+ containerSize$: Observable<ContainerSize>
50
+ xScale$: Observable<(n: number) => number>
51
+ isCategorySeprate$: Observable<boolean>
52
+ event$: Subject<EventMultiValue>
53
+ }
54
+
55
+ interface RenderGraphicGParams {
56
+ containerSelection: d3.Selection<SVGGElement, ComputedDatumMultiValue[], any, any>
57
+ visibleComputedRankingData: ComputedDatumMultiValue[][]
58
+ rankingScaleList: d3.ScalePoint<string>[]
59
+ transitionDuration: number
60
+ }
61
+
62
+ interface RenderBarParams {
63
+ graphicGSelection: d3.Selection<SVGGElement, ComputedDatumMultiValue, any, any>
64
+ rectClassName: string
65
+ // xyValueIndex: [number, number]
66
+ xScale: (n: number) => number
67
+ fullParams: BaseRacingBarsParams
68
+ barWidth: number
69
+ transitionDuration: number
70
+ }
71
+
72
+ type ClipPathDatum = {
73
+ id: string;
74
+ // x: number;
75
+ // y: number;
76
+ width: number;
77
+ height: number;
78
+ }
79
+
80
+
81
+ function renderGraphicG ({ containerSelection, visibleComputedRankingData, rankingScaleList, transitionDuration }: RenderGraphicGParams) {
82
+ containerSelection
83
+ .each((_, categoryIndex, g) => {
84
+ const container = d3.select(g[categoryIndex])
85
+ const graphicG = container.selectAll<SVGGElement, ComputedDatumMultiValue>(`g`)
86
+ .data(visibleComputedRankingData[categoryIndex] ?? [], d => d.id)
87
+ .join(
88
+ enter => {
89
+ return enter
90
+ .append('g')
91
+ .attr('cursor', 'pointer')
92
+ .attr('transform', d => {
93
+ return `translate(0, ${rankingScaleList[categoryIndex] && rankingScaleList[categoryIndex](d.label)})`
94
+ })
95
+ },
96
+ update => {
97
+ return update
98
+ .transition()
99
+ .duration(transitionDuration)
100
+ .ease(d3.easeLinear)
101
+ .attr('transform', d => {
102
+ return `translate(0, ${rankingScaleList[categoryIndex] && rankingScaleList[categoryIndex](d.label)})`
103
+ })
104
+ },
105
+ exit => exit.remove()
106
+ )
107
+ })
108
+
109
+ const graphicBarSelection: d3.Selection<SVGRectElement, ComputedDatumMultiValue, SVGGElement, unknown> = containerSelection.selectAll(`g`)
110
+
111
+ return graphicBarSelection
112
+ }
113
+
114
+ function renderRectBars ({ graphicGSelection, rectClassName, xScale, fullParams, barWidth, transitionDuration }: RenderBarParams) {
115
+
116
+ graphicGSelection
117
+ .each((datum, i, g) => {
118
+ // const containerIndex = isCategorySeprate ? datum.categoryIndex : 0
119
+ // const barWidth = barWidthList[containerIndex]
120
+ const barHalfWidth = barWidth / 2
121
+ const radius = fullParams.bar.barRadius === true ? barHalfWidth
122
+ : fullParams.bar.barRadius === false ? 0
123
+ : typeof fullParams.bar.barRadius == 'number' ? fullParams.bar.barRadius
124
+ : 0
125
+
126
+ const gSelection = d3.select(g[i])
127
+ gSelection.selectAll<SVGRectElement, ComputedDatumMultiValue>(`rect.${rectClassName}`)
128
+ .data([datum], d => d.id)
129
+ .join(
130
+ enter => {
131
+ return enter
132
+ .append('rect')
133
+ .classed(rectClassName, true)
134
+ .attr('cursor', 'pointer')
135
+ // .attr('width', d => 1)
136
+ .attr('width', d => xScale(d.value[d.xValueIndex]) ?? 1)
137
+ .attr('height', barWidth)
138
+ },
139
+ update => {
140
+ return update
141
+ .transition()
142
+ .duration(transitionDuration)
143
+ .ease(d3.easeLinear)
144
+ .attr('width', d => xScale(d.value[d.xValueIndex]) ?? 1)
145
+ .attr('height', barWidth)
146
+ },
147
+ exit => exit.remove()
148
+ )
149
+ .attr('transform', `translate(0, ${-barHalfWidth})`)
150
+ .attr('fill', d => d.color)
151
+ .attr('rx', radius)
152
+ .attr('ry', radius)
153
+ })
154
+
155
+ const graphicBarSelection: d3.Selection<SVGRectElement, ComputedDatumMultiValue, SVGGElement, unknown> = graphicGSelection.selectAll(`rect.${rectClassName}`)
156
+
157
+ return graphicBarSelection
158
+ }
159
+
160
+ function renderClipPath ({ defsSelection, clipPathData }: {
161
+ defsSelection: d3.Selection<SVGDefsElement, any, any, any>
162
+ clipPathData: ClipPathDatum[]
163
+ }) {
164
+ const clipPath = defsSelection
165
+ .selectAll<SVGClipPathElement, Layout>('clipPath')
166
+ .data(clipPathData)
167
+ .join(
168
+ enter => {
169
+ return enter
170
+ .append('clipPath')
171
+ },
172
+ update => update,
173
+ exit => exit.remove()
174
+ )
175
+ .attr('id', d => d.id)
176
+ .each((d, i, g) => {
177
+ const rect = d3.select(g[i])
178
+ .selectAll<SVGRectElement, typeof d>('rect')
179
+ .data([d])
180
+ .join(
181
+ enter => {
182
+ return enter
183
+ .append('rect')
184
+ },
185
+ update => update,
186
+ exit => exit.remove()
187
+ )
188
+ .attr('x', 0)
189
+ .attr('y', 0)
190
+ .attr('width', _d => _d.width)
191
+ .attr('height', _d => _d.height)
192
+ })
193
+ }
194
+
195
+ function highlight ({ selection, ids, fullChartParams }: {
196
+ selection: d3.Selection<any, ComputedDatumMultiValue, any, any>
197
+ ids: string[]
198
+ fullChartParams: ChartParams
199
+ }) {
200
+ selection.interrupt('highlight')
201
+
202
+ if (!ids.length) {
203
+ // remove highlight
204
+ selection
205
+ .transition('highlight')
206
+ .duration(200)
207
+ .style('opacity', 1)
208
+ return
209
+ }
210
+
211
+ selection
212
+ .each((d, i, n) => {
213
+ if (ids.includes(d.id)) {
214
+ d3.select(n[i])
215
+ .style('opacity', 1)
216
+ } else {
217
+ d3.select(n[i])
218
+ .style('opacity', fullChartParams.styles.unhighlightedOpacity)
219
+ }
220
+ })
221
+ }
222
+
223
+
224
+ export const createBaseRacingBars: BasePluginFn<BaseRacingBarsContext> = (pluginName: string, {
225
+ selection,
226
+ computedData$,
227
+ visibleComputedRankingData$,
228
+ // xyValueIndex$,
229
+ // categoryLabels$,
230
+ CategoryDataMap$,
231
+ fullParams$,
232
+ fullDataFormatter$,
233
+ fullChartParams$,
234
+ // layout$,
235
+ // graphicTransform$,
236
+ // graphicReverseScale$,
237
+ highlight$,
238
+ // computedRankingAmountList$,
239
+ rankingItemHeight$,
240
+ rankingScaleList$,
241
+ containerPosition$,
242
+ containerSize$,
243
+ // layout$,
244
+ xScale$,
245
+ isCategorySeprate$,
246
+ event$
247
+ }) => {
248
+
249
+ const destroy$ = new Subject()
250
+
251
+ const clipPathID = getUniID(pluginName, 'clipPath-box')
252
+ const rectClassName = getClassName(pluginName, 'rect')
253
+ // const containerClassName = getClassName(pluginName, 'container')
254
+
255
+ // const {
256
+ // categorySelection$,
257
+ // axesSelection$,
258
+ // defsSelection$,
259
+ // graphicGSelection$
260
+ // } = multiValueSelectionsObservable({
261
+ // selection,
262
+ // pluginName,
263
+ // clipPathID,
264
+ // categoryLabels$: categoryLabels$,
265
+ // containerPosition$: containerPosition$,
266
+ // graphicTransform$: graphicTransform$
267
+ // })
268
+
269
+ // const clipPathSubscription = combineLatest({
270
+ // defsSelection: defsSelection$,
271
+ // layout: layout$,
272
+ // }).pipe(
273
+ // takeUntil(destroy$),
274
+ // switchMap(async (d) => d),
275
+ // ).subscribe(data => {
276
+ // // 外層的遮罩
277
+ // const clipPathData = [{
278
+ // id: clipPathID,
279
+ // width: data.layout.width,
280
+ // height: data.layout.height
281
+ // }]
282
+ // renderClipPath({
283
+ // defsSelection: data.defsSelection,
284
+ // clipPathData,
285
+ // })
286
+ // })
287
+
288
+ const containerSelection$ = multiValueContainerSelectionsObservable({
289
+ selection,
290
+ pluginName,
291
+ clipPathID,
292
+ computedData$,
293
+ containerPosition$,
294
+ isCategorySeprate$,
295
+ }).pipe(
296
+ takeUntil(destroy$),
297
+ )
298
+
299
+ // const containerSelection$ = combineLatest({
300
+ // computedData: computedData$.pipe(
301
+ // distinctUntilChanged((a, b) => {
302
+ // // 只有當series的數量改變時,才重新計算
303
+ // return a.length === b.length
304
+ // }),
305
+ // ),
306
+ // isCategorySeprate: isCategorySeprate$
307
+ // }).pipe(
308
+ // takeUntil(destroy$),
309
+ // switchMap(async (d) => d),
310
+ // map(data => {
311
+ // return data.isCategorySeprate
312
+ // // category分開的時候顯示各別axis
313
+ // ? data.computedData
314
+ // // category合併的時候只顯示第一個axis
315
+ // : [data.computedData[0]]
316
+ // }),
317
+ // map((computedData, i) => {
318
+ // return selection
319
+ // .selectAll<SVGGElement, ComputedDatumMultiValue[]>(`g.${containerClassName}`)
320
+ // .data(computedData, d => d[0] ? d[0].categoryIndex : i)
321
+ // .join('g')
322
+ // .classed(containerClassName, true)
323
+ // .attr('clip-path', `url(#${clipPathID})`)
324
+ // })
325
+ // )
326
+
327
+ containerSize$.subscribe(data => {
328
+ const defsSelection = selection.selectAll<SVGDefsElement, any>('defs')
329
+ .data([clipPathID])
330
+ .join('defs')
331
+ const clipPathData = [{
332
+ id: clipPathID,
333
+ width: data.width,
334
+ height: data.height
335
+ }]
336
+ renderClipPath({
337
+ defsSelection: defsSelection,
338
+ clipPathData,
339
+ // textReverseTransform: data.textReverseTransform
340
+ })
341
+ })
342
+
343
+ // combineLatest({
344
+ // containerSelection: containerSelection$,
345
+ // containerPosition: containerPosition$
346
+ // }).pipe(
347
+ // takeUntil(destroy$),
348
+ // switchMap(async d => d)
349
+ // ).subscribe(data => {
350
+ // data.containerSelection
351
+ // .attr('transform', (d, i) => {
352
+ // const containerPosition = data.containerPosition[i] ?? data.containerPosition[0]
353
+ // const translate = containerPosition.translate
354
+ // const scale = containerPosition.scale
355
+ // // return `translate(${translate[0]}, ${translate[1]}) scale(${scale[0]}, ${scale[1]})`
356
+ // return `translate(${translate[0]}, ${translate[1]})`
357
+ // })
358
+ // // .attr('opacity', 0)
359
+ // // .transition()
360
+ // // .attr('opacity', 1)
361
+ // })
362
+
363
+ const barWidth$ = combineLatest({
364
+ fullParams: fullParams$,
365
+ rankingItemHeight: rankingItemHeight$,
366
+ }).pipe(
367
+ takeUntil(destroy$),
368
+ switchMap(async d => d),
369
+ map(data => {
370
+ if (data.fullParams.bar.barWidth) {
371
+ return data.fullParams.bar.barWidth
372
+ } else {
373
+ return data.rankingItemHeight - data.fullParams.bar.barPadding
374
+ }
375
+ }),
376
+ distinctUntilChanged()
377
+ )
378
+
379
+ const transitionDuration$ = fullChartParams$.pipe(
380
+ takeUntil(destroy$),
381
+ map(d => d.transitionDuration),
382
+ distinctUntilChanged()
383
+ )
384
+
385
+ const graphicGSelection$ = combineLatest({
386
+ containerSelection: containerSelection$,
387
+ visibleComputedRankingData: visibleComputedRankingData$,
388
+ rankingScaleList: rankingScaleList$,
389
+ transitionDuration: transitionDuration$,
390
+ }).pipe(
391
+ takeUntil(destroy$),
392
+ switchMap(async (d) => d),
393
+ map(data => {
394
+
395
+ return renderGraphicG({
396
+ containerSelection: data.containerSelection,
397
+ visibleComputedRankingData: data.visibleComputedRankingData,
398
+ rankingScaleList: data.rankingScaleList,
399
+ transitionDuration: data.transitionDuration
400
+ })
401
+ })
402
+ )
403
+
404
+ const graphicSelection$ = combineLatest({
405
+ graphicGSelection: graphicGSelection$,
406
+ // xyValueIndex: xyValueIndex$,
407
+ xScale: xScale$,
408
+ barWidth: barWidth$,
409
+ transitionDuration: transitionDuration$,
410
+ fullParams: fullParams$,
411
+ }).pipe(
412
+ takeUntil(destroy$),
413
+ switchMap(async (d) => d),
414
+ map(data => {
415
+
416
+ return renderRectBars({
417
+ graphicGSelection: data.graphicGSelection,
418
+ rectClassName,
419
+ // xyValueIndex: data.xyValueIndex,
420
+ xScale: data.xScale,
421
+ fullParams: data.fullParams,
422
+ barWidth: data.barWidth,
423
+ transitionDuration: data.transitionDuration,
424
+ })
425
+ }),
426
+ shareReplay(1)
427
+ )
428
+
429
+ const highlightTarget$ = fullChartParams$.pipe(
430
+ takeUntil(destroy$),
431
+ map(d => d.highlightTarget),
432
+ distinctUntilChanged()
433
+ )
434
+
435
+ combineLatest({
436
+ graphicSelection: graphicSelection$,
437
+ computedData: computedData$,
438
+ CategoryDataMap: CategoryDataMap$,
439
+ highlightTarget: highlightTarget$,
440
+ fullDataFormatter: fullDataFormatter$
441
+ }).pipe(
442
+ takeUntil(destroy$),
443
+ switchMap(async (d) => d),
444
+ ).subscribe(data => {
445
+
446
+ data.graphicSelection
447
+ .on('mouseover', (event, datum) => {
448
+ // event.stopPropagation()
449
+ // console.log({
450
+ // type: 'multiValue',
451
+ // eventName: 'mouseover',
452
+ // pluginName,
453
+ // highlightTarget: data.highlightTarget,
454
+ // datum,
455
+ // category: data.CategoryDataMap.get(datum.categoryLabel)!,
456
+ // categoryIndex: datum.categoryIndex,
457
+ // categoryLabel: datum.categoryLabel,
458
+ // data: data.computedData,
459
+ // event,
460
+ // })
461
+
462
+ // 只顯示目前的值
463
+ // datum._visibleValue = [datum.value[datum.xValueIndex]]
464
+
465
+ event$.next({
466
+ type: 'multiValue',
467
+ eventName: 'mouseover',
468
+ pluginName,
469
+ highlightTarget: data.highlightTarget,
470
+ valueDetail: [
471
+ {
472
+ value: datum.value[datum.xValueIndex],
473
+ valueIndex: datum.xValueIndex,
474
+ valueLabel: data.fullDataFormatter.valueLabels[datum.xValueIndex] ?? String(datum.xValueIndex)
475
+ },
476
+ ],
477
+ datum,
478
+ category: data.CategoryDataMap.get(datum.categoryLabel)!,
479
+ categoryIndex: datum.categoryIndex,
480
+ categoryLabel: datum.categoryLabel,
481
+ data: data.computedData,
482
+ event,
483
+ })
484
+ })
485
+ .on('mousemove', (event, datum) => {
486
+ // event.stopPropagation()
487
+
488
+ // 只顯示目前的值
489
+ // datum._visibleValue = [datum.value[datum.xValueIndex]]
490
+
491
+ event$.next({
492
+ type: 'multiValue',
493
+ eventName: 'mousemove',
494
+ pluginName,
495
+ highlightTarget: data.highlightTarget,
496
+ valueDetail: [
497
+ {
498
+ value: datum.value[datum.xValueIndex],
499
+ valueIndex: datum.xValueIndex,
500
+ valueLabel: data.fullDataFormatter.valueLabels[datum.xValueIndex] ?? String(datum.xValueIndex)
501
+ },
502
+ ],
503
+ datum,
504
+ category: data.CategoryDataMap.get(datum.categoryLabel)!,
505
+ categoryIndex: datum.categoryIndex,
506
+ categoryLabel: datum.categoryLabel,
507
+ data: data.computedData,
508
+ event,
509
+ })
510
+ })
511
+ .on('mouseout', (event, datum) => {
512
+ // event.stopPropagation()
513
+
514
+ event$.next({
515
+ type: 'multiValue',
516
+ eventName: 'mouseout',
517
+ pluginName,
518
+ highlightTarget: data.highlightTarget,
519
+ valueDetail: [
520
+ {
521
+ value: datum.value[datum.xValueIndex],
522
+ valueIndex: datum.xValueIndex,
523
+ valueLabel: data.fullDataFormatter.valueLabels[datum.xValueIndex] ?? String(datum.xValueIndex)
524
+ },
525
+ ],
526
+ datum,
527
+ category: data.CategoryDataMap.get(datum.categoryLabel)!,
528
+ categoryIndex: datum.categoryIndex,
529
+ categoryLabel: datum.categoryLabel,
530
+ data: data.computedData,
531
+ event,
532
+ })
533
+ })
534
+ .on('click', (event, datum) => {
535
+ // event.stopPropagation()
536
+
537
+ // 只顯示目前的值
538
+ // datum._visibleValue = [datum.value[datum.xValueIndex]]
539
+
540
+ event$.next({
541
+ type: 'multiValue',
542
+ eventName: 'click',
543
+ pluginName,
544
+ highlightTarget: data.highlightTarget,
545
+ valueDetail: [
546
+ {
547
+ value: datum.value[datum.xValueIndex],
548
+ valueIndex: datum.xValueIndex,
549
+ valueLabel: data.fullDataFormatter.valueLabels[datum.xValueIndex] ?? String(datum.xValueIndex)
550
+ },
551
+ ],
552
+ datum,
553
+ category: data.CategoryDataMap.get(datum.categoryLabel)!,
554
+ categoryIndex: datum.categoryIndex,
555
+ categoryLabel: datum.categoryLabel,
556
+ data: data.computedData,
557
+ event,
558
+ })
559
+ })
560
+
561
+ })
562
+
563
+ combineLatest({
564
+ graphicSelection: graphicSelection$,
565
+ highlight: highlight$.pipe(
566
+ map(data => data.map(d => d.id))
567
+ ),
568
+ fullChartParams: fullChartParams$
569
+ }).pipe(
570
+ takeUntil(destroy$),
571
+ switchMap(async d => d)
572
+ ).subscribe(data => {
573
+ highlight({
574
+ selection: data.graphicSelection,
575
+ ids: data.highlight,
576
+ fullChartParams: data.fullChartParams
577
+ })
578
+ })
579
+
580
+ return () => {
581
+ destroy$.next(undefined)
582
+ }
583
583
  }