@orbcharts/plugins-basic 3.0.0-beta.15 → 3.0.0-beta.17

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 (228) hide show
  1. package/LICENSE +200 -200
  2. package/dist/orbcharts-plugins-basic.es.js +11839 -10485
  3. package/dist/orbcharts-plugins-basic.umd.js +231 -171
  4. package/dist/{orbcharts-plugins-basic/src → src}/base/BaseBars.d.ts +3 -3
  5. package/dist/{orbcharts-plugins-basic/src → src}/base/BaseBarsTriangle.d.ts +3 -3
  6. package/dist/{orbcharts-plugins-basic/src → src}/base/BaseDots.d.ts +3 -3
  7. package/dist/{orbcharts-plugins-basic/src → src}/base/BaseLineAreas.d.ts +3 -3
  8. package/dist/{orbcharts-plugins-basic/src → src}/base/BaseLines.d.ts +3 -3
  9. package/dist/src/base/BaseRacingBars.d.ts +23 -0
  10. package/dist/src/base/BaseRacingLabels.d.ts +20 -0
  11. package/dist/src/base/BaseRacingValueLabels.d.ts +20 -0
  12. package/dist/{orbcharts-plugins-basic/src/base/BaseStackedBar.d.ts → src/base/BaseStackedBars.d.ts} +7 -7
  13. package/dist/{orbcharts-plugins-basic/src → src}/base/BaseValueAxis.d.ts +4 -7
  14. package/dist/src/base/BaseXAxis.d.ts +20 -0
  15. package/dist/src/base/BaseYAxis.d.ts +18 -0
  16. package/dist/{orbcharts-plugins-basic/src → src}/grid/defaults.d.ts +3 -3
  17. package/dist/{orbcharts-plugins-basic/src → src}/grid/gridObservables.d.ts +8 -1
  18. package/dist/{orbcharts-plugins-basic/src → src}/grid/index.d.ts +2 -2
  19. package/dist/src/grid/plugins/GroupZoom.d.ts +1 -0
  20. package/dist/src/grid/plugins/StackedBars.d.ts +1 -0
  21. package/dist/src/index.d.ts +7 -1
  22. package/dist/{orbcharts-plugins-basic/src → src}/multiGrid/defaults.d.ts +2 -2
  23. package/dist/{orbcharts-plugins-basic/src → src}/multiGrid/index.d.ts +1 -1
  24. package/dist/src/multiGrid/plugins/MultiStackedBars.d.ts +1 -0
  25. package/dist/src/multiValue/defaults.d.ts +13 -0
  26. package/dist/{orbcharts-plugins-basic/src → src}/multiValue/index.d.ts +5 -1
  27. package/dist/src/multiValue/multiValueObservables.d.ts +56 -0
  28. package/dist/src/multiValue/plugins/RacingBars.d.ts +1 -0
  29. package/dist/src/multiValue/plugins/RacingCounterTexts.d.ts +3 -0
  30. package/dist/src/multiValue/plugins/RacingValueAxis.d.ts +1 -0
  31. package/dist/src/multiValue/plugins/XAxis.d.ts +1 -0
  32. package/dist/src/multiValue/plugins/XYAxes.d.ts +1 -0
  33. package/dist/src/multiValue/plugins/XZoom.d.ts +1 -0
  34. package/dist/{orbcharts-plugins-basic/src → src}/utils/commonUtils.d.ts +1 -0
  35. package/dist/{orbcharts-plugins-basic/src → src}/utils/d3Graphics.d.ts +2 -1
  36. package/lib/core-types.ts +7 -7
  37. package/lib/core.ts +6 -6
  38. package/lib/plugins-basic-types.ts +6 -6
  39. package/package.json +44 -44
  40. package/src/base/BaseBars.ts +765 -765
  41. package/src/base/BaseBarsTriangle.ts +676 -676
  42. package/src/base/BaseDots.ts +464 -464
  43. package/src/base/BaseGroupAxis.ts +691 -679
  44. package/src/base/BaseLegend.ts +684 -684
  45. package/src/base/BaseLineAreas.ts +629 -629
  46. package/src/base/BaseLines.ts +706 -706
  47. package/src/base/BaseRacingBars.ts +552 -0
  48. package/src/base/BaseRacingLabels.ts +396 -0
  49. package/src/base/BaseRacingValueLabels.ts +403 -0
  50. package/src/base/{BaseStackedBar.ts → BaseStackedBars.ts} +782 -782
  51. package/src/base/BaseTooltip.ts +386 -385
  52. package/src/base/BaseValueAxis.ts +600 -583
  53. package/src/base/BaseXAxis.ts +427 -0
  54. package/src/base/BaseYAxis.ts +389 -0
  55. package/src/base/types.ts +2 -2
  56. package/src/const.ts +30 -30
  57. package/src/grid/defaults.ts +213 -250
  58. package/src/grid/gridObservables.ts +612 -554
  59. package/src/grid/index.ts +16 -16
  60. package/src/grid/plugins/Bars.ts +69 -69
  61. package/src/grid/plugins/BarsPN.ts +66 -66
  62. package/src/grid/plugins/BarsTriangle.ts +73 -73
  63. package/src/grid/plugins/Dots.ts +68 -68
  64. package/src/grid/plugins/GridLegend.ts +107 -107
  65. package/src/grid/plugins/GridTooltip.ts +66 -66
  66. package/src/grid/plugins/GroupAux.ts +1120 -1103
  67. package/src/grid/plugins/GroupAxis.ts +73 -97
  68. package/src/grid/plugins/{GridZoom.ts → GroupZoom.ts} +218 -218
  69. package/src/grid/plugins/LineAreas.ts +65 -65
  70. package/src/grid/plugins/Lines.ts +59 -59
  71. package/src/grid/plugins/{StackedBar.ts → StackedBars.ts} +64 -64
  72. package/src/grid/plugins/StackedValueAxis.ts +96 -96
  73. package/src/grid/plugins/ValueAxis.ts +94 -94
  74. package/src/index.ts +6 -6
  75. package/src/multiGrid/defaults.ts +244 -228
  76. package/src/multiGrid/index.ts +14 -14
  77. package/src/multiGrid/multiGridObservables.ts +50 -49
  78. package/src/multiGrid/plugins/MultiBars.ts +108 -108
  79. package/src/multiGrid/plugins/MultiBarsTriangle.ts +114 -114
  80. package/src/multiGrid/plugins/MultiDots.ts +102 -102
  81. package/src/multiGrid/plugins/MultiGridLegend.ts +169 -159
  82. package/src/multiGrid/plugins/MultiGridTooltip.ts +66 -66
  83. package/src/multiGrid/plugins/MultiGroupAxis.ts +137 -137
  84. package/src/multiGrid/plugins/MultiLineAreas.ts +107 -107
  85. package/src/multiGrid/plugins/MultiLines.ts +101 -101
  86. package/src/multiGrid/plugins/{MultiStackedBar.ts → MultiStackedBars.ts} +106 -106
  87. package/src/multiGrid/plugins/MultiStackedValueAxis.ts +134 -134
  88. package/src/multiGrid/plugins/MultiValueAxis.ts +134 -134
  89. package/src/multiGrid/plugins/OverlappingStackedValueAxes.ts +300 -299
  90. package/src/multiGrid/plugins/OverlappingValueAxes.ts +300 -300
  91. package/src/multiValue/defaults.ts +388 -166
  92. package/src/multiValue/index.ts +13 -9
  93. package/src/multiValue/multiValueObservables.ts +667 -297
  94. package/src/multiValue/plugins/MultiValueLegend.ts +107 -107
  95. package/src/multiValue/plugins/MultiValueTooltip.ts +66 -66
  96. package/src/multiValue/plugins/OrdinalBubbles.ts +0 -0
  97. package/src/multiValue/plugins/OrdinalXAxis.ts +0 -0
  98. package/src/multiValue/plugins/RacingBars.ts +373 -0
  99. package/src/multiValue/plugins/RacingCounterAxis.ts +0 -0
  100. package/src/multiValue/plugins/RacingCounterTexts.ts +300 -0
  101. package/src/multiValue/plugins/RacingValueAxis.ts +115 -0
  102. package/src/multiValue/plugins/RankingAxis_legacy.ts +109 -0
  103. package/src/multiValue/plugins/Scatter.ts +426 -426
  104. package/src/multiValue/plugins/ScatterBubbles.ts +554 -554
  105. package/src/multiValue/plugins/XAxis.ts +108 -0
  106. package/src/multiValue/plugins/XYAux.ts +682 -681
  107. package/src/multiValue/plugins/XYAxes.ts +194 -684
  108. package/src/multiValue/plugins/XYAxes_legacy.ts +684 -0
  109. package/src/multiValue/plugins/{XYZoom.ts → XZoom.ts} +299 -299
  110. package/src/noneData/defaults.ts +102 -102
  111. package/src/noneData/index.ts +3 -3
  112. package/src/noneData/plugins/Container.ts +27 -27
  113. package/src/noneData/plugins/Tooltip.ts +373 -373
  114. package/src/relationship/defaults.ts +220 -218
  115. package/src/relationship/index.ts +5 -5
  116. package/src/relationship/plugins/ForceDirected.ts +1168 -1168
  117. package/src/relationship/plugins/ForceDirectedBubbles.ts +1403 -1403
  118. package/src/relationship/plugins/RelationshipLegend.ts +100 -100
  119. package/src/relationship/plugins/RelationshipTooltip.ts +66 -66
  120. package/src/relationship/relationshipObservables.ts +49 -49
  121. package/src/series/defaults.ts +221 -230
  122. package/src/series/index.ts +9 -9
  123. package/src/series/plugins/Bubbles.ts +636 -620
  124. package/src/series/plugins/Pie.ts +623 -623
  125. package/src/series/plugins/PieEventTexts.ts +284 -284
  126. package/src/series/plugins/PieLabels.ts +640 -640
  127. package/src/series/plugins/Rose.ts +516 -516
  128. package/src/series/plugins/RoseLabels.ts +600 -600
  129. package/src/series/plugins/SeriesLegend.ts +107 -107
  130. package/src/series/plugins/SeriesTooltip.ts +66 -66
  131. package/src/series/seriesObservables.ts +145 -145
  132. package/src/series/seriesUtils.ts +51 -51
  133. package/src/tree/defaults.ts +102 -100
  134. package/src/tree/index.ts +4 -4
  135. package/src/tree/plugins/TreeLegend.ts +100 -100
  136. package/src/tree/plugins/TreeMap.ts +341 -341
  137. package/src/tree/plugins/TreeTooltip.ts +66 -66
  138. package/src/utils/commonUtils.ts +31 -22
  139. package/src/utils/d3Graphics.ts +176 -174
  140. package/src/utils/d3Utils.ts +92 -92
  141. package/src/utils/observables.ts +14 -14
  142. package/src/utils/orbchartsUtils.ts +129 -129
  143. package/tsconfig.base.json +13 -13
  144. package/tsconfig.json +2 -2
  145. package/vite.config.js +22 -22
  146. package/dist/orbcharts-plugins-basic/src/grid/plugins/GridZoom.d.ts +0 -1
  147. package/dist/orbcharts-plugins-basic/src/grid/plugins/StackedBar.d.ts +0 -1
  148. package/dist/orbcharts-plugins-basic/src/index.d.ts +0 -7
  149. package/dist/orbcharts-plugins-basic/src/multiGrid/plugins/MultiStackedBar.d.ts +0 -1
  150. package/dist/orbcharts-plugins-basic/src/multiValue/defaults.d.ts +0 -9
  151. package/dist/orbcharts-plugins-basic/src/multiValue/multiValueObservables.d.ts +0 -33
  152. package/dist/orbcharts-plugins-basic/src/multiValue/plugins/XYZoom.d.ts +0 -1
  153. /package/dist/{orbcharts-plugins-basic/lib → lib}/core-types.d.ts +0 -0
  154. /package/dist/{orbcharts-plugins-basic/lib → lib}/core.d.ts +0 -0
  155. /package/dist/{orbcharts-plugins-basic/lib → lib}/plugins-basic-types.d.ts +0 -0
  156. /package/dist/{orbcharts-plugins-basic/src → src}/base/BaseGroupAxis.d.ts +0 -0
  157. /package/dist/{orbcharts-plugins-basic/src → src}/base/BaseLegend.d.ts +0 -0
  158. /package/dist/{orbcharts-plugins-basic/src → src}/base/BaseTooltip.d.ts +0 -0
  159. /package/dist/{orbcharts-plugins-basic/src → src}/base/types.d.ts +0 -0
  160. /package/dist/{orbcharts-plugins-basic/src → src}/const.d.ts +0 -0
  161. /package/dist/{orbcharts-plugins-basic/src → src}/grid/plugins/Bars.d.ts +0 -0
  162. /package/dist/{orbcharts-plugins-basic/src → src}/grid/plugins/BarsPN.d.ts +0 -0
  163. /package/dist/{orbcharts-plugins-basic/src → src}/grid/plugins/BarsTriangle.d.ts +0 -0
  164. /package/dist/{orbcharts-plugins-basic/src → src}/grid/plugins/Dots.d.ts +0 -0
  165. /package/dist/{orbcharts-plugins-basic/src → src}/grid/plugins/GridLegend.d.ts +0 -0
  166. /package/dist/{orbcharts-plugins-basic/src → src}/grid/plugins/GridTooltip.d.ts +0 -0
  167. /package/dist/{orbcharts-plugins-basic/src → src}/grid/plugins/GroupAux.d.ts +0 -0
  168. /package/dist/{orbcharts-plugins-basic/src → src}/grid/plugins/GroupAxis.d.ts +0 -0
  169. /package/dist/{orbcharts-plugins-basic/src → src}/grid/plugins/LineAreas.d.ts +0 -0
  170. /package/dist/{orbcharts-plugins-basic/src → src}/grid/plugins/Lines.d.ts +0 -0
  171. /package/dist/{orbcharts-plugins-basic/src → src}/grid/plugins/StackedValueAxis.d.ts +0 -0
  172. /package/dist/{orbcharts-plugins-basic/src → src}/grid/plugins/ValueAxis.d.ts +0 -0
  173. /package/dist/{orbcharts-plugins-basic/src → src}/multiGrid/multiGridObservables.d.ts +0 -0
  174. /package/dist/{orbcharts-plugins-basic/src → src}/multiGrid/plugins/MultiBars.d.ts +0 -0
  175. /package/dist/{orbcharts-plugins-basic/src → src}/multiGrid/plugins/MultiBarsTriangle.d.ts +0 -0
  176. /package/dist/{orbcharts-plugins-basic/src → src}/multiGrid/plugins/MultiDots.d.ts +0 -0
  177. /package/dist/{orbcharts-plugins-basic/src → src}/multiGrid/plugins/MultiGridLegend.d.ts +0 -0
  178. /package/dist/{orbcharts-plugins-basic/src → src}/multiGrid/plugins/MultiGridTooltip.d.ts +0 -0
  179. /package/dist/{orbcharts-plugins-basic/src → src}/multiGrid/plugins/MultiGroupAxis.d.ts +0 -0
  180. /package/dist/{orbcharts-plugins-basic/src → src}/multiGrid/plugins/MultiLineAreas.d.ts +0 -0
  181. /package/dist/{orbcharts-plugins-basic/src → src}/multiGrid/plugins/MultiLines.d.ts +0 -0
  182. /package/dist/{orbcharts-plugins-basic/src → src}/multiGrid/plugins/MultiStackedValueAxis.d.ts +0 -0
  183. /package/dist/{orbcharts-plugins-basic/src → src}/multiGrid/plugins/MultiValueAxis.d.ts +0 -0
  184. /package/dist/{orbcharts-plugins-basic/src → src}/multiGrid/plugins/OverlappingStackedValueAxes.d.ts +0 -0
  185. /package/dist/{orbcharts-plugins-basic/src → src}/multiGrid/plugins/OverlappingValueAxes.d.ts +0 -0
  186. /package/dist/{orbcharts-plugins-basic/src → src}/multiValue/plugins/MultiValueLegend.d.ts +0 -0
  187. /package/dist/{orbcharts-plugins-basic/src → src}/multiValue/plugins/MultiValueTooltip.d.ts +0 -0
  188. /package/dist/{orbcharts-plugins-basic/src/multiValue/plugins/Ranking.d.ts → src/multiValue/plugins/OrdinalBubbles.d.ts} +0 -0
  189. /package/dist/{orbcharts-plugins-basic/src/multiValue/plugins/RankingAxis.d.ts → src/multiValue/plugins/OrdinalXAxis.d.ts} +0 -0
  190. /package/dist/{orbcharts-plugins-basic/src/noneData/plugins/Container.d.ts → src/multiValue/plugins/RacingCounterAxis.d.ts} +0 -0
  191. /package/dist/{orbcharts-plugins-basic/src/noneData/plugins/Tooltip.d.ts → src/multiValue/plugins/RankingAxis_legacy.d.ts} +0 -0
  192. /package/dist/{orbcharts-plugins-basic/src → src}/multiValue/plugins/Scatter.d.ts +0 -0
  193. /package/dist/{orbcharts-plugins-basic/src → src}/multiValue/plugins/ScatterBubbles.d.ts +0 -0
  194. /package/dist/{orbcharts-plugins-basic/src → src}/multiValue/plugins/XYAux.d.ts +0 -0
  195. /package/dist/{orbcharts-plugins-basic/src/multiValue/plugins/XYAxes.d.ts → src/multiValue/plugins/XYAxes_legacy.d.ts} +0 -0
  196. /package/dist/{orbcharts-plugins-basic/src → src}/noneData/defaults.d.ts +0 -0
  197. /package/dist/{orbcharts-plugins-basic/src → src}/noneData/index.d.ts +0 -0
  198. /package/dist/{orbcharts-plugins-basic/src/series/plugins/Waffle.d.ts → src/noneData/plugins/Container.d.ts} +0 -0
  199. /package/{src/multiValue/plugins/Ranking.ts → dist/src/noneData/plugins/Tooltip.d.ts} +0 -0
  200. /package/dist/{orbcharts-plugins-basic/src → src}/relationship/defaults.d.ts +0 -0
  201. /package/dist/{orbcharts-plugins-basic/src → src}/relationship/index.d.ts +0 -0
  202. /package/dist/{orbcharts-plugins-basic/src → src}/relationship/plugins/ForceDirected.d.ts +0 -0
  203. /package/dist/{orbcharts-plugins-basic/src → src}/relationship/plugins/ForceDirectedBubbles.d.ts +0 -0
  204. /package/dist/{orbcharts-plugins-basic/src → src}/relationship/plugins/RelationshipLegend.d.ts +0 -0
  205. /package/dist/{orbcharts-plugins-basic/src → src}/relationship/plugins/RelationshipTooltip.d.ts +0 -0
  206. /package/dist/{orbcharts-plugins-basic/src → src}/relationship/relationshipObservables.d.ts +0 -0
  207. /package/dist/{orbcharts-plugins-basic/src → src}/series/defaults.d.ts +0 -0
  208. /package/dist/{orbcharts-plugins-basic/src → src}/series/index.d.ts +0 -0
  209. /package/dist/{orbcharts-plugins-basic/src → src}/series/plugins/Bubbles.d.ts +0 -0
  210. /package/dist/{orbcharts-plugins-basic/src → src}/series/plugins/Pie.d.ts +0 -0
  211. /package/dist/{orbcharts-plugins-basic/src → src}/series/plugins/PieEventTexts.d.ts +0 -0
  212. /package/dist/{orbcharts-plugins-basic/src → src}/series/plugins/PieLabels.d.ts +0 -0
  213. /package/dist/{orbcharts-plugins-basic/src → src}/series/plugins/Rose.d.ts +0 -0
  214. /package/dist/{orbcharts-plugins-basic/src → src}/series/plugins/RoseLabels.d.ts +0 -0
  215. /package/dist/{orbcharts-plugins-basic/src → src}/series/plugins/SeriesLegend.d.ts +0 -0
  216. /package/dist/{orbcharts-plugins-basic/src → src}/series/plugins/SeriesTooltip.d.ts +0 -0
  217. /package/{src/multiValue/plugins/RankingAxis.ts → dist/src/series/plugins/Waffle.d.ts} +0 -0
  218. /package/dist/{orbcharts-plugins-basic/src → src}/series/seriesObservables.d.ts +0 -0
  219. /package/dist/{orbcharts-plugins-basic/src → src}/series/seriesUtils.d.ts +0 -0
  220. /package/dist/{orbcharts-plugins-basic/src → src}/tree/defaults.d.ts +0 -0
  221. /package/dist/{orbcharts-plugins-basic/src → src}/tree/index.d.ts +0 -0
  222. /package/dist/{orbcharts-plugins-basic/src → src}/tree/plugins/TreeLegend.d.ts +0 -0
  223. /package/dist/{orbcharts-plugins-basic/src → src}/tree/plugins/TreeMap.d.ts +0 -0
  224. /package/dist/{orbcharts-plugins-basic/src → src}/tree/plugins/TreeTooltip.d.ts +0 -0
  225. /package/dist/{orbcharts-plugins-basic/src → src}/utils/d3Utils.d.ts +0 -0
  226. /package/dist/{orbcharts-plugins-basic/src → src}/utils/observables.d.ts +0 -0
  227. /package/dist/{orbcharts-plugins-basic/src → src}/utils/orbchartsUtils.d.ts +0 -0
  228. /package/dist/{orbcharts-plugins-basic/vite.config.d.ts → vite.config.d.ts} +0 -0
