@orbcharts/core 3.0.0-alpha.42 → 3.0.0-alpha.44
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/orbcharts-core.es.js +1905 -1896
- package/dist/orbcharts-core.umd.js +2 -2
- package/dist/src/defaults.d.ts +4 -3
- package/dist/src/grid/computeGridData.d.ts +4 -11
- package/dist/src/grid/gridObservables.d.ts +15 -18
- package/dist/src/multiGrid/multiGridObservables.d.ts +4 -11
- package/dist/src/series/seriesObservables.d.ts +26 -1
- package/dist/src/types/ComputedData.d.ts +1 -0
- package/dist/src/types/ComputedDataGrid.d.ts +0 -3
- package/dist/src/types/ComputedDataSeries.d.ts +1 -2
- package/dist/src/types/ContextObserverGrid.d.ts +11 -4
- package/dist/src/types/ContextObserverMultiGrid.d.ts +8 -3
- package/dist/src/types/ContextObserverSeries.d.ts +18 -0
- package/dist/src/types/DataFormatter.d.ts +8 -5
- package/dist/src/types/DataFormatterGrid.d.ts +13 -16
- package/dist/src/types/DataFormatterMultiGrid.d.ts +6 -3
- package/dist/src/types/DataFormatterMultiValue.d.ts +3 -0
- package/dist/src/types/DataFormatterRelationship.d.ts +3 -0
- package/dist/src/types/DataFormatterSeries.d.ts +11 -4
- package/dist/src/utils/orbchartsUtils.d.ts +14 -13
- package/package.json +1 -1
- package/src/base/createBaseChart.ts +10 -10
- package/src/defaults.ts +36 -64
- package/src/grid/computeGridData.ts +15 -86
- package/src/grid/createGridContextObserver.ts +33 -16
- package/src/grid/gridObservables.ts +157 -70
- package/src/multiGrid/computeMultiGridData.ts +77 -120
- package/src/multiGrid/createMultiGridContextObserver.ts +8 -8
- package/src/multiGrid/multiGridObservables.ts +236 -171
- package/src/multiValue/computeMultiValueData.ts +22 -15
- package/src/relationship/computeRelationshipData.ts +16 -4
- package/src/series/computeSeriesData.ts +51 -114
- package/src/series/createSeriesContextObserver.ts +59 -4
- package/src/series/seriesObservables.ts +162 -10
- package/src/tree/computeTreeData.ts +6 -3
- package/src/types/ComputedData.ts +1 -0
- package/src/types/ComputedDataGrid.ts +3 -3
- package/src/types/ComputedDataSeries.ts +2 -2
- package/src/types/ContextObserverGrid.ts +18 -10
- package/src/types/ContextObserverMultiGrid.ts +6 -18
- package/src/types/ContextObserverSeries.ts +21 -1
- package/src/types/DataFormatter.ts +11 -32
- package/src/types/DataFormatterGrid.ts +32 -20
- package/src/types/DataFormatterMultiGrid.ts +6 -4
- package/src/types/DataFormatterMultiValue.ts +3 -0
- package/src/types/DataFormatterRelationship.ts +3 -0
- package/src/types/DataFormatterSeries.ts +11 -21
- package/src/utils/d3Utils.ts +7 -7
- package/src/utils/orbchartsUtils.ts +128 -32
@@ -25,7 +25,7 @@ import type {
|
|
25
25
|
HighlightTarget,
|
26
26
|
Layout,
|
27
27
|
TransformData } from '../types'
|
28
|
-
import type { ContextObserverGridDetail } from '../types'
|
28
|
+
import type { ContextObserverGridDetail, ContextObserverMultiGridDetail, GridContainerPosition } from '../types'
|
29
29
|
import {
|
30
30
|
highlightObservable,
|
31
31
|
seriesDataMapObservable,
|
@@ -36,12 +36,14 @@ import {
|
|
36
36
|
gridGraphicReverseScaleObservable,
|
37
37
|
gridAxesReverseTransformObservable,
|
38
38
|
gridAxesSizeObservable,
|
39
|
-
|
39
|
+
seriesLabelsObservable,
|
40
|
+
gridComputedLayoutDataObservable,
|
40
41
|
gridVisibleComputedDataObservable,
|
41
|
-
|
42
|
-
|
42
|
+
gridVisibleComputedLayoutDataObservable,
|
43
|
+
// isSeriesSeprateObservable,
|
44
|
+
gridContainerPositionObservable } from '../grid/gridObservables'
|
43
45
|
import { DATA_FORMATTER_MULTI_GRID_GRID_DEFAULT } from '../defaults'
|
44
|
-
import {
|
46
|
+
import { calcGridContainerLayout } from '../utils/orbchartsUtils'
|
45
47
|
|
46
48
|
// 每一個grid計算出來的所有Observable
|
47
49
|
export const multiGridEachDetailObservable = ({ fullDataFormatter$, computedData$, layout$, fullChartParams$, event$ }: {
|
@@ -50,128 +52,34 @@ export const multiGridEachDetailObservable = ({ fullDataFormatter$, computedData
|
|
50
52
|
layout$: Observable<Layout>
|
51
53
|
fullChartParams$: Observable<ChartParams>
|
52
54
|
event$: Subject<EventMultiGrid>
|
53
|
-
}) => {
|
55
|
+
}): Observable<ContextObserverMultiGridDetail[]> => {
|
54
56
|
|
55
|
-
|
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
|
-
)
|
57
|
+
const destroy$ = new Subject()
|
146
58
|
|
147
|
-
|
148
|
-
|
149
|
-
|
59
|
+
// highlight全部grid
|
60
|
+
const allGridHighlight$ = highlightObservable({
|
61
|
+
datumList$: computedData$.pipe(
|
62
|
+
map(d => d.flat().flat()),
|
150
63
|
shareReplay(1)
|
151
|
-
)
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
gridAxesTransform$,
|
158
|
-
gridAxesReverseTransform$,
|
159
|
-
gridGraphicTransform$,
|
160
|
-
gridGraphicReverseScale$,
|
161
|
-
gridAxesSize$,
|
162
|
-
gridHighlight$,
|
163
|
-
existSeriesLabels$,
|
164
|
-
SeriesDataMap$,
|
165
|
-
GroupDataMap$,
|
166
|
-
visibleComputedData$,
|
167
|
-
}
|
168
|
-
}
|
64
|
+
),
|
65
|
+
fullChartParams$: fullChartParams$,
|
66
|
+
event$: event$
|
67
|
+
}).pipe(
|
68
|
+
shareReplay(1)
|
69
|
+
)
|
169
70
|
|
170
|
-
const
|
71
|
+
const multiGridContainer$ = multiGridContainerObservable({
|
72
|
+
computedData$: computedData$,
|
73
|
+
fullDataFormatter$: fullDataFormatter$,
|
74
|
+
layout$: layout$,
|
75
|
+
}).pipe(
|
76
|
+
shareReplay(1)
|
77
|
+
)
|
171
78
|
|
172
79
|
return combineLatest({
|
173
80
|
fullDataFormatter: fullDataFormatter$,
|
174
81
|
computedData: computedData$,
|
82
|
+
multiGridContainer: multiGridContainer$
|
175
83
|
}).pipe(
|
176
84
|
switchMap(async (d) => d),
|
177
85
|
// distinctUntilChanged((a, b) => {
|
@@ -190,6 +98,7 @@ export const multiGridEachDetailObservable = ({ fullDataFormatter$, computedData
|
|
190
98
|
const grid = data.fullDataFormatter.gridList[gridIndex] ?? defaultGrid
|
191
99
|
const gridDataFormatter: DataFormatterGrid = {
|
192
100
|
type: 'grid',
|
101
|
+
visibleFilter: data.fullDataFormatter.visibleFilter as any,
|
193
102
|
grid: {
|
194
103
|
...grid
|
195
104
|
},
|
@@ -206,14 +115,143 @@ export const multiGridEachDetailObservable = ({ fullDataFormatter$, computedData
|
|
206
115
|
shareReplay(1)
|
207
116
|
)
|
208
117
|
|
209
|
-
//
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
118
|
+
// const isSeriesSeprate$ = isSeriesSeprateObservable({
|
119
|
+
// computedData$: gridComputedData$,
|
120
|
+
// fullDataFormatter$: gridDataFormatter$,
|
121
|
+
// }).pipe(
|
122
|
+
// takeUntil(destroy$),
|
123
|
+
// shareReplay(1)
|
124
|
+
// )
|
125
|
+
|
126
|
+
// const gridContainerPosition$ = gridContainerPositionObservable({
|
127
|
+
// computedData$: gridComputedData$,
|
128
|
+
// fullDataFormatter$: gridDataFormatter$,
|
129
|
+
// layout$
|
130
|
+
// }).pipe(
|
131
|
+
// shareReplay(1)
|
132
|
+
// )
|
133
|
+
|
134
|
+
const gridContainerPosition$ = of(data.multiGridContainer[gridIndex]).pipe(
|
135
|
+
takeUntil(destroy$),
|
136
|
+
shareReplay(1)
|
137
|
+
)
|
138
|
+
|
139
|
+
const gridAxesTransform$ = gridAxesTransformObservable({
|
140
|
+
fullDataFormatter$: gridDataFormatter$,
|
141
|
+
layout$: layout$
|
142
|
+
}).pipe(
|
143
|
+
takeUntil(destroy$),
|
144
|
+
shareReplay(1)
|
145
|
+
)
|
146
|
+
|
147
|
+
|
148
|
+
const gridAxesReverseTransform$ = gridAxesReverseTransformObservable({
|
149
|
+
gridAxesTransform$
|
150
|
+
}).pipe(
|
151
|
+
takeUntil(destroy$),
|
152
|
+
shareReplay(1)
|
153
|
+
)
|
154
|
+
|
155
|
+
const gridGraphicTransform$ = gridGraphicTransformObservable({
|
156
|
+
computedData$: gridComputedData$,
|
157
|
+
fullDataFormatter$: gridDataFormatter$,
|
158
|
+
layout$: layout$
|
159
|
+
}).pipe(
|
160
|
+
takeUntil(destroy$),
|
161
|
+
shareReplay(1)
|
162
|
+
)
|
163
|
+
|
164
|
+
const gridGraphicReverseScale$ = gridGraphicReverseScaleObservable({
|
165
|
+
gridContainerPosition$: gridContainerPosition$,
|
166
|
+
gridAxesTransform$: gridAxesTransform$,
|
167
|
+
gridGraphicTransform$: gridGraphicTransform$,
|
216
168
|
})
|
169
|
+
|
170
|
+
const gridAxesSize$ = gridAxesSizeObservable({
|
171
|
+
fullDataFormatter$: gridDataFormatter$,
|
172
|
+
layout$: layout$
|
173
|
+
}).pipe(
|
174
|
+
takeUntil(destroy$),
|
175
|
+
shareReplay(1)
|
176
|
+
)
|
177
|
+
|
178
|
+
const datumList$ = gridComputedData$.pipe(
|
179
|
+
map(d => d.flat())
|
180
|
+
).pipe(
|
181
|
+
takeUntil(destroy$),
|
182
|
+
shareReplay(1)
|
183
|
+
)
|
184
|
+
|
185
|
+
// const gridHighlight$ = highlightObservable({
|
186
|
+
// datumList$,
|
187
|
+
// fullChartParams$: fullChartParams$,
|
188
|
+
// event$: event$
|
189
|
+
// }).pipe(
|
190
|
+
// shareReplay(1)
|
191
|
+
// )
|
192
|
+
|
193
|
+
const seriesLabels$ = seriesLabelsObservable({
|
194
|
+
computedData$: gridComputedData$,
|
195
|
+
}).pipe(
|
196
|
+
takeUntil(destroy$),
|
197
|
+
shareReplay(1)
|
198
|
+
)
|
199
|
+
|
200
|
+
const SeriesDataMap$ = seriesDataMapObservable({
|
201
|
+
datumList$: datumList$
|
202
|
+
}).pipe(
|
203
|
+
takeUntil(destroy$),
|
204
|
+
shareReplay(1)
|
205
|
+
)
|
206
|
+
|
207
|
+
const GroupDataMap$ = groupDataMapObservable({
|
208
|
+
datumList$: datumList$
|
209
|
+
}).pipe(
|
210
|
+
takeUntil(destroy$),
|
211
|
+
shareReplay(1)
|
212
|
+
)
|
213
|
+
|
214
|
+
const visibleComputedData$ = gridVisibleComputedDataObservable({
|
215
|
+
computedData$: gridComputedData$,
|
216
|
+
}).pipe(
|
217
|
+
takeUntil(destroy$),
|
218
|
+
shareReplay(1)
|
219
|
+
)
|
220
|
+
|
221
|
+
const computedLayoutData$ = gridComputedLayoutDataObservable({
|
222
|
+
computedData$: gridComputedData$,
|
223
|
+
fullDataFormatter$: gridDataFormatter$,
|
224
|
+
layout$: layout$,
|
225
|
+
}).pipe(
|
226
|
+
takeUntil(destroy$),
|
227
|
+
shareReplay(1)
|
228
|
+
)
|
229
|
+
|
230
|
+
const visibleComputedLayoutData$ = gridVisibleComputedLayoutDataObservable({
|
231
|
+
computedLayoutData$: computedLayoutData$,
|
232
|
+
}).pipe(
|
233
|
+
takeUntil(destroy$),
|
234
|
+
shareReplay(1)
|
235
|
+
)
|
236
|
+
|
237
|
+
return <ContextObserverMultiGridDetail>{
|
238
|
+
gridContainerPosition$,
|
239
|
+
gridAxesTransform$,
|
240
|
+
gridAxesReverseTransform$,
|
241
|
+
gridGraphicTransform$,
|
242
|
+
gridGraphicReverseScale$,
|
243
|
+
gridAxesSize$,
|
244
|
+
gridHighlight$: allGridHighlight$,
|
245
|
+
seriesLabels$,
|
246
|
+
SeriesDataMap$,
|
247
|
+
GroupDataMap$,
|
248
|
+
dataFormatter$: gridDataFormatter$,
|
249
|
+
computedData$: gridComputedData$,
|
250
|
+
computedLayoutData$,
|
251
|
+
visibleComputedData$,
|
252
|
+
visibleComputedLayoutData$,
|
253
|
+
// isSeriesSeprate$
|
254
|
+
}
|
217
255
|
})
|
218
256
|
})
|
219
257
|
)
|
@@ -221,66 +259,93 @@ export const multiGridEachDetailObservable = ({ fullDataFormatter$, computedData
|
|
221
259
|
|
222
260
|
|
223
261
|
// 所有container位置(對應series)
|
224
|
-
export const multiGridContainerObservable = ({ computedData$, fullDataFormatter$,
|
262
|
+
export const multiGridContainerObservable = ({ computedData$, fullDataFormatter$, layout$ }: {
|
225
263
|
computedData$: Observable<ComputedDataTypeMap<'multiGrid'>>
|
226
264
|
fullDataFormatter$: Observable<DataFormatterTypeMap<'multiGrid'>>
|
227
|
-
fullChartParams$: Observable<ChartParams>
|
228
265
|
layout$: Observable<Layout>
|
229
|
-
}) => {
|
266
|
+
}): Observable<GridContainerPosition[][]> => {
|
230
267
|
|
231
|
-
|
268
|
+
return combineLatest({
|
232
269
|
computedData: computedData$,
|
233
270
|
fullDataFormatter: fullDataFormatter$,
|
234
|
-
fullChartParams: fullChartParams$,
|
235
271
|
layout: layout$,
|
236
272
|
}).pipe(
|
237
273
|
switchMap(async (d) => d),
|
238
274
|
map(data => {
|
239
275
|
|
240
276
|
const defaultGrid = data.fullDataFormatter.gridList[0] ?? DATA_FORMATTER_MULTI_GRID_GRID_DEFAULT
|
241
|
-
|
242
|
-
const boxArr = data.computedData.map((gridData, gridIndex) => {
|
277
|
+
const slotAmount = data.computedData.reduce((acc, gridData, gridIndex) => {
|
243
278
|
const grid = data.fullDataFormatter.gridList[gridIndex] ?? defaultGrid
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
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
|
+
const gridSlotAmount = grid.separateSeries
|
280
|
+
? gridData.length
|
281
|
+
: data.fullDataFormatter.separateGrid
|
282
|
+
? 1
|
283
|
+
: 0 // 如果grid和series都不分開,則slotAmount不增加(在相同的slot)
|
284
|
+
return acc + gridSlotAmount
|
285
|
+
}, 0) || 1
|
286
|
+
|
287
|
+
const gridContainerLayout = calcGridContainerLayout(data.layout, data.fullDataFormatter.container, slotAmount)
|
279
288
|
|
289
|
+
let accGridSlotIndex = 0
|
290
|
+
const gridContainerPositionArr = data.computedData.map((gridData, gridIndex) => {
|
291
|
+
const grid = data.fullDataFormatter.gridList[gridIndex] ?? defaultGrid
|
292
|
+
const seriesContainerArr = gridData.map((seriesData, seriesIndex) => {
|
293
|
+
const container = gridContainerLayout[accGridSlotIndex]
|
294
|
+
if (grid.separateSeries) {
|
295
|
+
accGridSlotIndex += 1
|
296
|
+
}
|
297
|
+
return container
|
298
|
+
})
|
299
|
+
if (!grid.separateSeries && data.fullDataFormatter.separateGrid) {
|
300
|
+
accGridSlotIndex += 1
|
301
|
+
}
|
302
|
+
return seriesContainerArr
|
280
303
|
})
|
281
|
-
|
304
|
+
|
305
|
+
// let accGridSlotIndex = 0
|
306
|
+
|
307
|
+
// const gridContainerPositionArr = data.computedData.map((gridData, gridIndex) => {
|
308
|
+
// const grid = data.fullDataFormatter.gridList[gridIndex] ?? defaultGrid
|
309
|
+
|
310
|
+
// if (grid.separateSeries) {
|
311
|
+
// // -- 依seriesSlotIndexes計算 --
|
312
|
+
// const seriesContainerArr = gridData.map((seriesData, seriesIndex) => {
|
313
|
+
// const currentSlotIndex = accGridSlotIndex + seriesIndex
|
314
|
+
// const columnIndex = currentSlotIndex % data.fullDataFormatter.container.columnAmount
|
315
|
+
// const rowIndex = Math.floor(currentSlotIndex / data.fullDataFormatter.container.columnAmount)
|
316
|
+
// const { translate, scale } = calcGridContainerPosition(data.layout, data.fullDataFormatter.container, rowIndex, columnIndex)
|
317
|
+
// return {
|
318
|
+
// slotIndex: currentSlotIndex,
|
319
|
+
// rowIndex,
|
320
|
+
// columnIndex,
|
321
|
+
// translate,
|
322
|
+
// scale,
|
323
|
+
// }
|
324
|
+
// })
|
325
|
+
// accGridSlotIndex += seriesContainerArr.length
|
326
|
+
// return seriesContainerArr
|
327
|
+
// } else {
|
328
|
+
// // -- 依grid的slotIndex計算 --
|
329
|
+
// const columnIndex = accGridSlotIndex % data.fullDataFormatter.container.columnAmount
|
330
|
+
// const rowIndex = Math.floor(accGridSlotIndex / data.fullDataFormatter.container.columnAmount)
|
331
|
+
// const seriesContainerArr = gridData.map((seriesData, seriesIndex) => {
|
332
|
+
// const { translate, scale } = calcGridContainerPosition(data.layout, data.fullDataFormatter.container, rowIndex, columnIndex)
|
333
|
+
// return {
|
334
|
+
// slotIndex: accGridSlotIndex,
|
335
|
+
// rowIndex,
|
336
|
+
// columnIndex,
|
337
|
+
// translate,
|
338
|
+
// scale,
|
339
|
+
// }
|
340
|
+
// })
|
341
|
+
// if (data.fullDataFormatter.separateGrid) {
|
342
|
+
// accGridSlotIndex += 1
|
343
|
+
// }
|
344
|
+
// return seriesContainerArr
|
345
|
+
// }
|
346
|
+
// })
|
347
|
+
|
348
|
+
return gridContainerPositionArr
|
282
349
|
}),
|
283
350
|
)
|
284
|
-
|
285
|
-
return multiGridContainer$
|
286
351
|
}
|
@@ -7,11 +7,17 @@ import { createAxisLinearScale, createAxisPointScale } from '../utils/d3Utils'
|
|
7
7
|
import { getMinAndMaxValue } from '../utils/orbchartsUtils'
|
8
8
|
|
9
9
|
export const computeMultiValueData: ComputedDataFn<'multiValue'> = (context) => {
|
10
|
-
const { data, dataFormatter, chartParams
|
10
|
+
const { data, dataFormatter, chartParams } = context
|
11
11
|
if (!data.length) {
|
12
12
|
return []
|
13
13
|
}
|
14
14
|
|
15
|
+
// @Q@ 假資料待改寫
|
16
|
+
const layout = {
|
17
|
+
width: 1000,
|
18
|
+
height: 1000
|
19
|
+
}
|
20
|
+
|
15
21
|
let computedDataMultiValue: ComputedDatumMultiValue[][] = []
|
16
22
|
|
17
23
|
try {
|
@@ -85,18 +91,18 @@ export const computeMultiValueData: ComputedDataFn<'multiValue'> = (context) =>
|
|
85
91
|
dataFormatter.yAxis.scaleDomain[1] === 'auto' ? yMaxValue : dataFormatter.yAxis.scaleDomain[1]
|
86
92
|
]
|
87
93
|
|
88
|
-
// 篩選顯示狀態
|
89
|
-
const visibleFilter = (datum: DataMultiValueDatum, rowIndex: number, columnIndex: number, context: DataFormatterContext<"multiValue">) => {
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
94
|
+
// // 篩選顯示狀態
|
95
|
+
// const visibleFilter = (datum: DataMultiValueDatum, rowIndex: number, columnIndex: number, context: DataFormatterContext<"multiValue">) => {
|
96
|
+
// // 如果不在scale的範圍內則為false,不再做visibleFilter的判斷
|
97
|
+
// if (columnIndex === 0 && datum.value != null && ((datum.value as number) < _xScaleDoamin[0] || datum.value > _xScaleDoamin[1])) {
|
98
|
+
// return false
|
99
|
+
// }
|
100
|
+
// if (columnIndex === 1 && datum.value != null && (datum.value < _yScaleDoamin[0] || datum.value > _yScaleDoamin[1])) {
|
101
|
+
// return false
|
102
|
+
// }
|
97
103
|
|
98
|
-
|
99
|
-
}
|
104
|
+
// return dataFormatter.visibleFilter(datum, rowIndex, columnIndex, context)
|
105
|
+
// }
|
100
106
|
|
101
107
|
let index = 0
|
102
108
|
|
@@ -106,8 +112,6 @@ export const computeMultiValueData: ComputedDataFn<'multiValue'> = (context) =>
|
|
106
112
|
index++
|
107
113
|
|
108
114
|
const defaultId = createDefaultDatumId(dataFormatter.type, i, _i)
|
109
|
-
// const visible = dataFormatter.visibleFilter(_d, i, _i, context)
|
110
|
-
const visible = visibleFilter(_d, i, _i, context)
|
111
115
|
|
112
116
|
const computedDatum: ComputedDatumMultiValue = {
|
113
117
|
id: _d.id ? _d.id : defaultId,
|
@@ -121,9 +125,12 @@ export const computeMultiValueData: ComputedDataFn<'multiValue'> = (context) =>
|
|
121
125
|
categoryLabel: '', // @Q@ 未完成
|
122
126
|
// valueLabel: formatValueToLabel(_d.value, dataFormatter.multiValue[_i].valueFormat),
|
123
127
|
axis: _i == 0 ? xScale(_d.value) : yScale(_d.value),
|
124
|
-
visible,
|
128
|
+
visible: true, // 先給預設值
|
125
129
|
color: '' // @Q@ 未完成
|
126
130
|
}
|
131
|
+
|
132
|
+
computedDatum.visible = dataFormatter.visibleFilter(computedDatum, context)
|
133
|
+
|
127
134
|
return computedDatum
|
128
135
|
})
|
129
136
|
})
|
@@ -28,7 +28,7 @@ export const computeRelationshipData: ComputedDataFn<'relationship'> = (context)
|
|
28
28
|
|
29
29
|
// -- nodes --
|
30
30
|
computedNodes = nodes.map((node, i) => {
|
31
|
-
|
31
|
+
const computedNode: ComputedNode = {
|
32
32
|
id: node.id,
|
33
33
|
index: i,
|
34
34
|
label: node.label ?? '',
|
@@ -43,15 +43,16 @@ export const computeRelationshipData: ComputedDataFn<'relationship'> = (context)
|
|
43
43
|
startNodeIds: [], // 後面再取得資料
|
44
44
|
endNodes: [], // 後面再取得資料
|
45
45
|
endNodeIds: [], // 後面再取得資料
|
46
|
-
visible:
|
46
|
+
visible: true // 後面再取得資料
|
47
47
|
}
|
48
|
+
return computedNode
|
48
49
|
})
|
49
50
|
|
50
51
|
const NodesMap: Map<string, ComputedNode> = new Map(computedNodes.map(d => [d.id, d]))
|
51
52
|
|
52
53
|
// -- edges --
|
53
54
|
computedEdges = edges.map((edge, i) => {
|
54
|
-
|
55
|
+
const computedEdge: ComputedEdge = {
|
55
56
|
id: edge.id,
|
56
57
|
index: i,
|
57
58
|
label: edge.label ?? '',
|
@@ -63,8 +64,10 @@ export const computeRelationshipData: ComputedDataFn<'relationship'> = (context)
|
|
63
64
|
startNodeId: edge.start,
|
64
65
|
endNode: NodesMap.get(edge.end),
|
65
66
|
endNodeId: edge.end,
|
66
|
-
visible:
|
67
|
+
visible: true // 先給預設值
|
67
68
|
}
|
69
|
+
|
70
|
+
return computedEdge
|
68
71
|
})
|
69
72
|
|
70
73
|
const StartNodesMap: Map<string, ComputedNode[]> = (function () {
|
@@ -93,6 +96,15 @@ export const computeRelationshipData: ComputedDataFn<'relationship'> = (context)
|
|
93
96
|
node.startNodeIds = node.startNodes.map(d => d.id)
|
94
97
|
node.endNodes = EndNodesMap.get(nodeId)
|
95
98
|
node.endNodeIds = node.endNodes.map(d => d.id)
|
99
|
+
node.visible = dataFormatter.visibleFilter(node, context)
|
100
|
+
})
|
101
|
+
|
102
|
+
// -- 補齊edges資料 --
|
103
|
+
computedEdges = computedEdges.map(edge => {
|
104
|
+
edge.visible = edge.startNode.visible && edge.endNode.visible
|
105
|
+
? true
|
106
|
+
: false
|
107
|
+
return edge
|
96
108
|
})
|
97
109
|
} catch (e) {
|
98
110
|
// console.error(e)
|