@orbcharts/core 3.0.0-alpha.38 → 3.0.0-alpha.40

Sign up to get free protection for your applications and to get access to all the features.
Files changed (86) hide show
  1. package/LICENSE +200 -200
  2. package/dist/orbcharts-core.es.js +5 -4
  3. package/dist/orbcharts-core.umd.js +1 -1
  4. package/dist/src/types/ContextObserverGrid.d.ts +1 -1
  5. package/dist/src/types/ContextObserverSeries.d.ts +1 -1
  6. package/dist/src/types/ContextObserverTree.d.ts +1 -1
  7. package/dist/src/utils/observables.d.ts +5 -5
  8. package/package.json +41 -41
  9. package/src/AbstractChart.ts +48 -48
  10. package/src/GridChart.ts +20 -20
  11. package/src/MultiGridChart.ts +20 -20
  12. package/src/MultiValueChart.ts +20 -20
  13. package/src/RelationshipChart.ts +20 -20
  14. package/src/SeriesChart.ts +20 -20
  15. package/src/TreeChart.ts +20 -20
  16. package/src/base/createBaseChart.ts +367 -367
  17. package/src/base/createBasePlugin.ts +89 -89
  18. package/src/defaults.ts +247 -247
  19. package/src/defineGridPlugin.ts +3 -3
  20. package/src/defineMultiGridPlugin.ts +3 -3
  21. package/src/defineMultiValuePlugin.ts +3 -3
  22. package/src/defineNoneDataPlugin.ts +4 -4
  23. package/src/defineRelationshipPlugin.ts +3 -3
  24. package/src/defineSeriesPlugin.ts +3 -3
  25. package/src/defineTreePlugin.ts +3 -3
  26. package/src/grid/computeGridData.ts +205 -205
  27. package/src/grid/createGridContextObserver.ts +124 -124
  28. package/src/grid/gridObservables.ts +486 -486
  29. package/src/index.ts +21 -21
  30. package/src/multiGrid/computeMultiGridData.ts +173 -173
  31. package/src/multiGrid/createMultiGridContextObserver.ts +34 -34
  32. package/src/multiGrid/multiGridObservables.ts +285 -285
  33. package/src/multiValue/computeMultiValueData.ts +136 -136
  34. package/src/multiValue/createMultiValueContextObserver.ts +12 -12
  35. package/src/relationship/computeRelationshipData.ts +106 -106
  36. package/src/relationship/createRelationshipContextObserver.ts +12 -12
  37. package/src/series/computeSeriesData.ts +153 -153
  38. package/src/series/createSeriesContextObserver.ts +33 -33
  39. package/src/series/seriesObservables.ts +23 -23
  40. package/src/tree/computeTreeData.ts +128 -128
  41. package/src/tree/createTreeContextObserver.ts +56 -56
  42. package/src/tree/treeObservables.ts +94 -94
  43. package/src/types/Chart.ts +48 -48
  44. package/src/types/ChartParams.ts +51 -51
  45. package/src/types/ComputedData.ts +82 -82
  46. package/src/types/ComputedDataGrid.ts +13 -13
  47. package/src/types/ComputedDataMultiGrid.ts +2 -2
  48. package/src/types/ComputedDataMultiValue.ts +9 -9
  49. package/src/types/ComputedDataRelationship.ts +19 -19
  50. package/src/types/ComputedDataSeries.ts +7 -7
  51. package/src/types/ComputedDataTree.ts +19 -19
  52. package/src/types/ContextObserver.ts +38 -38
  53. package/src/types/ContextObserverGrid.ts +33 -33
  54. package/src/types/ContextObserverMultiGrid.ts +27 -27
  55. package/src/types/ContextObserverMultiValue.ts +4 -4
  56. package/src/types/ContextObserverRelationship.ts +4 -4
  57. package/src/types/ContextObserverSeries.ts +7 -7
  58. package/src/types/ContextObserverTree.ts +10 -10
  59. package/src/types/ContextSubject.ts +18 -18
  60. package/src/types/Data.ts +45 -45
  61. package/src/types/DataFormatter.ts +95 -95
  62. package/src/types/DataFormatterGrid.ts +55 -55
  63. package/src/types/DataFormatterMultiGrid.ts +42 -42
  64. package/src/types/DataFormatterMultiValue.ts +20 -20
  65. package/src/types/DataFormatterRelationship.ts +22 -22
  66. package/src/types/DataFormatterSeries.ts +29 -29
  67. package/src/types/DataFormatterTree.ts +12 -12
  68. package/src/types/DataGrid.ts +11 -11
  69. package/src/types/DataMultiGrid.ts +6 -6
  70. package/src/types/DataMultiValue.ts +12 -12
  71. package/src/types/DataRelationship.ts +27 -27
  72. package/src/types/DataSeries.ts +11 -11
  73. package/src/types/DataTree.ts +20 -20
  74. package/src/types/Event.ts +153 -153
  75. package/src/types/Layout.ts +11 -11
  76. package/src/types/Padding.ts +5 -5
  77. package/src/types/Plugin.ts +60 -60
  78. package/src/types/TransformData.ts +7 -7
  79. package/src/types/index.ts +37 -37
  80. package/src/utils/commonUtils.ts +50 -50
  81. package/src/utils/d3Utils.ts +89 -89
  82. package/src/utils/index.ts +4 -4
  83. package/src/utils/observables.ts +181 -181
  84. package/src/utils/orbchartsUtils.ts +253 -253
  85. package/tsconfig.json +13 -13
  86. package/vite.config.js +44 -44