@@ -1,707 +1,707 @@
1
- import * as d3 from 'd3'
2
- import {
3
- combineLatest,
4
- map,
5
- filter,
6
- switchMap,
7
- takeUntil,
8
- distinctUntilChanged,
9
- Observable,
10
- Subject } from 'rxjs'
11
- import type { BasePluginFn } from './types'
12
- import type {
13
- ComputedDatumGrid,
14
- ComputedDataGrid,
15
- ComputedLayoutDatumGrid,
16
- ComputedLayoutDataGrid,
17
- DataFormatterGrid,
18
- EventGrid,
19
- ContainerPositionScaled,
20
- ChartParams,
21
- Layout,
22
- TransformData
23
- } from '../../lib/core-types'
24
- import type { BaseLinesParams } from '../../lib/plugins-basic-types'
25
- import { getD3TransitionEase } from '../utils/d3Utils'
26
- import { getClassName, getUniID } from '../utils/orbchartsUtils'
27
- import { gridGroupPositionFnObservable } from '../grid/gridObservables'
28
- import { gridSelectionsObservable } from '../grid/gridObservables'
29
-
30
- // export interface BaseLinesParams {
31
- // // lineType: LineType
32
- // lineCurve: string
33
- // lineWidth: number
34
- // // labelFn: (d: ComputedDatumSeries) => string
35
- // // labelPositionFn: (d: ComputedDatumSeries) => 'top' | 'bottom' | 'left' | 'right' | 'center'
36
- // // labelStyleFn: (d: ComputedDatumSeries) => string
37
- // // labelFontSizeFn: (d: ComputedDatumSeries) => number
38
- // // labelColorFn: (d: ComputedDatumSeries) => string
39
- // // labelPadding: number
40
- // }
41
-
42
- interface BaseLinesContext {
43
- selection: d3.Selection<any, unknown, any, unknown>
44
- computedData$: Observable<ComputedDataGrid>
45
- computedLayoutData$: Observable<ComputedLayoutDataGrid>
46
- visibleComputedData$: Observable<ComputedDatumGrid[][]>
47
- visibleComputedLayoutData$: Observable<ComputedLayoutDataGrid>
48
- seriesLabels$: Observable<string[]>
49
- SeriesDataMap$: Observable<Map<string, ComputedDatumGrid[]>>
50
- GroupDataMap$: Observable<Map<string, ComputedDatumGrid[]>>
51
- fullDataFormatter$: Observable<DataFormatterGrid>
52
- fullParams$: Observable<BaseLinesParams>
53
- fullChartParams$: Observable<ChartParams>
54
- gridAxesTransform$: Observable<TransformData>
55
- gridGraphicTransform$: Observable<TransformData>
56
- gridAxesSize$: Observable<{
57
- width: number;
58
- height: number;
59
- }>
60
- gridHighlight$: Observable<ComputedDatumGrid[]>
61
- gridContainerPosition$: Observable<ContainerPositionScaled[]>
62
- allContainerPosition$: Observable<ContainerPositionScaled[]>
63
- layout$: Observable<Layout>
64
- event$: Subject<EventGrid>
65
- }
66
-
67
-
68
- type ClipPathDatum = {
69
- id: string;
70
- // x: number;
71
- // y: number;
72
- width: number;
73
- height: number;
74
- }
75
-
76
- // const pluginName = 'Lines'
77
- // const pathClassName = getClassName(pluginName, 'path')
78
-
79
-
80
- function createLinePath (lineCurve: string = 'curveLinear'): d3.Line<ComputedLayoutDatumGrid> {
81
- return d3.line<ComputedLayoutDatumGrid>()
82
- .x((d) => d.axisX)
83
- .y((d) => d.axisY)
84
- .curve((d3 as any)[lineCurve])
85
- }
86
-
87
- // 依無值的資料分段
88
- function makeSegmentData (data: ComputedLayoutDatumGrid[]): ComputedLayoutDatumGrid[][] {
89
- let segmentData: ComputedLayoutDatumGrid[][] = [[]]
90
-
91
- let currentIndex = 0
92
- for (let i in data) {
93
- if (data[i].visible == false || data[i].value === undefined || data[i].value === null) {
94
- // 換下一段的 index
95
- if (segmentData[currentIndex].length) {
96
- currentIndex ++
97
- segmentData[currentIndex] = []
98
- }
99
- continue
100
- }
101
- segmentData[currentIndex].push(data[i])
102
- }
103
-
104
- return segmentData
105
- }
106
-
107
-
108
- function renderLines ({ selection, pathClassName, segmentData, linePath, params }: {
109
- selection: d3.Selection<SVGGElement, unknown, any, unknown>
110
- pathClassName: string
111
- segmentData: ComputedLayoutDatumGrid[][]
112
- linePath: d3.Line<ComputedLayoutDatumGrid>
113
- params: BaseLinesParams
114
- }): d3.Selection<SVGPathElement, ComputedLayoutDatumGrid[], any, any> {
115
- // if (!data[0]) {
116
- // return undefined
117
- // }
118
-
119
- const lines = selection
120
- .selectAll<SVGPathElement, ComputedLayoutDatumGrid[]>('path')
121
- .data(segmentData, (d, i) => d.length ? `${d[0].id}_${d[d.length - 1].id}` : i) // 以線段起迄id結合為線段id
122
- .join(
123
- enter => {
124
- return enter
125
- .append<SVGPathElement>('path')
126
- .classed(pathClassName, true)
127
- .attr("fill","none")
128
- .attr('pointer-events', 'visibleStroke') // 只對線條產生事件
129
- .style('vector-effect', 'non-scaling-stroke')
130
- .style('cursor', 'pointer')
131
- },
132
- update => update,
133
- exit => exit.remove()
134
- )
135
- .attr("stroke-width", params.lineWidth)
136
- .attr("stroke", (d, i) => d[0] && d[0].color)
137
- .attr("d", (d) => {
138
- return linePath(d)
139
- })
140
-
141
- return lines
142
- }
143
-
144
- function highlightLines ({ selection, seriesLabel, fullChartParams }: {
145
- selection: d3.Selection<any, string, any, any>
146
- seriesLabel: string | null
147
- fullChartParams: ChartParams
148
- }) {
149
- selection.interrupt('highlight')
150
- if (!seriesLabel) {
151
- // remove highlight
152
- selection
153
- .transition('highlight')
154
- .duration(200)
155
- .style('opacity', 1)
156
- return
157
- }
158
-
159
- selection
160
- .each((currentSeriesLabel, i, n) => {
161
- // const currentSeriesLabel = d[0] ? d[0].seriesLabel : ''
162
-
163
- if (currentSeriesLabel === seriesLabel) {
164
- d3.select(n[i])
165
- .style('opacity', 1)
166
- } else {
167
- d3.select(n[i])
168
- .style('opacity', fullChartParams.styles.unhighlightedOpacity)
169
- }
170
- })
171
- }
172
-
173
- function renderClipPath ({ defsSelection, clipPathData, transitionDuration, transitionEase }: {
174
- defsSelection: d3.Selection<SVGDefsElement, any, any, any>
175
- clipPathData: ClipPathDatum[]
176
- transitionDuration: number
177
- transitionEase: string
178
- }) {
179
- const clipPath = defsSelection
180
- .selectAll<SVGClipPathElement, Layout>('clipPath')
181
- .data(clipPathData)
182
- .join(
183
- enter => {
184
- return enter
185
- .append('clipPath')
186
- },
187
- update => update,
188
- exit => exit.remove()
189
- )
190
- .attr('id', d => d.id)
191
- .each((d, i, g) => {
192
- const rect = d3.select(g[i])
193
- .selectAll<SVGRectElement, typeof d>('rect')
194
- .data([d])
195
- .join(
196
- enter => {
197
- const enterSelection = enter
198
- .append('rect')
199
- enterSelection
200
- .transition()
201
- .duration(transitionDuration)
202
- .ease(getD3TransitionEase(transitionEase))
203
- // .delay(100) // @Q@ 不知為何如果沒加 delay位置會有點跑掉
204
- .tween('tween', (_d, _i, _g) => {
205
- return (t) => {
206
- const transitionWidth = _d.width * t
207
-
208
- enterSelection
209
- .attr('x', 0)
210
- .attr('y', 0)
211
- .attr('width', _d => transitionWidth)
212
- .attr('height', _d => _d.height)
213
- }
214
- })
215
- return enterSelection
216
- },
217
- update => {
218
- return update
219
- .attr('x', 0)
220
- .attr('y', 0)
221
- .attr('width', _d => _d.width)
222
- .attr('height', _d => _d.height)
223
- },
224
- exit => exit.remove()
225
- )
226
- })
227
-
228
- }
229
-
230
- export const createBaseLines: BasePluginFn<BaseLinesContext> = (pluginName: string, {
231
- selection,
232
- computedData$,
233
- computedLayoutData$,
234
- visibleComputedData$,
235
- visibleComputedLayoutData$,
236
- seriesLabels$,
237
- SeriesDataMap$,
238
- GroupDataMap$,
239
- fullParams$,
240
- fullDataFormatter$,
241
- fullChartParams$,
242
- gridAxesTransform$,
243
- gridGraphicTransform$,
244
- gridAxesSize$,
245
- gridHighlight$,
246
- gridContainerPosition$,
247
- allContainerPosition$,
248
- layout$,
249
- event$
250
- }) => {
251
-
252
- const destroy$ = new Subject()
253
-
254
- const clipPathID = getUniID(pluginName, 'clipPath-box')
255
- const pathClassName = getClassName(pluginName, 'path')
256
- // const clipPathSeriesID = getUniID(pluginName, 'clipPath')
257
-
258
- // const axisSelection: d3.Selection<SVGGElement, any, any, any> = selection
259
- // .append('g')
260
- // .attr('clip-path', `url(#${clipPathID})`)
261
- // const defsSelection: d3.Selection<SVGDefsElement, any, any, any> = axisSelection.append('defs')
262
- // const graphicGSelection: d3.Selection<SVGGElement, any, any, any> = axisSelection.append('g')
263
- // const graphicSelection$: Subject<d3.Selection<SVGGElement, string, any, any>> = new Subject()
264
-
265
-
266
- // gridAxesTransform$
267
- // .pipe(
268
- // takeUntil(destroy$),
269
- // map(d => d.value),
270
- // distinctUntilChanged()
271
- // ).subscribe(d => {
272
- // axisSelection
273
- // .style('transform', d)
274
- // })
275
-
276
- // gridGraphicTransform$
277
- // .pipe(
278
- // takeUntil(destroy$),
279
- // map(d => d.value),
280
- // distinctUntilChanged()
281
- // ).subscribe(d => {
282
- // graphicGSelection
283
- // .transition()
284
- // .duration(50)
285
- // .style('transform', d)
286
- // })
287
-
288
- // const seriesSelection$ = computedData$.pipe(
289
- // takeUntil(destroy$),
290
- // distinctUntilChanged((a, b) => {
291
- // // 只有當series的數量改變時,才重新計算
292
- // return a.length === b.length
293
- // }),
294
- // map((computedData, i) => {
295
- // return selection
296
- // .selectAll<SVGGElement, ComputedDatumGrid[]>(`g.${seriesClassName}`)
297
- // .data(computedData, d => d[0] ? d[0].seriesIndex : i)
298
- // .join(
299
- // enter => {
300
- // return enter
301
- // .append('g')
302
- // .classed(seriesClassName, true)
303
- // .each((d, i, g) => {
304
- // const axesSelection = d3.select(g[i])
305
- // .selectAll<SVGGElement, ComputedDatumGrid[]>(`g.${axesClassName}`)
306
- // .data([i])
307
- // .join(
308
- // enter => {
309
- // return enter
310
- // .append('g')
311
- // .classed(axesClassName, true)
312
- // .attr('clip-path', `url(#${clipPathID})`)
313
- // .each((d, i, g) => {
314
- // const defsSelection = d3.select(g[i])
315
- // .selectAll<SVGDefsElement, any>('defs')
316
- // .data([i])
317
- // .join('defs')
318
-
319
- // const graphicGSelection = d3.select(g[i])
320
- // .selectAll<SVGGElement, any>('g')
321
- // .data([i])
322
- // .join('g')
323
- // .classed(graphicClassName, true)
324
- // })
325
- // },
326
- // update => update,
327
- // exit => exit.remove()
328
- // )
329
- // })
330
- // },
331
- // update => update,
332
- // exit => exit.remove()
333
- // )
334
- // })
335
- // )
336
-
337
- // combineLatest({
338
- // seriesSelection: seriesSelection$,
339
- // gridContainerPosition: gridContainerPosition$
340
- // }).pipe(
341
- // takeUntil(destroy$),
342
- // switchMap(async d => d)
343
- // ).subscribe(data => {
344
- // data.seriesSelection
345
- // .transition()
346
- // .attr('transform', (d, i) => {
347
- // const translate = data.gridContainerPosition[i].translate
348
- // const scale = data.gridContainerPosition[i].scale
349
- // return `translate(${translate[0]}, ${translate[1]}) scale(${scale[0]}, ${scale[1]})`
350
- // })
351
- // })
352
-
353
-
354
- // const axesSelection$ = combineLatest({
355
- // seriesSelection: seriesSelection$,
356
- // gridAxesTransform: gridAxesTransform$
357
- // }).pipe(
358
- // takeUntil(destroy$),
359
- // switchMap(async d => d),
360
- // map(data => {
361
- // return data.seriesSelection
362
- // .select<SVGGElement>(`g.${axesClassName}`)
363
- // .style('transform', data.gridAxesTransform.value)
364
- // })
365
- // )
366
- // const defsSelection$ = axesSelection$.pipe(
367
- // takeUntil(destroy$),
368
- // map(axesSelection => {
369
- // return axesSelection.select<SVGDefsElement>('defs')
370
- // })
371
- // )
372
- // const graphicGSelection$ = combineLatest({
373
- // axesSelection: axesSelection$,
374
- // gridGraphicTransform: gridGraphicTransform$
375
- // }).pipe(
376
- // takeUntil(destroy$),
377
- // switchMap(async d => d),
378
- // map(data => {
379
- // const graphicGSelection = data.axesSelection
380
- // .select<SVGGElement>(`g.${graphicClassName}`)
381
- // .attr('clip-path', (d) => `url(#${clipPathSeriesID}-${d[0] ? d[0].seriesLabel : ''})`)
382
- // graphicGSelection
383
- // .transition()
384
- // .duration(50)
385
- // .style('transform', data.gridGraphicTransform.value)
386
- // return graphicGSelection
387
- // })
388
- // )
389
-
390
- const {
391
- seriesSelection$,
392
- axesSelection$,
393
- defsSelection$,
394
- graphicGSelection$
395
- } = gridSelectionsObservable({
396
- selection,
397
- pluginName,
398
- clipPathID,
399
- seriesLabels$,
400
- gridContainerPosition$,
401
- gridAxesTransform$,
402
- gridGraphicTransform$
403
- })
404
-
405
- const linePath$: Observable<d3.Line<ComputedLayoutDatumGrid>> = new Observable(subscriber => {
406
- const paramsSubscription = fullParams$
407
- .pipe(
408
- takeUntil(destroy$)
409
- )
410
- .subscribe(d => {
411
- if (!d) return
412
- const linePath = createLinePath(d.lineCurve)
413
- subscriber.next(linePath)
414
- })
415
- return () => {
416
- paramsSubscription.unsubscribe()
417
- }
418
- })
419
-
420
- // // 顯示範圍內的series labels
421
- // const seriesLabels$: Observable<string[]> = new Observable(subscriber => {
422
- // computedData$.pipe(
423
- // takeUntil(destroy$),
424
- // switchMap(async (d) => d),
425
- // ).subscribe(data => {
426
- // const labels = data[0] && data[0][0]
427
- // ? data.map(d => d[0].seriesLabel)
428
- // : []
429
- // subscriber.next(labels)
430
- // })
431
- // })
432
-
433
- // const axisSize$ = gridAxisSizeObservable({
434
- // fullDataFormatter$,
435
- // computedLayout$
436
- // })
437
-
438
- const transitionDuration$ = fullChartParams$
439
- .pipe(
440
- map(d => d.transitionDuration),
441
- distinctUntilChanged()
442
- )
443
-
444
- const transitionEase$ = fullChartParams$
445
- .pipe(
446
- map(d => d.transitionEase),
447
- distinctUntilChanged()
448
- )
449
-
450
- const clipPathSubscription = combineLatest({
451
- defsSelection: defsSelection$,
452
- seriesLabels: seriesLabels$,
453
- axisSize: gridAxesSize$,
454
- transitionDuration: transitionDuration$,
455
- transitionEase: transitionEase$
456
- }).pipe(
457
- takeUntil(destroy$),
458
- switchMap(async (d) => d),
459
- ).subscribe(data => {
460
- // 外層的遮罩
461
- const clipPathBox = [{
462
- id: clipPathID,
463
- width: data.axisSize.width,
464
- height: data.axisSize.height
465
- }]
466
- // 各別線條的遮罩(各別動畫)
467
- const clipPathData = clipPathBox.concat(
468
- data.seriesLabels.map(d => {
469
- return {
470
- id: `orbcharts__clipPath_${d}`,
471
- width: data.axisSize.width,
472
- height: data.axisSize.height
473
- }
474
- })
475
- )
476
- renderClipPath({
477
- defsSelection: data.defsSelection,
478
- clipPathData,
479
- transitionDuration: data.transitionDuration,
480
- transitionEase: data.transitionEase
481
- })
482
- })
483
-
484
- // const SeriesDataMap$ = computedData$.pipe(
485
- // map(d => makeGridSeriesDataMap(d))
486
- // )
487
-
488
- // const GroupDataMap$ = computedData$.pipe(
489
- // map(d => makeGridGroupDataMap(d))
490
- // )
491
-
492
- const DataMap$ = computedData$.pipe(
493
- map(d => {
494
- const DataMap: Map<string, ComputedDatumGrid> = new Map()
495
- d.flat().forEach(_d => DataMap.set(_d.id, _d))
496
- return DataMap
497
- })
498
- )
499
-
500
- // 取得事件座標的group資料
501
- const gridGroupPositionFn$ = gridGroupPositionFnObservable({
502
- fullDataFormatter$,
503
- gridAxesSize$: gridAxesSize$,
504
- computedData$: computedData$,
505
- fullChartParams$: fullChartParams$,
506
- gridContainerPosition$: allContainerPosition$,
507
- layout$: layout$
508
- })
509
-
510
- const highlightTarget$ = fullChartParams$.pipe(
511
- takeUntil(destroy$),
512
- map(d => d.highlightTarget),
513
- distinctUntilChanged()
514
- )
515
-
516
- const pathSelectionArr$ = combineLatest({
517
- graphicGSelection: graphicGSelection$,
518
- visibleComputedLayoutData: visibleComputedLayoutData$,
519
- linePath: linePath$,
520
- params: fullParams$,
521
- }).pipe(
522
- takeUntil(destroy$),
523
- switchMap(async (d) => d),
524
- map(data => {
525
- // const updateGraphic = data.graphicGSelection
526
- // .selectAll<SVGGElement, number>('g')
527
- // .data(data.seriesLabels, (d, i) => d)
528
- // const enterGraphic = updateGraphic.enter()
529
- // .append('g')
530
- // .classed(graphicClassName, true)
531
- // updateGraphic.exit().remove()
532
- // const graphicSelection = updateGraphic.merge(enterGraphic)
533
- // .attr('clip-path', (d, i) => `url(#orbcharts__clipPath_${d})`)
534
- let pathSelectionArr: d3.Selection<SVGPathElement, ComputedLayoutDatumGrid[], any, any>[] = []
535
-
536
- // 繪圖
537
- data.graphicGSelection.each((d, i, all) => {
538
- // 將資料分段
539
- const segmentData = makeSegmentData(data.visibleComputedLayoutData[i] ?? [])
540
-
541
- pathSelectionArr[i] = renderLines({
542
- selection: d3.select(all[i]),
543
- pathClassName,
544
- linePath: data.linePath,
545
- segmentData: segmentData,
546
- params: data.params
547
- })
548
- })
549
-
550
- return pathSelectionArr
551
- })
552
- )
553
-
554
- combineLatest({
555
- pathSelectionArr: pathSelectionArr$,
556
- computedData: computedData$,
557
- SeriesDataMap: SeriesDataMap$,
558
- GroupDataMap: GroupDataMap$,
559
- highlightTarget: highlightTarget$,
560
- gridGroupPositionFn: gridGroupPositionFn$,
561
- }).pipe(
562
- takeUntil(destroy$),
563
- switchMap(async (d) => d)
564
- ).subscribe(data => {
565
- data.pathSelectionArr.forEach(pathSelection => {
566
- pathSelection
567
- .on('mouseover', (event, datum) => {
568
- event.stopPropagation()
569
-
570
- const seriesLabel = datum[0] ? datum[0].seriesLabel : ''
571
- const { groupIndex, groupLabel } = data.gridGroupPositionFn(event)
572
- // console.log('groupIndex', groupIndex)
573
- const groupData = data.GroupDataMap.get(groupLabel)!
574
- const targetDatum = groupData.find(d => d.seriesLabel === seriesLabel)
575
- const _datum = targetDatum ?? datum[0]
576
-
577
- event$.next({
578
- type: 'grid',
579
- eventName: 'mouseover',
580
- pluginName,
581
- highlightTarget: data.highlightTarget,
582
- datum: _datum,
583
- gridIndex: _datum.gridIndex,
584
- series: data.SeriesDataMap.get(_datum.seriesLabel)!,
585
- seriesIndex: _datum.seriesIndex,
586
- seriesLabel: _datum.seriesLabel,
587
- group: data.GroupDataMap.get(_datum.groupLabel)!,
588
- groupIndex: _datum.groupIndex,
589
- groupLabel: _datum.groupLabel,
590
- event,
591
- data: data.computedData
592
- })
593
- })
594
- .on('mousemove', (event, datum) => {
595
- event.stopPropagation()
596
-
597
- const seriesLabel = datum[0] ? datum[0].seriesLabel : ''
598
- const { groupIndex, groupLabel } = data.gridGroupPositionFn(event)
599
- const groupData = data.GroupDataMap.get(groupLabel)!
600
- const targetDatum = groupData.find(d => d.seriesLabel === seriesLabel)
601
- const _datum = targetDatum ?? datum[0]
602
-
603
- event$.next({
604
- type: 'grid',
605
- eventName: 'mousemove',
606
- pluginName,
607
- highlightTarget: data.highlightTarget,
608
- datum: _datum,
609
- gridIndex: _datum.gridIndex,
610
- series: data.SeriesDataMap.get(_datum.seriesLabel)!,
611
- seriesIndex: _datum.seriesIndex,
612
- seriesLabel: _datum.seriesLabel,
613
- group: data.GroupDataMap.get(_datum.groupLabel)!,
614
- groupIndex: _datum.groupIndex,
615
- groupLabel: _datum.groupLabel,
616
- event,
617
- data: data.computedData
618
- })
619
- })
620
- .on('mouseout', (event, datum) => {
621
- event.stopPropagation()
622
-
623
- const seriesLabel = datum[0] ? datum[0].seriesLabel : ''
624
- const { groupIndex, groupLabel } = data.gridGroupPositionFn(event)
625
- const groupData = data.GroupDataMap.get(groupLabel)!
626
- const targetDatum = groupData.find(d => d.seriesLabel === seriesLabel)
627
- const _datum = targetDatum ?? datum[0]
628
-
629
- event$.next({
630
- type: 'grid',
631
- eventName: 'mouseout',
632
- pluginName,
633
- highlightTarget: data.highlightTarget,
634
- datum: _datum,
635
- gridIndex: _datum.gridIndex,
636
- series: data.SeriesDataMap.get(_datum.seriesLabel)!,
637
- seriesIndex: _datum.seriesIndex,
638
- seriesLabel: _datum.seriesLabel,
639
- group: data.GroupDataMap.get(_datum.groupLabel)!,
640
- groupIndex: _datum.groupIndex,
641
- groupLabel: _datum.groupLabel,
642
- event,
643
- data: data.computedData
644
- })
645
- })
646
- .on('click', (event, datum) => {
647
- event.stopPropagation()
648
-
649
- const seriesLabel = datum[0] ? datum[0].seriesLabel : ''
650
- const { groupIndex, groupLabel } = data.gridGroupPositionFn(event)
651
- const groupData = data.GroupDataMap.get(groupLabel)!
652
- const targetDatum = groupData.find(d => d.seriesLabel === seriesLabel)
653
- const _datum = targetDatum ?? datum[0]
654
-
655
- event$.next({
656
- type: 'grid',
657
- eventName: 'click',
658
- pluginName,
659
- highlightTarget: data.highlightTarget,
660
- datum: _datum,
661
- gridIndex: _datum.gridIndex,
662
- series: data.SeriesDataMap.get(_datum.seriesLabel)!,
663
- seriesIndex: _datum.seriesIndex,
664
- seriesLabel: _datum.seriesLabel,
665
- group: data.GroupDataMap.get(_datum.groupLabel)!,
666
- groupIndex: _datum.groupIndex,
667
- groupLabel: _datum.groupLabel,
668
- event,
669
- data: data.computedData
670
- })
671
- })
672
- })
673
- })
674
-
675
- // const datumList$ = computedData$.pipe(
676
- // takeUntil(destroy$),
677
- // map(d => d.flat())
678
- // )
679
- // const highlight$ = highlightObservable({ datumList$, fullChartParams$, event$: store.event$ })
680
- // const highlightSubscription = gridHighlight$.subscribe()
681
-
682
- fullChartParams$.pipe(
683
- takeUntil(destroy$),
684
- filter(d => d.highlightTarget === 'series'),
685
- switchMap(d => combineLatest({
686
- graphicGSelection: graphicGSelection$,
687
- gridHighlight: gridHighlight$,
688
- DataMap: DataMap$,
689
- fullChartParams: fullChartParams$
690
- }).pipe(
691
- takeUntil(destroy$),
692
- switchMap(async d => d)
693
- ))
694
- ).subscribe(data => {
695
- const seriesLabel = data.gridHighlight[0] ? data.gridHighlight[0].seriesLabel : null
696
- highlightLines({
697
- selection: data.graphicGSelection,
698
- seriesLabel,
699
- fullChartParams: data.fullChartParams
700
- })
701
- })
702
-
703
- return () => {
704
- destroy$.next(undefined)
705
- // highlightSubscription.unsubscribe()
706
- }
1
+ import * as d3 from 'd3'
2
+ import {
3
+ combineLatest,
4
+ map,
5
+ filter,
6
+ switchMap,
7
+ takeUntil,
8
+ distinctUntilChanged,
9
+ Observable,
10
+ Subject } from 'rxjs'
11
+ import type { BasePluginFn } from './types'
12
+ import type {
13
+ ComputedDatumGrid,
14
+ ComputedDataGrid,
15
+ ComputedLayoutDatumGrid,
16
+ ComputedAxesDataGrid,
17
+ DataFormatterGrid,
18
+ EventGrid,
19
+ ContainerPositionScaled,
20
+ ChartParams,
21
+ Layout,
22
+ TransformData
23
+ } from '../../lib/core-types'
24
+ import type { BaseLinesParams } from '../../lib/plugins-basic-types'
25
+ import { getD3TransitionEase } from '../utils/d3Utils'
26
+ import { getClassName, getUniID } from '../utils/orbchartsUtils'
27
+ import { gridGroupPositionFnObservable } from '../grid/gridObservables'
28
+ import { gridSelectionsObservable } from '../grid/gridObservables'
29
+
30
+ // export interface BaseLinesParams {
31
+ // // lineType: LineType
32
+ // lineCurve: string
33
+ // lineWidth: number
34
+ // // labelFn: (d: ComputedDatumSeries) => string
35
+ // // labelPositionFn: (d: ComputedDatumSeries) => 'top' | 'bottom' | 'left' | 'right' | 'center'
36
+ // // labelStyleFn: (d: ComputedDatumSeries) => string
37
+ // // labelFontSizeFn: (d: ComputedDatumSeries) => number
38
+ // // labelColorFn: (d: ComputedDatumSeries) => string
39
+ // // labelPadding: number
40
+ // }
41
+
42
+ interface BaseLinesContext {
43
+ selection: d3.Selection<any, unknown, any, unknown>
44
+ computedData$: Observable<ComputedDataGrid>
45
+ computedAxesData$: Observable<ComputedAxesDataGrid>
46
+ visibleComputedData$: Observable<ComputedDatumGrid[][]>
47
+ visibleComputedAxesData$: Observable<ComputedAxesDataGrid>
48
+ seriesLabels$: Observable<string[]>
49
+ SeriesDataMap$: Observable<Map<string, ComputedDatumGrid[]>>
50
+ GroupDataMap$: Observable<Map<string, ComputedDatumGrid[]>>
51
+ fullDataFormatter$: Observable<DataFormatterGrid>
52
+ fullParams$: Observable<BaseLinesParams>
53
+ fullChartParams$: Observable<ChartParams>
54
+ gridAxesTransform$: Observable<TransformData>
55
+ gridGraphicTransform$: Observable<TransformData>
56
+ gridAxesSize$: Observable<{
57
+ width: number;
58
+ height: number;
59
+ }>
60
+ gridHighlight$: Observable<ComputedDatumGrid[]>
61
+ gridContainerPosition$: Observable<ContainerPositionScaled[]>
62
+ allContainerPosition$: Observable<ContainerPositionScaled[]>
63
+ layout$: Observable<Layout>
64
+ event$: Subject<EventGrid>
65
+ }
66
+
67
+
68
+ type ClipPathDatum = {
69
+ id: string;
70
+ // x: number;
71
+ // y: number;
72
+ width: number;
73
+ height: number;
74
+ }
75
+
76
+ // const pluginName = 'Lines'
77
+ // const pathClassName = getClassName(pluginName, 'path')
78
+
79
+
80
+ function createLinePath (lineCurve: string = 'curveLinear'): d3.Line<ComputedLayoutDatumGrid> {
81
+ return d3.line<ComputedLayoutDatumGrid>()
82
+ .x((d) => d.axisX)
83
+ .y((d) => d.axisY)
84
+ .curve((d3 as any)[lineCurve])
85
+ }
86
+
87
+ // 依無值的資料分段
88
+ function makeSegmentData (data: ComputedLayoutDatumGrid[]): ComputedLayoutDatumGrid[][] {
89
+ let segmentData: ComputedLayoutDatumGrid[][] = [[]]
90
+
91
+ let currentIndex = 0
92
+ for (let i in data) {
93
+ if (data[i].visible == false || data[i].value === undefined || data[i].value === null) {
94
+ // 換下一段的 index
95
+ if (segmentData[currentIndex].length) {
96
+ currentIndex ++
97
+ segmentData[currentIndex] = []
98
+ }
99
+ continue
100
+ }
101
+ segmentData[currentIndex].push(data[i])
102
+ }
103
+
104
+ return segmentData
105
+ }
106
+
107
+
108
+ function renderLines ({ selection, pathClassName, segmentData, linePath, params }: {
109
+ selection: d3.Selection<SVGGElement, unknown, any, unknown>
110
+ pathClassName: string
111
+ segmentData: ComputedLayoutDatumGrid[][]
112
+ linePath: d3.Line<ComputedLayoutDatumGrid>
113
+ params: BaseLinesParams
114
+ }): d3.Selection<SVGPathElement, ComputedLayoutDatumGrid[], any, any> {
115
+ // if (!data[0]) {
116
+ // return undefined
117
+ // }
118
+
119
+ const lines = selection
120
+ .selectAll<SVGPathElement, ComputedLayoutDatumGrid[]>('path')
121
+ .data(segmentData, (d, i) => d.length ? `${d[0].id}_${d[d.length - 1].id}` : i) // 以線段起迄id結合為線段id
122
+ .join(
123
+ enter => {
124
+ return enter
125
+ .append<SVGPathElement>('path')
126
+ .classed(pathClassName, true)
127
+ .attr("fill","none")
128
+ .attr('pointer-events', 'visibleStroke') // 只對線條產生事件
129
+ .style('vector-effect', 'non-scaling-stroke')
130
+ .style('cursor', 'pointer')
131
+ },
132
+ update => update,
133
+ exit => exit.remove()
134
+ )
135
+ .attr("stroke-width", params.lineWidth)
136
+ .attr("stroke", (d, i) => d[0] && d[0].color)
137
+ .attr("d", (d) => {
138
+ return linePath(d)
139
+ })
140
+
141
+ return lines
142
+ }
143
+
144
+ function highlightLines ({ selection, seriesLabel, fullChartParams }: {
145
+ selection: d3.Selection<any, string, any, any>
146
+ seriesLabel: string | null
147
+ fullChartParams: ChartParams
148
+ }) {
149
+ selection.interrupt('highlight')
150
+ if (!seriesLabel) {
151
+ // remove highlight
152
+ selection
153
+ .transition('highlight')
154
+ .duration(200)
155
+ .style('opacity', 1)
156
+ return
157
+ }
158
+
159
+ selection
160
+ .each((currentSeriesLabel, i, n) => {
161
+ // const currentSeriesLabel = d[0] ? d[0].seriesLabel : ''
162
+
163
+ if (currentSeriesLabel === seriesLabel) {
164
+ d3.select(n[i])
165
+ .style('opacity', 1)
166
+ } else {
167
+ d3.select(n[i])
168
+ .style('opacity', fullChartParams.styles.unhighlightedOpacity)
169
+ }
170
+ })
171
+ }
172
+
173
+ function renderClipPath ({ defsSelection, clipPathData, transitionDuration, transitionEase }: {
174
+ defsSelection: d3.Selection<SVGDefsElement, any, any, any>
175
+ clipPathData: ClipPathDatum[]
176
+ transitionDuration: number
177
+ transitionEase: string
178
+ }) {
179
+ const clipPath = defsSelection
180
+ .selectAll<SVGClipPathElement, Layout>('clipPath')
181
+ .data(clipPathData)
182
+ .join(
183
+ enter => {
184
+ return enter
185
+ .append('clipPath')
186
+ },
187
+ update => update,
188
+ exit => exit.remove()
189
+ )
190
+ .attr('id', d => d.id)
191
+ .each((d, i, g) => {
192
+ const rect = d3.select(g[i])
193
+ .selectAll<SVGRectElement, typeof d>('rect')
194
+ .data([d])
195
+ .join(
196
+ enter => {
197
+ const enterSelection = enter
198
+ .append('rect')
199
+ enterSelection
200
+ .transition()
201
+ .duration(transitionDuration)
202
+ .ease(getD3TransitionEase(transitionEase))
203
+ // .delay(100) // @Q@ 不知為何如果沒加 delay位置會有點跑掉
204
+ .tween('tween', (_d, _i, _g) => {
205
+ return (t) => {
206
+ const transitionWidth = _d.width * t
207
+
208
+ enterSelection
209
+ .attr('x', 0)
210
+ .attr('y', 0)
211
+ .attr('width', _d => transitionWidth)
212
+ .attr('height', _d => _d.height)
213
+ }
214
+ })
215
+ return enterSelection
216
+ },
217
+ update => {
218
+ return update
219
+ .attr('x', 0)
220
+ .attr('y', 0)
221
+ .attr('width', _d => _d.width)
222
+ .attr('height', _d => _d.height)
223
+ },
224
+ exit => exit.remove()
225
+ )
226
+ })
227
+
228
+ }
229
+
230
+ export const createBaseLines: BasePluginFn<BaseLinesContext> = (pluginName: string, {
231
+ selection,
232
+ computedData$,
233
+ computedAxesData$,
234
+ visibleComputedData$,
235
+ visibleComputedAxesData$,
236
+ seriesLabels$,
237
+ SeriesDataMap$,
238
+ GroupDataMap$,
239
+ fullParams$,
240
+ fullDataFormatter$,
241
+ fullChartParams$,
242
+ gridAxesTransform$,
243
+ gridGraphicTransform$,
244
+ gridAxesSize$,
245
+ gridHighlight$,
246
+ gridContainerPosition$,
247
+ allContainerPosition$,
248
+ layout$,
249
+ event$
250
+ }) => {
251
+
252
+ const destroy$ = new Subject()
253
+
254
+ const clipPathID = getUniID(pluginName, 'clipPath-box')
255
+ const pathClassName = getClassName(pluginName, 'path')
256
+ // const clipPathSeriesID = getUniID(pluginName, 'clipPath')
257
+
258
+ // const axisSelection: d3.Selection<SVGGElement, any, any, any> = selection
259
+ // .append('g')
260
+ // .attr('clip-path', `url(#${clipPathID})`)
261
+ // const defsSelection: d3.Selection<SVGDefsElement, any, any, any> = axisSelection.append('defs')
262
+ // const graphicGSelection: d3.Selection<SVGGElement, any, any, any> = axisSelection.append('g')
263
+ // const graphicSelection$: Subject<d3.Selection<SVGGElement, string, any, any>> = new Subject()
264
+
265
+
266
+ // gridAxesTransform$
267
+ // .pipe(
268
+ // takeUntil(destroy$),
269
+ // map(d => d.value),
270
+ // distinctUntilChanged()
271
+ // ).subscribe(d => {
272
+ // axisSelection
273
+ // .style('transform', d)
274
+ // })
275
+
276
+ // gridGraphicTransform$
277
+ // .pipe(
278
+ // takeUntil(destroy$),
279
+ // map(d => d.value),
280
+ // distinctUntilChanged()
281
+ // ).subscribe(d => {
282
+ // graphicGSelection
283
+ // .transition()
284
+ // .duration(50)
285
+ // .style('transform', d)
286
+ // })
287
+
288
+ // const seriesSelection$ = computedData$.pipe(
289
+ // takeUntil(destroy$),
290
+ // distinctUntilChanged((a, b) => {
291
+ // // 只有當series的數量改變時,才重新計算
292
+ // return a.length === b.length
293
+ // }),
294
+ // map((computedData, i) => {
295
+ // return selection
296
+ // .selectAll<SVGGElement, ComputedDatumGrid[]>(`g.${seriesClassName}`)
297
+ // .data(computedData, d => d[0] ? d[0].seriesIndex : i)
298
+ // .join(
299
+ // enter => {
300
+ // return enter
301
+ // .append('g')
302
+ // .classed(seriesClassName, true)
303
+ // .each((d, i, g) => {
304
+ // const axesSelection = d3.select(g[i])
305
+ // .selectAll<SVGGElement, ComputedDatumGrid[]>(`g.${axesClassName}`)
306
+ // .data([i])
307
+ // .join(
308
+ // enter => {
309
+ // return enter
310
+ // .append('g')
311
+ // .classed(axesClassName, true)
312
+ // .attr('clip-path', `url(#${clipPathID})`)
313
+ // .each((d, i, g) => {
314
+ // const defsSelection = d3.select(g[i])
315
+ // .selectAll<SVGDefsElement, any>('defs')
316
+ // .data([i])
317
+ // .join('defs')
318
+
319
+ // const graphicGSelection = d3.select(g[i])
320
+ // .selectAll<SVGGElement, any>('g')
321
+ // .data([i])
322
+ // .join('g')
323
+ // .classed(graphicClassName, true)
324
+ // })
325
+ // },
326
+ // update => update,
327
+ // exit => exit.remove()
328
+ // )
329
+ // })
330
+ // },
331
+ // update => update,
332
+ // exit => exit.remove()
333
+ // )
334
+ // })
335
+ // )
336
+
337
+ // combineLatest({
338
+ // seriesSelection: seriesSelection$,
339
+ // gridContainerPosition: gridContainerPosition$
340
+ // }).pipe(
341
+ // takeUntil(destroy$),
342
+ // switchMap(async d => d)
343
+ // ).subscribe(data => {
344
+ // data.seriesSelection
345
+ // .transition()
346
+ // .attr('transform', (d, i) => {
347
+ // const translate = data.gridContainerPosition[i].translate
348
+ // const scale = data.gridContainerPosition[i].scale
349
+ // return `translate(${translate[0]}, ${translate[1]}) scale(${scale[0]}, ${scale[1]})`
350
+ // })
351
+ // })
352
+
353
+
354
+ // const axesSelection$ = combineLatest({
355
+ // seriesSelection: seriesSelection$,
356
+ // gridAxesTransform: gridAxesTransform$
357
+ // }).pipe(
358
+ // takeUntil(destroy$),
359
+ // switchMap(async d => d),
360
+ // map(data => {
361
+ // return data.seriesSelection
362
+ // .select<SVGGElement>(`g.${axesClassName}`)
363
+ // .style('transform', data.gridAxesTransform.value)
364
+ // })
365
+ // )
366
+ // const defsSelection$ = axesSelection$.pipe(
367
+ // takeUntil(destroy$),
368
+ // map(axesSelection => {
369
+ // return axesSelection.select<SVGDefsElement>('defs')
370
+ // })
371
+ // )
372
+ // const graphicGSelection$ = combineLatest({
373
+ // axesSelection: axesSelection$,
374
+ // gridGraphicTransform: gridGraphicTransform$
375
+ // }).pipe(
376
+ // takeUntil(destroy$),
377
+ // switchMap(async d => d),
378
+ // map(data => {
379
+ // const graphicGSelection = data.axesSelection
380
+ // .select<SVGGElement>(`g.${graphicClassName}`)
381
+ // .attr('clip-path', (d) => `url(#${clipPathSeriesID}-${d[0] ? d[0].seriesLabel : ''})`)
382
+ // graphicGSelection
383
+ // .transition()
384
+ // .duration(50)
385
+ // .style('transform', data.gridGraphicTransform.value)
386
+ // return graphicGSelection
387
+ // })
388
+ // )
389
+
390
+ const {
391
+ seriesSelection$,
392
+ axesSelection$,
393
+ defsSelection$,
394
+ graphicGSelection$
395
+ } = gridSelectionsObservable({
396
+ selection,
397
+ pluginName,
398
+ clipPathID,
399
+ seriesLabels$,
400
+ gridContainerPosition$,
401
+ gridAxesTransform$,
402
+ gridGraphicTransform$
403
+ })
404
+
405
+ const linePath$: Observable<d3.Line<ComputedLayoutDatumGrid>> = new Observable(subscriber => {
406
+ const paramsSubscription = fullParams$
407
+ .pipe(
408
+ takeUntil(destroy$)
409
+ )
410
+ .subscribe(d => {
411
+ if (!d) return
412
+ const linePath = createLinePath(d.lineCurve)
413
+ subscriber.next(linePath)
414
+ })
415
+ return () => {
416
+ paramsSubscription.unsubscribe()
417
+ }
418
+ })
419
+
420
+ // // 顯示範圍內的series labels
421
+ // const seriesLabels$: Observable<string[]> = new Observable(subscriber => {
422
+ // computedData$.pipe(
423
+ // takeUntil(destroy$),
424
+ // switchMap(async (d) => d),
425
+ // ).subscribe(data => {
426
+ // const labels = data[0] && data[0][0]
427
+ // ? data.map(d => d[0].seriesLabel)
428
+ // : []
429
+ // subscriber.next(labels)
430
+ // })
431
+ // })
432
+
433
+ // const axisSize$ = gridAxisSizeObservable({
434
+ // fullDataFormatter$,
435
+ // computedLayout$
436
+ // })
437
+
438
+ const transitionDuration$ = fullChartParams$
439
+ .pipe(
440
+ map(d => d.transitionDuration),
441
+ distinctUntilChanged()
442
+ )
443
+
444
+ const transitionEase$ = fullChartParams$
445
+ .pipe(
446
+ map(d => d.transitionEase),
447
+ distinctUntilChanged()
448
+ )
449
+
450
+ const clipPathSubscription = combineLatest({
451
+ defsSelection: defsSelection$,
452
+ seriesLabels: seriesLabels$,
453
+ axisSize: gridAxesSize$,
454
+ transitionDuration: transitionDuration$,
455
+ transitionEase: transitionEase$
456
+ }).pipe(
457
+ takeUntil(destroy$),
458
+ switchMap(async (d) => d),
459
+ ).subscribe(data => {
460
+ // 外層的遮罩
461
+ const clipPathBox = [{
462
+ id: clipPathID,
463
+ width: data.axisSize.width,
464
+ height: data.axisSize.height
465
+ }]
466
+ // 各別線條的遮罩(各別動畫)
467
+ const clipPathData = clipPathBox.concat(
468
+ data.seriesLabels.map(d => {
469
+ return {
470
+ id: `orbcharts__clipPath_${d}`,
471
+ width: data.axisSize.width,
472
+ height: data.axisSize.height
473
+ }
474
+ })
475
+ )
476
+ renderClipPath({
477
+ defsSelection: data.defsSelection,
478
+ clipPathData,
479
+ transitionDuration: data.transitionDuration,
480
+ transitionEase: data.transitionEase
481
+ })
482
+ })
483
+
484
+ // const SeriesDataMap$ = computedData$.pipe(
485
+ // map(d => makeGridSeriesDataMap(d))
486
+ // )
487
+
488
+ // const GroupDataMap$ = computedData$.pipe(
489
+ // map(d => makeGridGroupDataMap(d))
490
+ // )
491
+
492
+ const DataMap$ = computedData$.pipe(
493
+ map(d => {
494
+ const DataMap: Map<string, ComputedDatumGrid> = new Map()
495
+ d.flat().forEach(_d => DataMap.set(_d.id, _d))
496
+ return DataMap
497
+ })
498
+ )
499
+
500
+ // 取得事件座標的group資料
501
+ const gridGroupPositionFn$ = gridGroupPositionFnObservable({
502
+ fullDataFormatter$,
503
+ gridAxesSize$: gridAxesSize$,
504
+ computedData$: computedData$,
505
+ fullChartParams$: fullChartParams$,
506
+ gridContainerPosition$: allContainerPosition$,
507
+ layout$: layout$
508
+ })
509
+
510
+ const highlightTarget$ = fullChartParams$.pipe(
511
+ takeUntil(destroy$),
512
+ map(d => d.highlightTarget),
513
+ distinctUntilChanged()
514
+ )
515
+
516
+ const pathSelectionArr$ = combineLatest({
517
+ graphicGSelection: graphicGSelection$,
518
+ visibleComputedAxesData: visibleComputedAxesData$,
519
+ linePath: linePath$,
520
+ params: fullParams$,
521
+ }).pipe(
522
+ takeUntil(destroy$),
523
+ switchMap(async (d) => d),
524
+ map(data => {
525
+ // const updateGraphic = data.graphicGSelection
526
+ // .selectAll<SVGGElement, number>('g')
527
+ // .data(data.seriesLabels, (d, i) => d)
528
+ // const enterGraphic = updateGraphic.enter()
529
+ // .append('g')
530
+ // .classed(graphicClassName, true)
531
+ // updateGraphic.exit().remove()
532
+ // const graphicSelection = updateGraphic.merge(enterGraphic)
533
+ // .attr('clip-path', (d, i) => `url(#orbcharts__clipPath_${d})`)
534
+ let pathSelectionArr: d3.Selection<SVGPathElement, ComputedLayoutDatumGrid[], any, any>[] = []
535
+
536
+ // 繪圖
537
+ data.graphicGSelection.each((d, i, all) => {
538
+ // 將資料分段
539
+ const segmentData = makeSegmentData(data.visibleComputedAxesData[i] ?? [])
540
+
541
+ pathSelectionArr[i] = renderLines({
542
+ selection: d3.select(all[i]),
543
+ pathClassName,
544
+ linePath: data.linePath,
545
+ segmentData: segmentData,
546
+ params: data.params
547
+ })
548
+ })
549
+
550
+ return pathSelectionArr
551
+ })
552
+ )
553
+
554
+ combineLatest({
555
+ pathSelectionArr: pathSelectionArr$,
556
+ computedData: computedData$,
557
+ SeriesDataMap: SeriesDataMap$,
558
+ GroupDataMap: GroupDataMap$,
559
+ highlightTarget: highlightTarget$,
560
+ gridGroupPositionFn: gridGroupPositionFn$,
561
+ }).pipe(
562
+ takeUntil(destroy$),
563
+ switchMap(async (d) => d)
564
+ ).subscribe(data => {
565
+ data.pathSelectionArr.forEach(pathSelection => {
566
+ pathSelection
567
+ .on('mouseover', (event, datum) => {
568
+ event.stopPropagation()
569
+
570
+ const seriesLabel = datum[0] ? datum[0].seriesLabel : ''
571
+ const { groupIndex, groupLabel } = data.gridGroupPositionFn(event)
572
+ // console.log('groupIndex', groupIndex)
573
+ const groupData = data.GroupDataMap.get(groupLabel)!
574
+ const targetDatum = groupData.find(d => d.seriesLabel === seriesLabel)
575
+ const _datum = targetDatum ?? datum[0]
576
+
577
+ event$.next({
578
+ type: 'grid',
579
+ eventName: 'mouseover',
580
+ pluginName,
581
+ highlightTarget: data.highlightTarget,
582
+ datum: _datum,
583
+ gridIndex: _datum.gridIndex,
584
+ series: data.SeriesDataMap.get(_datum.seriesLabel)!,
585
+ seriesIndex: _datum.seriesIndex,
586
+ seriesLabel: _datum.seriesLabel,
587
+ group: data.GroupDataMap.get(_datum.groupLabel)!,
588
+ groupIndex: _datum.groupIndex,
589
+ groupLabel: _datum.groupLabel,
590
+ event,
591
+ data: data.computedData
592
+ })
593
+ })
594
+ .on('mousemove', (event, datum) => {
595
+ event.stopPropagation()
596
+
597
+ const seriesLabel = datum[0] ? datum[0].seriesLabel : ''
598
+ const { groupIndex, groupLabel } = data.gridGroupPositionFn(event)
599
+ const groupData = data.GroupDataMap.get(groupLabel)!
600
+ const targetDatum = groupData.find(d => d.seriesLabel === seriesLabel)
601
+ const _datum = targetDatum ?? datum[0]
602
+
603
+ event$.next({
604
+ type: 'grid',
605
+ eventName: 'mousemove',
606
+ pluginName,
607
+ highlightTarget: data.highlightTarget,
608
+ datum: _datum,
609
+ gridIndex: _datum.gridIndex,
610
+ series: data.SeriesDataMap.get(_datum.seriesLabel)!,
611
+ seriesIndex: _datum.seriesIndex,
612
+ seriesLabel: _datum.seriesLabel,
613
+ group: data.GroupDataMap.get(_datum.groupLabel)!,
614
+ groupIndex: _datum.groupIndex,
615
+ groupLabel: _datum.groupLabel,
616
+ event,
617
+ data: data.computedData
618
+ })
619
+ })
620
+ .on('mouseout', (event, datum) => {
621
+ event.stopPropagation()
622
+
623
+ const seriesLabel = datum[0] ? datum[0].seriesLabel : ''
624
+ const { groupIndex, groupLabel } = data.gridGroupPositionFn(event)
625
+ const groupData = data.GroupDataMap.get(groupLabel)!
626
+ const targetDatum = groupData.find(d => d.seriesLabel === seriesLabel)
627
+ const _datum = targetDatum ?? datum[0]
628
+
629
+ event$.next({
630
+ type: 'grid',
631
+ eventName: 'mouseout',
632
+ pluginName,
633
+ highlightTarget: data.highlightTarget,
634
+ datum: _datum,
635
+ gridIndex: _datum.gridIndex,
636
+ series: data.SeriesDataMap.get(_datum.seriesLabel)!,
637
+ seriesIndex: _datum.seriesIndex,
638
+ seriesLabel: _datum.seriesLabel,
639
+ group: data.GroupDataMap.get(_datum.groupLabel)!,
640
+ groupIndex: _datum.groupIndex,
641
+ groupLabel: _datum.groupLabel,
642
+ event,
643
+ data: data.computedData
644
+ })
645
+ })
646
+ .on('click', (event, datum) => {
647
+ event.stopPropagation()
648
+
649
+ const seriesLabel = datum[0] ? datum[0].seriesLabel : ''
650
+ const { groupIndex, groupLabel } = data.gridGroupPositionFn(event)
651
+ const groupData = data.GroupDataMap.get(groupLabel)!
652
+ const targetDatum = groupData.find(d => d.seriesLabel === seriesLabel)
653
+ const _datum = targetDatum ?? datum[0]
654
+
655
+ event$.next({
656
+ type: 'grid',
657
+ eventName: 'click',
658
+ pluginName,
659
+ highlightTarget: data.highlightTarget,
660
+ datum: _datum,
661
+ gridIndex: _datum.gridIndex,
662
+ series: data.SeriesDataMap.get(_datum.seriesLabel)!,
663
+ seriesIndex: _datum.seriesIndex,
664
+ seriesLabel: _datum.seriesLabel,
665
+ group: data.GroupDataMap.get(_datum.groupLabel)!,
666
+ groupIndex: _datum.groupIndex,
667
+ groupLabel: _datum.groupLabel,
668
+ event,
669
+ data: data.computedData
670
+ })
671
+ })
672
+ })
673
+ })
674
+
675
+ // const datumList$ = computedData$.pipe(
676
+ // takeUntil(destroy$),
677
+ // map(d => d.flat())
678
+ // )
679
+ // const highlight$ = highlightObservable({ datumList$, fullChartParams$, event$: store.event$ })
680
+ // const highlightSubscription = gridHighlight$.subscribe()
681
+
682
+ fullChartParams$.pipe(
683
+ takeUntil(destroy$),
684
+ filter(d => d.highlightTarget === 'series'),
685
+ switchMap(d => combineLatest({
686
+ graphicGSelection: graphicGSelection$,
687
+ gridHighlight: gridHighlight$,
688
+ DataMap: DataMap$,
689
+ fullChartParams: fullChartParams$
690
+ }).pipe(
691
+ takeUntil(destroy$),
692
+ switchMap(async d => d)
693
+ ))
694
+ ).subscribe(data => {
695
+ const seriesLabel = data.gridHighlight[0] ? data.gridHighlight[0].seriesLabel : null
696
+ highlightLines({
697
+ selection: data.graphicGSelection,
698
+ seriesLabel,
699
+ fullChartParams: data.fullChartParams
700
+ })
701
+ })
702
+
703
+ return () => {
704
+ destroy$.next(undefined)
705
+ // highlightSubscription.unsubscribe()
706
+ }
707
707
  }