@orbcharts/core 3.0.0-beta.9 → 3.0.0
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.
- package/dist/orbcharts-core.es.js +2779 -2398
- package/dist/orbcharts-core.umd.js +4 -4
- package/dist/src/defaults.d.ts +2 -1
- package/dist/src/utils/gridObservables.d.ts +8 -4
- package/dist/src/utils/index.d.ts +0 -3
- package/dist/src/utils/multiGridObservables.d.ts +3 -2
- package/dist/src/utils/multiValueObservables.d.ts +76 -29
- package/dist/src/utils/observables.d.ts +8 -1
- package/dist/src/utils/orbchartsUtils.d.ts +9 -9
- package/dist/src/utils/seriesObservables.d.ts +1 -1
- package/package.json +2 -2
- package/src/base/createBaseChart.ts +4 -3
- package/src/base/createBasePlugin.ts +5 -4
- package/src/base/validators/chartParamsValidator.ts +4 -4
- package/src/defaults.ts +54 -10
- package/src/grid/contextObserverCallback.ts +31 -9
- package/src/grid/dataFormatterValidator.ts +42 -23
- package/src/multiGrid/contextObserverCallback.ts +38 -7
- package/src/multiValue/computedDataFn.ts +4 -1
- package/src/multiValue/contextObserverCallback.ts +159 -43
- package/src/multiValue/dataFormatterValidator.ts +85 -5
- package/src/multiValue/dataValidator.ts +9 -6
- package/src/relationship/computedDataFn.ts +37 -22
- package/src/relationship/dataFormatterValidator.ts +10 -6
- package/src/relationship/dataValidator.ts +10 -6
- package/src/series/contextObserverCallback.ts +18 -11
- package/src/tree/dataValidator.ts +1 -1
- package/src/utils/gridObservables.ts +32 -10
- package/src/utils/index.ts +3 -3
- package/src/utils/multiGridObservables.ts +34 -25
- package/src/utils/multiValueObservables.ts +479 -97
- package/src/utils/observables.ts +77 -15
- package/src/utils/orbchartsUtils.ts +9 -9
- package/src/utils/seriesObservables.ts +4 -4
- package/src/utils/validator.ts +1 -1
@@ -1,10 +1,14 @@
|
|
1
1
|
import type { DataValidator, DataTypeMap } from '../../lib/core-types'
|
2
|
+
import { validateColumns } from '../utils/validator'
|
3
|
+
import { isPlainObject } from '../utils'
|
2
4
|
|
3
5
|
export const dataValidator: DataValidator<'relationship'> = (data: DataTypeMap<'relationship'>) => {
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
6
|
+
const result = validateColumns({ data }, {
|
7
|
+
data: {
|
8
|
+
toBe: 'DataRelationshipObj | DataRelationshipList',
|
9
|
+
// 畢免資料量過大檢查不完,不深度檢查
|
10
|
+
test: (value) => isPlainObject(value) || Array.isArray(value)
|
11
|
+
}
|
12
|
+
})
|
13
|
+
return result
|
10
14
|
}
|
@@ -8,7 +8,7 @@ import { highlightObservable, textSizePxObservable } from '../utils/observables'
|
|
8
8
|
import {
|
9
9
|
separateSeriesObservable,
|
10
10
|
seriesVisibleComputedDataObservable,
|
11
|
-
|
11
|
+
seriesComputedSortedDataObservable,
|
12
12
|
seriesLabelsObservable,
|
13
13
|
seriesContainerPositionObservable,
|
14
14
|
seriesContainerPositionMapObservable
|
@@ -22,22 +22,28 @@ export const contextObserverCallback: ContextObserverCallback<'series'> = ({ sub
|
|
22
22
|
|
23
23
|
const separateSeries$ = separateSeriesObservable({
|
24
24
|
fullDataFormatter$: observer.fullDataFormatter$
|
25
|
-
})
|
25
|
+
}).pipe(
|
26
|
+
shareReplay(1)
|
27
|
+
)
|
26
28
|
|
27
29
|
const visibleComputedData$ = seriesVisibleComputedDataObservable({
|
28
30
|
computedData$: observer.computedData$,
|
29
|
-
})
|
31
|
+
}).pipe(
|
32
|
+
shareReplay(1)
|
33
|
+
)
|
30
34
|
|
31
|
-
const
|
35
|
+
const computedSortedData$ = seriesComputedSortedDataObservable({
|
32
36
|
computedData$: observer.computedData$,
|
33
37
|
fullDataFormatter$: observer.fullDataFormatter$
|
34
38
|
}).pipe(
|
35
39
|
shareReplay(1)
|
36
40
|
)
|
37
41
|
|
38
|
-
const
|
39
|
-
computedData$:
|
40
|
-
})
|
42
|
+
const visibleComputedSortedData$ = seriesVisibleComputedDataObservable({
|
43
|
+
computedData$: computedSortedData$,
|
44
|
+
}).pipe(
|
45
|
+
shareReplay(1)
|
46
|
+
)
|
41
47
|
|
42
48
|
const datumList$ = observer.computedData$.pipe(
|
43
49
|
map(d => d.flat())
|
@@ -55,8 +61,9 @@ export const contextObserverCallback: ContextObserverCallback<'series'> = ({ sub
|
|
55
61
|
|
56
62
|
const seriesLabels$ = seriesLabelsObservable({
|
57
63
|
computedData$: observer.computedData$,
|
58
|
-
})
|
59
|
-
|
64
|
+
}).pipe(
|
65
|
+
shareReplay(1)
|
66
|
+
)
|
60
67
|
|
61
68
|
const SeriesDataMap$ = seriesDataMapObservable({
|
62
69
|
datumList$
|
@@ -88,9 +95,9 @@ export const contextObserverCallback: ContextObserverCallback<'series'> = ({ sub
|
|
88
95
|
layout$: observer.layout$,
|
89
96
|
textSizePx$,
|
90
97
|
visibleComputedData$,
|
91
|
-
|
98
|
+
visibleComputedSortedData$,
|
92
99
|
separateSeries$,
|
93
|
-
|
100
|
+
computedSortedData$,
|
94
101
|
seriesHighlight$,
|
95
102
|
seriesLabels$,
|
96
103
|
SeriesDataMap$,
|
@@ -7,7 +7,7 @@ export const dataValidator: DataValidator<'tree'> = (data: DataTypeMap<'tree'>)
|
|
7
7
|
data: {
|
8
8
|
toBe: 'DataTreeObj | DataTreeDatum[]',
|
9
9
|
// 畢免資料量過大檢查不完,不深度檢查
|
10
|
-
test: (value) => isPlainObject(value) && value.id !== undefined
|
10
|
+
test: (value) => (isPlainObject(value) && value.id !== undefined) || Array.isArray(value)
|
11
11
|
}
|
12
12
|
})
|
13
13
|
return result
|
@@ -17,6 +17,7 @@ import type {
|
|
17
17
|
ComputedDataTypeMap,
|
18
18
|
ComputedDatumTypeMap,
|
19
19
|
ComputedDataGrid,
|
20
|
+
ContainerSize,
|
20
21
|
DataTypeMap,
|
21
22
|
DataGridDatum,
|
22
23
|
ComputedDatumGrid,
|
@@ -25,17 +26,17 @@ import type {
|
|
25
26
|
DataFormatterValueAxis,
|
26
27
|
DataFormatterGroupAxis,
|
27
28
|
ComputedLayoutDatumGrid,
|
28
|
-
|
29
|
+
ComputedAxesDataGrid,
|
29
30
|
ContainerPositionScaled,
|
30
31
|
HighlightTarget,
|
31
32
|
Layout,
|
32
33
|
TransformData } from '../../lib/core-types'
|
33
34
|
import { getMinMaxGrid } from './orbchartsUtils'
|
34
35
|
import { createValueToAxisScale, createLabelToAxisScale, createAxisToLabelIndexScale } from './d3Scale'
|
35
|
-
import {
|
36
|
+
import { calcContainerPositionScaled } from './orbchartsUtils'
|
36
37
|
import { getMinMaxValue } from './orbchartsUtils'
|
37
38
|
|
38
|
-
export const
|
39
|
+
export const gridComputedAxesDataObservable = ({ computedData$, fullDataFormatter$, layout$ }: {
|
39
40
|
computedData$: Observable<ComputedDataTypeMap<'grid'>>
|
40
41
|
fullDataFormatter$: Observable<DataFormatterTypeMap<'grid'>>
|
41
42
|
layout$: Observable<Layout>
|
@@ -138,9 +139,20 @@ export const gridAxesSizeObservable = ({ fullDataFormatter$, layout$ }: {
|
|
138
139
|
}
|
139
140
|
}
|
140
141
|
|
142
|
+
const groupAxisPosition$ = fullDataFormatter$.pipe(
|
143
|
+
map(d => d.groupAxis.position),
|
144
|
+
distinctUntilChanged()
|
145
|
+
)
|
146
|
+
|
147
|
+
const valueAxisPosition$ = fullDataFormatter$.pipe(
|
148
|
+
map(d => d.valueAxis.position),
|
149
|
+
distinctUntilChanged()
|
150
|
+
)
|
151
|
+
|
141
152
|
return new Observable(subscriber => {
|
142
153
|
combineLatest({
|
143
|
-
|
154
|
+
groupAxisPosition: groupAxisPosition$,
|
155
|
+
valueAxisPosition: valueAxisPosition$,
|
144
156
|
layout: layout$
|
145
157
|
}).pipe(
|
146
158
|
takeUntil(destroy$),
|
@@ -148,8 +160,8 @@ export const gridAxesSizeObservable = ({ fullDataFormatter$, layout$ }: {
|
|
148
160
|
).subscribe(data => {
|
149
161
|
|
150
162
|
const axisSize = calcAxesSize({
|
151
|
-
xAxisPosition: data.
|
152
|
-
yAxisPosition: data.
|
163
|
+
xAxisPosition: data.groupAxisPosition,
|
164
|
+
yAxisPosition: data.valueAxisPosition,
|
153
165
|
width: data.layout.width,
|
154
166
|
height: data.layout.height,
|
155
167
|
})
|
@@ -163,6 +175,16 @@ export const gridAxesSizeObservable = ({ fullDataFormatter$, layout$ }: {
|
|
163
175
|
})
|
164
176
|
}
|
165
177
|
|
178
|
+
export const gridAxesContainerSizeObservable = ({ fullDataFormatter$, containerSize$ }: {
|
179
|
+
containerSize$: Observable<ContainerSize>
|
180
|
+
fullDataFormatter$: Observable<DataFormatterTypeMap<'grid'>>
|
181
|
+
}): Observable<ContainerSize> => {
|
182
|
+
return gridAxesSizeObservable({
|
183
|
+
fullDataFormatter$,
|
184
|
+
layout$: containerSize$ as Observable<Layout>
|
185
|
+
})
|
186
|
+
}
|
187
|
+
|
166
188
|
// export const gridHighlightObservable = ({ computedData$, fullChartParams$, event$ }: {
|
167
189
|
// computedData$: Observable<ComputedDataTypeMap<'grid'>>
|
168
190
|
// fullChartParams$: Observable<ChartParams>
|
@@ -204,8 +226,8 @@ export const gridVisibleComputedDataObservable = ({ computedData$ }: { computedD
|
|
204
226
|
)
|
205
227
|
}
|
206
228
|
|
207
|
-
export const
|
208
|
-
return
|
229
|
+
export const gridVisibleComputedAxesDataObservable = ({ computedAxesData$ }: { computedAxesData$: Observable<ComputedAxesDataGrid> }) => {
|
230
|
+
return computedAxesData$.pipe(
|
209
231
|
map(data => {
|
210
232
|
const visibleComputedData = data
|
211
233
|
.map(d => {
|
@@ -236,7 +258,7 @@ export const gridContainerPositionObservable = ({ computedData$, fullDataFormatt
|
|
236
258
|
|
237
259
|
if (data.fullDataFormatter.separateSeries) {
|
238
260
|
// -- 依slotIndexes計算 --
|
239
|
-
return
|
261
|
+
return calcContainerPositionScaled(data.layout, data.fullDataFormatter.container, data.computedData.length)
|
240
262
|
// return data.computedData.map((seriesData, seriesIndex) => {
|
241
263
|
// const columnIndex = seriesIndex % data.fullDataFormatter.container.columnAmount
|
242
264
|
// const rowIndex = Math.floor(seriesIndex / data.fullDataFormatter.container.columnAmount)
|
@@ -251,7 +273,7 @@ export const gridContainerPositionObservable = ({ computedData$, fullDataFormatt
|
|
251
273
|
// })
|
252
274
|
} else {
|
253
275
|
// -- 無拆分 --
|
254
|
-
const gridContainerPositionArr =
|
276
|
+
const gridContainerPositionArr = calcContainerPositionScaled(data.layout, data.fullDataFormatter.container, 1)
|
255
277
|
return data.computedData.map((d, i) => gridContainerPositionArr[0]) // 每個series相同位置
|
256
278
|
// const columnIndex = 0
|
257
279
|
// const rowIndex = 0
|
package/src/utils/index.ts
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
export * from './commonUtils'
|
2
2
|
export * from './d3Scale'
|
3
3
|
export * from './gridObservables'
|
4
|
-
export * from './multiGridObservables'
|
4
|
+
// export * from './multiGridObservables'
|
5
5
|
// export * from './multiValueObservables'
|
6
6
|
export * from './observables'
|
7
7
|
export * from './orbchartsUtils'
|
8
8
|
// export * from './relationshipObservables'
|
9
|
-
export * from './seriesObservables'
|
10
|
-
export * from './treeObservables'
|
9
|
+
// export * from './seriesObservables'
|
10
|
+
// export * from './treeObservables'
|
@@ -18,6 +18,7 @@ import type {
|
|
18
18
|
ComputedDataTypeMap,
|
19
19
|
ComputedDataGrid,
|
20
20
|
ContextObserverMultiGridDetail,
|
21
|
+
ContainerSize,
|
21
22
|
DataTypeMap,
|
22
23
|
DataFormatterTypeMap,
|
23
24
|
DataFormatterGrid,
|
@@ -32,11 +33,12 @@ import {
|
|
32
33
|
seriesDataMapObservable,
|
33
34
|
groupDataMapObservable } from './observables'
|
34
35
|
import {
|
35
|
-
|
36
|
+
gridComputedAxesDataObservable,
|
36
37
|
gridAxesSizeObservable,
|
38
|
+
gridAxesContainerSizeObservable,
|
37
39
|
gridSeriesLabelsObservable,
|
38
40
|
gridVisibleComputedDataObservable,
|
39
|
-
|
41
|
+
gridVisibleComputedAxesDataObservable,
|
40
42
|
// isSeriesSeprateObservable,
|
41
43
|
gridContainerPositionObservable,
|
42
44
|
computedStackedDataObservables,
|
@@ -48,30 +50,31 @@ import {
|
|
48
50
|
gridGraphicReverseScaleObservable,
|
49
51
|
} from './gridObservables'
|
50
52
|
import { DEFAULT_DATA_FORMATTER_MULTI_GRID_GRID } from '../defaults'
|
51
|
-
import {
|
53
|
+
import { calcContainerPositionScaled } from './orbchartsUtils'
|
52
54
|
|
53
55
|
// 每一個grid計算出來的所有Observable
|
54
|
-
export const multiGridEachDetailObservable = ({ fullDataFormatter$, computedData$, layout$, fullChartParams$, event$ }: {
|
56
|
+
export const multiGridEachDetailObservable = ({ fullDataFormatter$, computedData$, layout$, fullChartParams$, event$, containerSize$ }: {
|
55
57
|
fullDataFormatter$: Observable<DataFormatterTypeMap<'multiGrid'>>
|
56
58
|
computedData$: Observable<ComputedDataTypeMap<'multiGrid'>>
|
57
59
|
layout$: Observable<Layout>
|
58
60
|
fullChartParams$: Observable<ChartParams>
|
59
61
|
event$: Subject<EventMultiGrid>
|
62
|
+
containerSize$: Observable<ContainerSize>
|
60
63
|
}): Observable<ContextObserverMultiGridDetail[]> => {
|
61
64
|
|
62
65
|
const destroy$ = new Subject()
|
63
66
|
|
64
|
-
// highlight全部grid
|
65
|
-
const allGridHighlight$ = highlightObservable({
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
}).pipe(
|
73
|
-
|
74
|
-
)
|
67
|
+
// // highlight全部grid
|
68
|
+
// const allGridHighlight$ = highlightObservable({
|
69
|
+
// datumList$: computedData$.pipe(
|
70
|
+
// map(d => d.flat().flat()),
|
71
|
+
// shareReplay(1)
|
72
|
+
// ),
|
73
|
+
// fullChartParams$: fullChartParams$,
|
74
|
+
// event$: event$
|
75
|
+
// }).pipe(
|
76
|
+
// shareReplay(1)
|
77
|
+
// )
|
75
78
|
|
76
79
|
const multiGridContainer$ = multiGridContainerObservable({
|
77
80
|
computedData$: computedData$,
|
@@ -146,9 +149,7 @@ export const multiGridEachDetailObservable = ({ fullDataFormatter$, computedData
|
|
146
149
|
takeUntil(destroy$),
|
147
150
|
shareReplay(1)
|
148
151
|
)
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
+
|
152
153
|
const gridAxesSize$ = gridAxesSizeObservable({
|
153
154
|
fullDataFormatter$: gridDataFormatter$,
|
154
155
|
layout$: layout$
|
@@ -156,6 +157,13 @@ export const multiGridEachDetailObservable = ({ fullDataFormatter$, computedData
|
|
156
157
|
takeUntil(destroy$),
|
157
158
|
shareReplay(1)
|
158
159
|
)
|
160
|
+
|
161
|
+
const gridAxesContainerSize$ = gridAxesContainerSizeObservable({
|
162
|
+
fullDataFormatter$: gridDataFormatter$,
|
163
|
+
containerSize$: containerSize$
|
164
|
+
}).pipe(
|
165
|
+
shareReplay(1)
|
166
|
+
)
|
159
167
|
|
160
168
|
const datumList$ = gridComputedData$.pipe(
|
161
169
|
map(d => d.flat())
|
@@ -200,7 +208,7 @@ export const multiGridEachDetailObservable = ({ fullDataFormatter$, computedData
|
|
200
208
|
shareReplay(1)
|
201
209
|
)
|
202
210
|
|
203
|
-
const
|
211
|
+
const computedAxesData$ = gridComputedAxesDataObservable({
|
204
212
|
computedData$: gridComputedData$,
|
205
213
|
fullDataFormatter$: gridDataFormatter$,
|
206
214
|
layout$: layout$,
|
@@ -209,8 +217,8 @@ export const multiGridEachDetailObservable = ({ fullDataFormatter$, computedData
|
|
209
217
|
shareReplay(1)
|
210
218
|
)
|
211
219
|
|
212
|
-
const
|
213
|
-
|
220
|
+
const visibleComputedAxesData$ = gridVisibleComputedAxesDataObservable({
|
221
|
+
computedAxesData$: computedAxesData$,
|
214
222
|
}).pipe(
|
215
223
|
takeUntil(destroy$),
|
216
224
|
shareReplay(1)
|
@@ -276,15 +284,16 @@ export const multiGridEachDetailObservable = ({ fullDataFormatter$, computedData
|
|
276
284
|
isSeriesSeprate$,
|
277
285
|
gridContainerPosition$,
|
278
286
|
gridAxesSize$,
|
279
|
-
|
287
|
+
gridAxesContainerSize$,
|
288
|
+
// gridHighlight$: allGridHighlight$,
|
280
289
|
seriesLabels$,
|
281
290
|
SeriesDataMap$,
|
282
291
|
GroupDataMap$,
|
283
292
|
dataFormatter$: gridDataFormatter$,
|
284
293
|
computedData$: gridComputedData$,
|
285
|
-
|
294
|
+
computedAxesData$,
|
286
295
|
visibleComputedData$,
|
287
|
-
|
296
|
+
visibleComputedAxesData$,
|
288
297
|
computedStackedData$,
|
289
298
|
groupScaleDomainValue$,
|
290
299
|
filteredMinMaxValue$,
|
@@ -325,7 +334,7 @@ export const multiGridContainerObservable = ({ computedData$, fullDataFormatter$
|
|
325
334
|
return acc + gridSlotAmount
|
326
335
|
}, 0) || 1
|
327
336
|
|
328
|
-
const gridContainerLayout =
|
337
|
+
const gridContainerLayout = calcContainerPositionScaled(data.layout, data.fullDataFormatter.container, slotAmount)
|
329
338
|
|
330
339
|
let accGridSlotIndex = 0
|
331
340
|
const gridContainerPositionArr = data.computedData.map((gridData, gridIndex) => {
|