@@ -1,286 +1,286 @@
1
- import {
2
- combineLatest,
3
- distinctUntilChanged,
4
- filter,
5
- of,
6
- map,
7
- merge,
8
- takeUntil,
9
- shareReplay,
10
- switchMap,
11
- Subject,
12
- Observable,
13
- combineLatestAll} from 'rxjs'
14
- import type {
15
- AxisPosition,
16
- ChartType,
17
- ChartParams,
18
- ComputedDataTypeMap,
19
- ComputedDataGrid,
20
- DataTypeMap,
21
- DataFormatterTypeMap,
22
- DataFormatterGrid,
23
- DataFormatterMultiGridContainer,
24
- EventMultiGrid,
25
- HighlightTarget,
26
- Layout,
27
- TransformData } from '../types'
28
- import type { ContextObserverGridDetail } from '../types'
29
- import {
30
- highlightObservable,
31
- seriesDataMapObservable,
32
- groupDataMapObservable } from '../utils/observables'
33
- import {
34
- gridAxesTransformObservable,
35
- gridGraphicTransformObservable,
36
- gridGraphicReverseScaleObservable,
37
- gridAxesReverseTransformObservable,
38
- gridAxesSizeObservable,
39
- existSeriesLabelsObservable,
40
- gridVisibleComputedDataObservable,
41
- isSeriesPositionSeprateObservable,
42
- gridContainerObservable } from '../grid/gridObservables'
43
- import { DATA_FORMATTER_MULTI_GRID_GRID_DEFAULT } from '../defaults'
44
- import { calcGridContainerPosition } from '../utils/orbchartsUtils'
45
-
46
- // 每一個grid計算出來的所有Observable
47
- export const multiGridEachDetailObservable = ({ fullDataFormatter$, computedData$, layout$, fullChartParams$, event$ }: {
48
- fullDataFormatter$: Observable<DataFormatterTypeMap<'multiGrid'>>
49
- computedData$: Observable<ComputedDataTypeMap<'multiGrid'>>
50
- layout$: Observable<Layout>
51
- fullChartParams$: Observable<ChartParams>
52
- event$: Subject<EventMultiGrid>
53
- }) => {
54
-
55
- // 建立Observables
56
- function detailObservables ({ gridDataFormatter$, gridComputedData$, layout$, fullChartParams$, event$ }: {
57
- // fullDataFormatter$: Observable<DataFormatterTypeMap<'multiGrid'>>
58
- // computedData$: Observable<ComputedDataTypeMap<'multiGrid'>>
59
- gridDataFormatter$: Observable<DataFormatterGrid>
60
- gridComputedData$: Observable<ComputedDataGrid>
61
- layout$: Observable<Layout>
62
- fullChartParams$: Observable<ChartParams>
63
- event$: Subject<EventMultiGrid>
64
- }): ContextObserverGridDetail {
65
-
66
- const isSeriesPositionSeprate$ = isSeriesPositionSeprateObservable({
67
- computedData$: gridComputedData$,
68
- fullDataFormatter$: gridDataFormatter$,
69
- }).pipe(
70
- shareReplay(1)
71
- )
72
-
73
- const gridContainer$ = gridContainerObservable({
74
- computedData$: gridComputedData$,
75
- fullDataFormatter$: gridDataFormatter$,
76
- fullChartParams$,
77
- layout$
78
- }).pipe(
79
- shareReplay(1)
80
- )
81
-
82
- const gridAxesTransform$ = gridAxesTransformObservable({
83
- fullDataFormatter$: gridDataFormatter$,
84
- layout$: layout$
85
- }).pipe(
86
- shareReplay(1)
87
- )
88
-
89
-
90
- const gridAxesReverseTransform$ = gridAxesReverseTransformObservable({
91
- gridAxesTransform$
92
- }).pipe(
93
- shareReplay(1)
94
- )
95
-
96
- const gridGraphicTransform$ = gridGraphicTransformObservable({
97
- computedData$: gridComputedData$,
98
- fullDataFormatter$: gridDataFormatter$,
99
- layout$: layout$
100
- }).pipe(
101
- shareReplay(1)
102
- )
103
-
104
- const gridGraphicReverseScale$ = gridGraphicReverseScaleObservable({
105
- gridContainer$: gridContainer$,
106
- gridAxesTransform$: gridAxesTransform$,
107
- gridGraphicTransform$: gridGraphicTransform$,
108
- })
109
-
110
- const gridAxesSize$ = gridAxesSizeObservable({
111
- fullDataFormatter$: gridDataFormatter$,
112
- layout$: layout$
113
- }).pipe(
114
- shareReplay(1)
115
- )
116
-
117
- const datumList$ = gridComputedData$.pipe(
118
- map(d => d.flat())
119
- ).pipe(
120
- shareReplay(1)
121
- )
122
-
123
- const gridHighlight$ = highlightObservable({
124
- datumList$,
125
- fullChartParams$: fullChartParams$,
126
- event$: event$
127
- }).pipe(
128
- shareReplay(1)
129
- )
130
-
131
- const existSeriesLabels$ = existSeriesLabelsObservable({
132
- computedData$: gridComputedData$,
133
- })
134
-
135
- const SeriesDataMap$ = seriesDataMapObservable({
136
- datumList$: datumList$
137
- }).pipe(
138
- shareReplay(1)
139
- )
140
-
141
- const GroupDataMap$ = groupDataMapObservable({
142
- datumList$: datumList$
143
- }).pipe(
144
- shareReplay(1)
145
- )
146
-
147
- const visibleComputedData$ = gridVisibleComputedDataObservable({
148
- computedData$: gridComputedData$,
149
- }).pipe(
150
- shareReplay(1)
151
- )
152
-
153
-
154
- return {
155
- isSeriesPositionSeprate$,
156
- gridContainer$,
157
- gridAxesTransform$,
158
- gridAxesReverseTransform$,
159
- gridGraphicTransform$,
160
- gridGraphicReverseScale$,
161
- gridAxesSize$,
162
- gridHighlight$,
163
- existSeriesLabels$,
164
- SeriesDataMap$,
165
- GroupDataMap$,
166
- visibleComputedData$,
167
- }
168
- }
169
-
170
- const destroy$ = new Subject()
171
-
172
- return combineLatest({
173
- fullDataFormatter: fullDataFormatter$,
174
- computedData: computedData$,
175
- }).pipe(
176
- switchMap(async (d) => d),
177
- // distinctUntilChanged((a, b) => {
178
- // // 只有當computedData的長度改變時,才重新計算
179
- // return a.computedData.length === b.computedData.length
180
- // }),
181
- map(data => {
182
- // 每次重新計算時,清除之前的訂閱
183
- destroy$.next(undefined)
184
-
185
- const defaultGrid = data.fullDataFormatter.gridList[0] ?? DATA_FORMATTER_MULTI_GRID_GRID_DEFAULT
186
-
187
- return data.computedData.map((gridComputedData, gridIndex) => {
188
-
189
- // -- 取得該grid的data和dataFormatter
190
- const grid = data.fullDataFormatter.gridList[gridIndex] ?? defaultGrid
191
- const gridDataFormatter: DataFormatterGrid = {
192
- type: 'grid',
193
- grid: {
194
- ...grid
195
- },
196
- container: {
197
- ...data.fullDataFormatter.container
198
- }
199
- }
200
- const gridDataFormatter$ = of(gridDataFormatter).pipe(
201
- takeUntil(destroy$),
202
- shareReplay(1)
203
- )
204
- const gridComputedData$ = of(gridComputedData).pipe(
205
- takeUntil(destroy$),
206
- shareReplay(1)
207
- )
208
-
209
- // -- 建立Observables --
210
- return detailObservables ({
211
- gridDataFormatter$,
212
- gridComputedData$,
213
- layout$,
214
- fullChartParams$,
215
- event$
216
- })
217
- })
218
- })
219
- )
220
- }
221
-
222
-
223
- // 所有container位置(對應series)
224
- export const multiGridContainerObservable = ({ computedData$, fullDataFormatter$, fullChartParams$, layout$ }: {
225
- computedData$: Observable<ComputedDataTypeMap<'multiGrid'>>
226
- fullDataFormatter$: Observable<DataFormatterTypeMap<'multiGrid'>>
227
- fullChartParams$: Observable<ChartParams>
228
- layout$: Observable<Layout>
229
- }) => {
230
-
231
- const multiGridContainer$ = combineLatest({
232
- computedData: computedData$,
233
- fullDataFormatter: fullDataFormatter$,
234
- fullChartParams: fullChartParams$,
235
- layout: layout$,
236
- }).pipe(
237
- switchMap(async (d) => d),
238
- map(data => {
239
-
240
- const defaultGrid = data.fullDataFormatter.gridList[0] ?? DATA_FORMATTER_MULTI_GRID_GRID_DEFAULT
241
-
242
- const boxArr = data.computedData.map((gridData, gridIndex) => {
243
- const grid = data.fullDataFormatter.gridList[gridIndex] ?? defaultGrid
244
-
245
- // 有設定series定位
246
- const hasSeriesPosition = grid.seriesSlotIndexes && grid.seriesSlotIndexes.length === gridData.length
247
- ? true
248
- : false
249
-
250
- if (hasSeriesPosition) {
251
- // -- 依seriesSlotIndexes計算 --
252
- return gridData.map((seriesData, seriesIndex) => {
253
- const columnIndex = grid.seriesSlotIndexes[seriesIndex] % data.fullDataFormatter.container.columnAmount
254
- const rowIndex = Math.floor(grid.seriesSlotIndexes[seriesIndex] / data.fullDataFormatter.container.columnAmount)
255
- const { translate, scale } = calcGridContainerPosition(data.layout, data.fullDataFormatter.container, rowIndex, columnIndex)
256
- return {
257
- slotIndex: grid.seriesSlotIndexes[seriesIndex],
258
- rowIndex,
259
- columnIndex,
260
- translate,
261
- scale,
262
- }
263
- })
264
- } else {
265
- // -- 依grid的slotIndex計算 --
266
- const columnIndex = grid.slotIndex % data.fullDataFormatter.container.columnAmount
267
- const rowIndex = Math.floor(grid.slotIndex / data.fullDataFormatter.container.columnAmount)
268
- return gridData.map((seriesData, seriesIndex) => {
269
- const { translate, scale } = calcGridContainerPosition(data.layout, data.fullDataFormatter.container, rowIndex, columnIndex)
270
- return {
271
- slotIndex: grid.slotIndex,
272
- rowIndex,
273
- columnIndex,
274
- translate,
275
- scale,
276
- }
277
- })
278
- }
279
-
280
- })
281
- return boxArr
282
- }),
283
- )
284
-
285
- return multiGridContainer$
1
+ import {
2
+ combineLatest,
3
+ distinctUntilChanged,
4
+ filter,
5
+ of,
6
+ map,
7
+ merge,
8
+ takeUntil,
9
+ shareReplay,
10
+ switchMap,
11
+ Subject,
12
+ Observable,
13
+ combineLatestAll} from 'rxjs'
14
+ import type {
15
+ AxisPosition,
16
+ ChartType,
17
+ ChartParams,
18
+ ComputedDataTypeMap,
19
+ ComputedDataGrid,
20
+ DataTypeMap,
21
+ DataFormatterTypeMap,
22
+ DataFormatterGrid,
23
+ DataFormatterMultiGridContainer,
24
+ EventMultiGrid,
25
+ HighlightTarget,
26
+ Layout,
27
+ TransformData } from '../types'
28
+ import type { ContextObserverGridDetail } from '../types'
29
+ import {
30
+ highlightObservable,
31
+ seriesDataMapObservable,
32
+ groupDataMapObservable } from '../utils/observables'
33
+ import {
34
+ gridAxesTransformObservable,
35
+ gridGraphicTransformObservable,
36
+ gridGraphicReverseScaleObservable,
37
+ gridAxesReverseTransformObservable,
38
+ gridAxesSizeObservable,
39
+ existSeriesLabelsObservable,
40
+ gridVisibleComputedDataObservable,
41
+ isSeriesPositionSeprateObservable,
42
+ gridContainerObservable } from '../grid/gridObservables'
43
+ import { DATA_FORMATTER_MULTI_GRID_GRID_DEFAULT } from '../defaults'
44
+ import { calcGridContainerPosition } from '../utils/orbchartsUtils'
45
+
46
+ // 每一個grid計算出來的所有Observable
47
+ export const multiGridEachDetailObservable = ({ fullDataFormatter$, computedData$, layout$, fullChartParams$, event$ }: {
48
+ fullDataFormatter$: Observable<DataFormatterTypeMap<'multiGrid'>>
49
+ computedData$: Observable<ComputedDataTypeMap<'multiGrid'>>
50
+ layout$: Observable<Layout>
51
+ fullChartParams$: Observable<ChartParams>
52
+ event$: Subject<EventMultiGrid>
53
+ }) => {
54
+
55
+ // 建立Observables
56
+ function detailObservables ({ gridDataFormatter$, gridComputedData$, layout$, fullChartParams$, event$ }: {
57
+ // fullDataFormatter$: Observable<DataFormatterTypeMap<'multiGrid'>>
58
+ // computedData$: Observable<ComputedDataTypeMap<'multiGrid'>>
59
+ gridDataFormatter$: Observable<DataFormatterGrid>
60
+ gridComputedData$: Observable<ComputedDataGrid>
61
+ layout$: Observable<Layout>
62
+ fullChartParams$: Observable<ChartParams>
63
+ event$: Subject<EventMultiGrid>
64
+ }): ContextObserverGridDetail {
65
+
66
+ const isSeriesPositionSeprate$ = isSeriesPositionSeprateObservable({
67
+ computedData$: gridComputedData$,
68
+ fullDataFormatter$: gridDataFormatter$,
69
+ }).pipe(
70
+ shareReplay(1)
71
+ )
72
+
73
+ const gridContainer$ = gridContainerObservable({
74
+ computedData$: gridComputedData$,
75
+ fullDataFormatter$: gridDataFormatter$,
76
+ fullChartParams$,
77
+ layout$
78
+ }).pipe(
79
+ shareReplay(1)
80
+ )
81
+
82
+ const gridAxesTransform$ = gridAxesTransformObservable({
83
+ fullDataFormatter$: gridDataFormatter$,
84
+ layout$: layout$
85
+ }).pipe(
86
+ shareReplay(1)
87
+ )
88
+
89
+
90
+ const gridAxesReverseTransform$ = gridAxesReverseTransformObservable({
91
+ gridAxesTransform$
92
+ }).pipe(
93
+ shareReplay(1)
94
+ )
95
+
96
+ const gridGraphicTransform$ = gridGraphicTransformObservable({
97
+ computedData$: gridComputedData$,
98
+ fullDataFormatter$: gridDataFormatter$,
99
+ layout$: layout$
100
+ }).pipe(
101
+ shareReplay(1)
102
+ )
103
+
104
+ const gridGraphicReverseScale$ = gridGraphicReverseScaleObservable({
105
+ gridContainer$: gridContainer$,
106
+ gridAxesTransform$: gridAxesTransform$,
107
+ gridGraphicTransform$: gridGraphicTransform$,
108
+ })
109
+
110
+ const gridAxesSize$ = gridAxesSizeObservable({
111
+ fullDataFormatter$: gridDataFormatter$,
112
+ layout$: layout$
113
+ }).pipe(
114
+ shareReplay(1)
115
+ )
116
+
117
+ const datumList$ = gridComputedData$.pipe(
118
+ map(d => d.flat())
119
+ ).pipe(
120
+ shareReplay(1)
121
+ )
122
+
123
+ const gridHighlight$ = highlightObservable({
124
+ datumList$,
125
+ fullChartParams$: fullChartParams$,
126
+ event$: event$
127
+ }).pipe(
128
+ shareReplay(1)
129
+ )
130
+
131
+ const existSeriesLabels$ = existSeriesLabelsObservable({
132
+ computedData$: gridComputedData$,
133
+ })
134
+
135
+ const SeriesDataMap$ = seriesDataMapObservable({
136
+ datumList$: datumList$
137
+ }).pipe(
138
+ shareReplay(1)
139
+ )
140
+
141
+ const GroupDataMap$ = groupDataMapObservable({
142
+ datumList$: datumList$
143
+ }).pipe(
144
+ shareReplay(1)
145
+ )
146
+
147
+ const visibleComputedData$ = gridVisibleComputedDataObservable({
148
+ computedData$: gridComputedData$,
149
+ }).pipe(
150
+ shareReplay(1)
151
+ )
152
+
153
+
154
+ return {
155
+ isSeriesPositionSeprate$,
156
+ gridContainer$,
157
+ gridAxesTransform$,
158
+ gridAxesReverseTransform$,
159
+ gridGraphicTransform$,
160
+ gridGraphicReverseScale$,
161
+ gridAxesSize$,
162
+ gridHighlight$,
163
+ existSeriesLabels$,
164
+ SeriesDataMap$,
165
+ GroupDataMap$,
166
+ visibleComputedData$,
167
+ }
168
+ }
169
+
170
+ const destroy$ = new Subject()
171
+
172
+ return combineLatest({
173
+ fullDataFormatter: fullDataFormatter$,
174
+ computedData: computedData$,
175
+ }).pipe(
176
+ switchMap(async (d) => d),
177
+ // distinctUntilChanged((a, b) => {
178
+ // // 只有當computedData的長度改變時,才重新計算
179
+ // return a.computedData.length === b.computedData.length
180
+ // }),
181
+ map(data => {
182
+ // 每次重新計算時,清除之前的訂閱
183
+ destroy$.next(undefined)
184
+
185
+ const defaultGrid = data.fullDataFormatter.gridList[0] ?? DATA_FORMATTER_MULTI_GRID_GRID_DEFAULT
186
+
187
+ return data.computedData.map((gridComputedData, gridIndex) => {
188
+
189
+ // -- 取得該grid的data和dataFormatter
190
+ const grid = data.fullDataFormatter.gridList[gridIndex] ?? defaultGrid
191
+ const gridDataFormatter: DataFormatterGrid = {
192
+ type: 'grid',
193
+ grid: {
194
+ ...grid
195
+ },
196
+ container: {
197
+ ...data.fullDataFormatter.container
198
+ }
199
+ }
200
+ const gridDataFormatter$ = of(gridDataFormatter).pipe(
201
+ takeUntil(destroy$),
202
+ shareReplay(1)
203
+ )
204
+ const gridComputedData$ = of(gridComputedData).pipe(
205
+ takeUntil(destroy$),
206
+ shareReplay(1)
207
+ )
208
+
209
+ // -- 建立Observables --
210
+ return detailObservables ({
211
+ gridDataFormatter$,
212
+ gridComputedData$,
213
+ layout$,
214
+ fullChartParams$,
215
+ event$
216
+ })
217
+ })
218
+ })
219
+ )
220
+ }
221
+
222
+
223
+ // 所有container位置(對應series)
224
+ export const multiGridContainerObservable = ({ computedData$, fullDataFormatter$, fullChartParams$, layout$ }: {
225
+ computedData$: Observable<ComputedDataTypeMap<'multiGrid'>>
226
+ fullDataFormatter$: Observable<DataFormatterTypeMap<'multiGrid'>>
227
+ fullChartParams$: Observable<ChartParams>
228
+ layout$: Observable<Layout>
229
+ }) => {
230
+
231
+ const multiGridContainer$ = combineLatest({
232
+ computedData: computedData$,
233
+ fullDataFormatter: fullDataFormatter$,
234
+ fullChartParams: fullChartParams$,
235
+ layout: layout$,
236
+ }).pipe(
237
+ switchMap(async (d) => d),
238
+ map(data => {
239
+
240
+ const defaultGrid = data.fullDataFormatter.gridList[0] ?? DATA_FORMATTER_MULTI_GRID_GRID_DEFAULT
241
+
242
+ const boxArr = data.computedData.map((gridData, gridIndex) => {
243
+ const grid = data.fullDataFormatter.gridList[gridIndex] ?? defaultGrid
244
+
245
+ // 有設定series定位
246
+ const hasSeriesPosition = grid.seriesSlotIndexes && grid.seriesSlotIndexes.length === gridData.length
247
+ ? true
248
+ : false
249
+
250
+ if (hasSeriesPosition) {
251
+ // -- 依seriesSlotIndexes計算 --
252
+ return gridData.map((seriesData, seriesIndex) => {
253
+ const columnIndex = grid.seriesSlotIndexes[seriesIndex] % data.fullDataFormatter.container.columnAmount
254
+ const rowIndex = Math.floor(grid.seriesSlotIndexes[seriesIndex] / data.fullDataFormatter.container.columnAmount)
255
+ const { translate, scale } = calcGridContainerPosition(data.layout, data.fullDataFormatter.container, rowIndex, columnIndex)
256
+ return {
257
+ slotIndex: grid.seriesSlotIndexes[seriesIndex],
258
+ rowIndex,
259
+ columnIndex,
260
+ translate,
261
+ scale,
262
+ }
263
+ })
264
+ } else {
265
+ // -- 依grid的slotIndex計算 --
266
+ const columnIndex = grid.slotIndex % data.fullDataFormatter.container.columnAmount
267
+ const rowIndex = Math.floor(grid.slotIndex / data.fullDataFormatter.container.columnAmount)
268
+ return gridData.map((seriesData, seriesIndex) => {
269
+ const { translate, scale } = calcGridContainerPosition(data.layout, data.fullDataFormatter.container, rowIndex, columnIndex)
270
+ return {
271
+ slotIndex: grid.slotIndex,
272
+ rowIndex,
273
+ columnIndex,
274
+ translate,
275
+ scale,
276
+ }
277
+ })
278
+ }
279
+
280
+ })
281
+ return boxArr
282
+ }),
283
+ )
284
+
285
+ return multiGridContainer$
286
286
  }