@orbcharts/core 3.0.0-beta.3 → 3.0.0-beta.4
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/LICENSE +200 -200
- package/dist/orbcharts-core.es.js +2623 -2338
- package/dist/orbcharts-core.umd.js +4 -4
- package/dist/src/utils/d3Scale.d.ts +28 -0
- package/dist/src/utils/gridObservables.d.ts +29 -19
- package/dist/src/utils/index.d.ts +1 -1
- package/dist/src/utils/multiGridObservables.d.ts +2 -2
- package/dist/src/utils/multiValueObservables.d.ts +73 -0
- package/dist/src/utils/orbchartsUtils.d.ts +19 -5
- package/dist/src/utils/seriesObservables.d.ts +4 -4
- package/dist/src/utils/treeObservables.d.ts +2 -5
- package/lib/core-types.ts +7 -7
- package/package.json +42 -42
- package/src/AbstractChart.ts +57 -57
- package/src/GridChart.ts +24 -24
- package/src/MultiGridChart.ts +24 -24
- package/src/MultiValueChart.ts +24 -24
- package/src/RelationshipChart.ts +24 -24
- package/src/SeriesChart.ts +24 -24
- package/src/TreeChart.ts +24 -24
- package/src/base/createBaseChart.ts +505 -505
- package/src/base/createBasePlugin.ts +153 -153
- package/src/base/validators/chartOptionsValidator.ts +23 -23
- package/src/base/validators/chartParamsValidator.ts +133 -133
- package/src/base/validators/elementValidator.ts +13 -13
- package/src/base/validators/pluginsValidator.ts +14 -14
- package/src/defaults.ts +235 -232
- package/src/defineGridPlugin.ts +3 -3
- package/src/defineMultiGridPlugin.ts +3 -3
- package/src/defineMultiValuePlugin.ts +3 -3
- package/src/defineNoneDataPlugin.ts +4 -4
- package/src/defineRelationshipPlugin.ts +3 -3
- package/src/defineSeriesPlugin.ts +3 -3
- package/src/defineTreePlugin.ts +3 -3
- package/src/grid/computedDataFn.ts +129 -129
- package/src/grid/contextObserverCallback.ts +176 -155
- package/src/grid/dataFormatterValidator.ts +101 -101
- package/src/grid/dataValidator.ts +12 -12
- package/src/index.ts +20 -20
- package/src/multiGrid/computedDataFn.ts +123 -123
- package/src/multiGrid/contextObserverCallback.ts +41 -41
- package/src/multiGrid/dataFormatterValidator.ts +115 -115
- package/src/multiGrid/dataValidator.ts +12 -12
- package/src/multiValue/computedDataFn.ts +110 -176
- package/src/multiValue/contextObserverCallback.ts +160 -12
- package/src/multiValue/dataFormatterValidator.ts +9 -9
- package/src/multiValue/dataValidator.ts +9 -9
- package/src/relationship/computedDataFn.ts +125 -125
- package/src/relationship/contextObserverCallback.ts +12 -12
- package/src/relationship/dataFormatterValidator.ts +9 -9
- package/src/relationship/dataValidator.ts +9 -9
- package/src/series/computedDataFn.ts +88 -88
- package/src/series/contextObserverCallback.ts +100 -100
- package/src/series/dataFormatterValidator.ts +41 -41
- package/src/series/dataValidator.ts +12 -12
- package/src/tree/computedDataFn.ts +129 -130
- package/src/tree/contextObserverCallback.ts +58 -61
- package/src/tree/dataFormatterValidator.ts +13 -13
- package/src/tree/dataValidator.ts +13 -13
- package/src/utils/commonUtils.ts +55 -55
- package/src/utils/d3Scale.ts +198 -0
- package/src/utils/errorMessage.ts +42 -42
- package/src/utils/gridObservables.ts +671 -614
- package/src/utils/index.ts +9 -9
- package/src/utils/multiGridObservables.ts +392 -366
- package/src/utils/multiValueObservables.ts +643 -0
- package/src/utils/observables.ts +219 -219
- package/src/utils/orbchartsUtils.ts +377 -352
- package/src/utils/seriesObservables.ts +175 -175
- package/src/utils/treeObservables.ts +105 -94
- package/src/utils/validator.ts +126 -125
- package/tsconfig.base.json +13 -13
- package/tsconfig.json +2 -2
- package/vite-env.d.ts +6 -6
- package/vite.config.js +22 -22
- package/dist/src/utils/d3Utils.d.ts +0 -19
- package/src/utils/d3Utils.ts +0 -108
@@ -1,88 +1,88 @@
|
|
1
|
-
import type { DataSeries, DataSeriesDatum, ComputedDataFn, ComputedDatumSeries } from '../../lib/core-types'
|
2
|
-
import { formatValueToLabel, createDefaultDatumId, createDefaultSeriesLabel, seriesColorPredicate } from '../utils/orbchartsUtils'
|
3
|
-
|
4
|
-
export const computedDataFn: ComputedDataFn<'series'> = (context) => {
|
5
|
-
const { data = [], dataFormatter, chartParams } = context
|
6
|
-
if (!data.length) {
|
7
|
-
return []
|
8
|
-
}
|
9
|
-
|
10
|
-
let computedDataSeries: ComputedDatumSeries[][] = []
|
11
|
-
|
12
|
-
try {
|
13
|
-
|
14
|
-
const createComputedDatumSeries = (seriesData: number | DataSeriesDatum, seriesIndex: number, itemIndex: number, currentIndex: number): ComputedDatumSeries => {
|
15
|
-
const defaultId = createDefaultDatumId(dataFormatter.type, seriesIndex, itemIndex)
|
16
|
-
const seriesLabel = dataFormatter.seriesLabels[seriesIndex] || createDefaultSeriesLabel('series', seriesIndex)
|
17
|
-
const color = seriesColorPredicate(seriesIndex, chartParams)
|
18
|
-
if (typeof seriesData === 'number') {
|
19
|
-
return {
|
20
|
-
id: defaultId,
|
21
|
-
index: currentIndex,
|
22
|
-
seq: 0, // 先給預設值
|
23
|
-
label: defaultId,
|
24
|
-
description: '',
|
25
|
-
data: {},
|
26
|
-
value: seriesData,
|
27
|
-
seriesIndex: seriesIndex,
|
28
|
-
seriesLabel,
|
29
|
-
color,
|
30
|
-
visible: true // 先給預設值
|
31
|
-
}
|
32
|
-
} else {
|
33
|
-
return {
|
34
|
-
id: seriesData.id ? seriesData.id : defaultId,
|
35
|
-
index: currentIndex,
|
36
|
-
seq: 0, // 先給預設值
|
37
|
-
label: seriesData.label ? seriesData.label : defaultId,
|
38
|
-
description: seriesData.description,
|
39
|
-
data: seriesData.data ?? {},
|
40
|
-
value: seriesData.value,
|
41
|
-
seriesIndex: seriesIndex,
|
42
|
-
seriesLabel,
|
43
|
-
color,
|
44
|
-
visible: true // 先給預設值
|
45
|
-
}
|
46
|
-
}
|
47
|
-
}
|
48
|
-
|
49
|
-
computedDataSeries = data
|
50
|
-
.map((seriesData, seriesIndex) => {
|
51
|
-
if (Array.isArray(seriesData)) {
|
52
|
-
return seriesData.map((item, itemIndex) =>
|
53
|
-
createComputedDatumSeries(item, seriesIndex, itemIndex, computedDataSeries.length + itemIndex)
|
54
|
-
)
|
55
|
-
} else {
|
56
|
-
return createComputedDatumSeries(seriesData, seriesIndex, 0, computedDataSeries.length)
|
57
|
-
}
|
58
|
-
})
|
59
|
-
// 攤為一維陣列
|
60
|
-
.flat()
|
61
|
-
// 排序後給 seq
|
62
|
-
.sort(dataFormatter.sort ?? undefined)
|
63
|
-
.map((datum, index) => {
|
64
|
-
datum.seq = index
|
65
|
-
return datum
|
66
|
-
})
|
67
|
-
.map(datum => {
|
68
|
-
datum.visible = dataFormatter.visibleFilter(datum, context)
|
69
|
-
return datum
|
70
|
-
})
|
71
|
-
// 恢復原排序
|
72
|
-
.sort((a, b) => a.index - b.index)
|
73
|
-
// 依seriesIndex分組(二維陣列)
|
74
|
-
.reduce((acc, datum) => {
|
75
|
-
if (!acc[datum.seriesIndex]) {
|
76
|
-
acc[datum.seriesIndex] = []
|
77
|
-
}
|
78
|
-
acc[datum.seriesIndex].push(datum)
|
79
|
-
return acc
|
80
|
-
}, [])
|
81
|
-
|
82
|
-
} catch (e) {
|
83
|
-
// console.error(e)
|
84
|
-
throw Error(e)
|
85
|
-
}
|
86
|
-
|
87
|
-
return computedDataSeries
|
88
|
-
}
|
1
|
+
import type { DataSeries, DataSeriesDatum, ComputedDataFn, ComputedDatumSeries } from '../../lib/core-types'
|
2
|
+
import { formatValueToLabel, createDefaultDatumId, createDefaultSeriesLabel, seriesColorPredicate } from '../utils/orbchartsUtils'
|
3
|
+
|
4
|
+
export const computedDataFn: ComputedDataFn<'series'> = (context) => {
|
5
|
+
const { data = [], dataFormatter, chartParams } = context
|
6
|
+
if (!data.length) {
|
7
|
+
return []
|
8
|
+
}
|
9
|
+
|
10
|
+
let computedDataSeries: ComputedDatumSeries[][] = []
|
11
|
+
|
12
|
+
try {
|
13
|
+
|
14
|
+
const createComputedDatumSeries = (seriesData: number | DataSeriesDatum, seriesIndex: number, itemIndex: number, currentIndex: number): ComputedDatumSeries => {
|
15
|
+
const defaultId = createDefaultDatumId(dataFormatter.type, seriesIndex, itemIndex)
|
16
|
+
const seriesLabel = dataFormatter.seriesLabels[seriesIndex] || createDefaultSeriesLabel('series', seriesIndex)
|
17
|
+
const color = seriesColorPredicate(seriesIndex, chartParams)
|
18
|
+
if (typeof seriesData === 'number') {
|
19
|
+
return {
|
20
|
+
id: defaultId,
|
21
|
+
index: currentIndex,
|
22
|
+
seq: 0, // 先給預設值
|
23
|
+
label: defaultId,
|
24
|
+
description: '',
|
25
|
+
data: {},
|
26
|
+
value: seriesData,
|
27
|
+
seriesIndex: seriesIndex,
|
28
|
+
seriesLabel,
|
29
|
+
color,
|
30
|
+
visible: true // 先給預設值
|
31
|
+
}
|
32
|
+
} else {
|
33
|
+
return {
|
34
|
+
id: seriesData.id ? seriesData.id : defaultId,
|
35
|
+
index: currentIndex,
|
36
|
+
seq: 0, // 先給預設值
|
37
|
+
label: seriesData.label ? seriesData.label : defaultId,
|
38
|
+
description: seriesData.description,
|
39
|
+
data: seriesData.data ?? {},
|
40
|
+
value: seriesData.value,
|
41
|
+
seriesIndex: seriesIndex,
|
42
|
+
seriesLabel,
|
43
|
+
color,
|
44
|
+
visible: true // 先給預設值
|
45
|
+
}
|
46
|
+
}
|
47
|
+
}
|
48
|
+
|
49
|
+
computedDataSeries = data
|
50
|
+
.map((seriesData, seriesIndex) => {
|
51
|
+
if (Array.isArray(seriesData)) {
|
52
|
+
return seriesData.map((item, itemIndex) =>
|
53
|
+
createComputedDatumSeries(item, seriesIndex, itemIndex, computedDataSeries.length + itemIndex)
|
54
|
+
)
|
55
|
+
} else {
|
56
|
+
return createComputedDatumSeries(seriesData, seriesIndex, 0, computedDataSeries.length)
|
57
|
+
}
|
58
|
+
})
|
59
|
+
// 攤為一維陣列
|
60
|
+
.flat()
|
61
|
+
// 排序後給 seq
|
62
|
+
.sort(dataFormatter.sort ?? undefined)
|
63
|
+
.map((datum, index) => {
|
64
|
+
datum.seq = index
|
65
|
+
return datum
|
66
|
+
})
|
67
|
+
.map(datum => {
|
68
|
+
datum.visible = dataFormatter.visibleFilter(datum, context)
|
69
|
+
return datum
|
70
|
+
})
|
71
|
+
// 恢復原排序
|
72
|
+
.sort((a, b) => a.index - b.index)
|
73
|
+
// 依seriesIndex分組(二維陣列)
|
74
|
+
.reduce((acc, datum) => {
|
75
|
+
if (!acc[datum.seriesIndex]) {
|
76
|
+
acc[datum.seriesIndex] = []
|
77
|
+
}
|
78
|
+
acc[datum.seriesIndex].push(datum)
|
79
|
+
return acc
|
80
|
+
}, [])
|
81
|
+
|
82
|
+
} catch (e) {
|
83
|
+
// console.error(e)
|
84
|
+
throw Error(e)
|
85
|
+
}
|
86
|
+
|
87
|
+
return computedDataSeries
|
88
|
+
}
|
@@ -1,100 +1,100 @@
|
|
1
|
-
import { map, shareReplay } from 'rxjs'
|
2
|
-
import type { ContextObserverCallback } from '../../lib/core-types'
|
3
|
-
import {
|
4
|
-
seriesDataMapObservable,
|
5
|
-
groupDataMapObservable } from '../utils/observables'
|
6
|
-
import { highlightObservable, textSizePxObservable } from '../utils/observables'
|
7
|
-
|
8
|
-
import {
|
9
|
-
separateSeriesObservable,
|
10
|
-
seriesVisibleComputedDataObservable,
|
11
|
-
seriesComputedLayoutDataObservable,
|
12
|
-
seriesLabelsObservable,
|
13
|
-
seriesContainerPositionObservable,
|
14
|
-
seriesContainerPositionMapObservable
|
15
|
-
} from '../utils/seriesObservables'
|
16
|
-
|
17
|
-
export const contextObserverCallback: ContextObserverCallback<'series'> = ({ subject, observer }) => {
|
18
|
-
|
19
|
-
const textSizePx$ = textSizePxObservable(observer.fullChartParams$).pipe(
|
20
|
-
shareReplay(1)
|
21
|
-
)
|
22
|
-
|
23
|
-
const separateSeries$ = separateSeriesObservable({
|
24
|
-
fullDataFormatter$: observer.fullDataFormatter$
|
25
|
-
})
|
26
|
-
|
27
|
-
const visibleComputedData$ = seriesVisibleComputedDataObservable({
|
28
|
-
computedData$: observer.computedData$,
|
29
|
-
})
|
30
|
-
|
31
|
-
const computedLayoutData$ = seriesComputedLayoutDataObservable({
|
32
|
-
computedData$: observer.computedData$,
|
33
|
-
fullDataFormatter$: observer.fullDataFormatter$
|
34
|
-
}).pipe(
|
35
|
-
shareReplay(1)
|
36
|
-
)
|
37
|
-
|
38
|
-
const visibleComputedLayoutData$ = seriesVisibleComputedDataObservable({
|
39
|
-
computedData$: computedLayoutData$,
|
40
|
-
})
|
41
|
-
|
42
|
-
const datumList$ = observer.computedData$.pipe(
|
43
|
-
map(d => d.flat())
|
44
|
-
).pipe(
|
45
|
-
shareReplay(1)
|
46
|
-
)
|
47
|
-
|
48
|
-
const seriesHighlight$ = highlightObservable({
|
49
|
-
datumList$,
|
50
|
-
fullChartParams$: observer.fullChartParams$,
|
51
|
-
event$: subject.event$
|
52
|
-
}).pipe(
|
53
|
-
shareReplay(1)
|
54
|
-
)
|
55
|
-
|
56
|
-
const seriesLabels$ = seriesLabelsObservable({
|
57
|
-
computedData$: observer.computedData$,
|
58
|
-
})
|
59
|
-
|
60
|
-
|
61
|
-
const SeriesDataMap$ = seriesDataMapObservable({
|
62
|
-
datumList$
|
63
|
-
}).pipe(
|
64
|
-
shareReplay(1)
|
65
|
-
)
|
66
|
-
|
67
|
-
const seriesContainerPosition$ = seriesContainerPositionObservable({
|
68
|
-
computedData$: observer.computedData$,
|
69
|
-
fullDataFormatter$: observer.fullDataFormatter$,
|
70
|
-
layout$: observer.layout$,
|
71
|
-
}).pipe(
|
72
|
-
shareReplay(1)
|
73
|
-
)
|
74
|
-
|
75
|
-
const SeriesContainerPositionMap$ = seriesContainerPositionMapObservable({
|
76
|
-
seriesContainerPosition$: seriesContainerPosition$,
|
77
|
-
seriesLabels$: seriesLabels$,
|
78
|
-
separateSeries$: separateSeries$,
|
79
|
-
}).pipe(
|
80
|
-
shareReplay(1)
|
81
|
-
)
|
82
|
-
|
83
|
-
return {
|
84
|
-
fullParams$: observer.fullParams$,
|
85
|
-
fullChartParams$: observer.fullChartParams$,
|
86
|
-
fullDataFormatter$: observer.fullDataFormatter$,
|
87
|
-
computedData$: observer.computedData$,
|
88
|
-
layout$: observer.layout$,
|
89
|
-
textSizePx$,
|
90
|
-
visibleComputedData$,
|
91
|
-
visibleComputedLayoutData$,
|
92
|
-
separateSeries$,
|
93
|
-
computedLayoutData$,
|
94
|
-
seriesHighlight$,
|
95
|
-
seriesLabels$,
|
96
|
-
SeriesDataMap$,
|
97
|
-
seriesContainerPosition$,
|
98
|
-
SeriesContainerPositionMap$,
|
99
|
-
}
|
100
|
-
}
|
1
|
+
import { map, shareReplay } from 'rxjs'
|
2
|
+
import type { ContextObserverCallback } from '../../lib/core-types'
|
3
|
+
import {
|
4
|
+
seriesDataMapObservable,
|
5
|
+
groupDataMapObservable } from '../utils/observables'
|
6
|
+
import { highlightObservable, textSizePxObservable } from '../utils/observables'
|
7
|
+
|
8
|
+
import {
|
9
|
+
separateSeriesObservable,
|
10
|
+
seriesVisibleComputedDataObservable,
|
11
|
+
seriesComputedLayoutDataObservable,
|
12
|
+
seriesLabelsObservable,
|
13
|
+
seriesContainerPositionObservable,
|
14
|
+
seriesContainerPositionMapObservable
|
15
|
+
} from '../utils/seriesObservables'
|
16
|
+
|
17
|
+
export const contextObserverCallback: ContextObserverCallback<'series'> = ({ subject, observer }) => {
|
18
|
+
|
19
|
+
const textSizePx$ = textSizePxObservable(observer.fullChartParams$).pipe(
|
20
|
+
shareReplay(1)
|
21
|
+
)
|
22
|
+
|
23
|
+
const separateSeries$ = separateSeriesObservable({
|
24
|
+
fullDataFormatter$: observer.fullDataFormatter$
|
25
|
+
})
|
26
|
+
|
27
|
+
const visibleComputedData$ = seriesVisibleComputedDataObservable({
|
28
|
+
computedData$: observer.computedData$,
|
29
|
+
})
|
30
|
+
|
31
|
+
const computedLayoutData$ = seriesComputedLayoutDataObservable({
|
32
|
+
computedData$: observer.computedData$,
|
33
|
+
fullDataFormatter$: observer.fullDataFormatter$
|
34
|
+
}).pipe(
|
35
|
+
shareReplay(1)
|
36
|
+
)
|
37
|
+
|
38
|
+
const visibleComputedLayoutData$ = seriesVisibleComputedDataObservable({
|
39
|
+
computedData$: computedLayoutData$,
|
40
|
+
})
|
41
|
+
|
42
|
+
const datumList$ = observer.computedData$.pipe(
|
43
|
+
map(d => d.flat())
|
44
|
+
).pipe(
|
45
|
+
shareReplay(1)
|
46
|
+
)
|
47
|
+
|
48
|
+
const seriesHighlight$ = highlightObservable({
|
49
|
+
datumList$,
|
50
|
+
fullChartParams$: observer.fullChartParams$,
|
51
|
+
event$: subject.event$
|
52
|
+
}).pipe(
|
53
|
+
shareReplay(1)
|
54
|
+
)
|
55
|
+
|
56
|
+
const seriesLabels$ = seriesLabelsObservable({
|
57
|
+
computedData$: observer.computedData$,
|
58
|
+
})
|
59
|
+
|
60
|
+
|
61
|
+
const SeriesDataMap$ = seriesDataMapObservable({
|
62
|
+
datumList$
|
63
|
+
}).pipe(
|
64
|
+
shareReplay(1)
|
65
|
+
)
|
66
|
+
|
67
|
+
const seriesContainerPosition$ = seriesContainerPositionObservable({
|
68
|
+
computedData$: observer.computedData$,
|
69
|
+
fullDataFormatter$: observer.fullDataFormatter$,
|
70
|
+
layout$: observer.layout$,
|
71
|
+
}).pipe(
|
72
|
+
shareReplay(1)
|
73
|
+
)
|
74
|
+
|
75
|
+
const SeriesContainerPositionMap$ = seriesContainerPositionMapObservable({
|
76
|
+
seriesContainerPosition$: seriesContainerPosition$,
|
77
|
+
seriesLabels$: seriesLabels$,
|
78
|
+
separateSeries$: separateSeries$,
|
79
|
+
}).pipe(
|
80
|
+
shareReplay(1)
|
81
|
+
)
|
82
|
+
|
83
|
+
return {
|
84
|
+
fullParams$: observer.fullParams$,
|
85
|
+
fullChartParams$: observer.fullChartParams$,
|
86
|
+
fullDataFormatter$: observer.fullDataFormatter$,
|
87
|
+
computedData$: observer.computedData$,
|
88
|
+
layout$: observer.layout$,
|
89
|
+
textSizePx$,
|
90
|
+
visibleComputedData$,
|
91
|
+
visibleComputedLayoutData$,
|
92
|
+
separateSeries$,
|
93
|
+
computedLayoutData$,
|
94
|
+
seriesHighlight$,
|
95
|
+
seriesLabels$,
|
96
|
+
SeriesDataMap$,
|
97
|
+
seriesContainerPosition$,
|
98
|
+
SeriesContainerPositionMap$,
|
99
|
+
}
|
100
|
+
}
|
@@ -1,42 +1,42 @@
|
|
1
|
-
import type { DataFormatterValidator, DataFormatterTypeMap } from '../../lib/core-types'
|
2
|
-
import { validateColumns } from '../utils/validator'
|
3
|
-
|
4
|
-
export const dataFormatterValidator: DataFormatterValidator<'series'> = (dataFormatter: DataFormatterTypeMap<'series'>) => {
|
5
|
-
const result = validateColumns(dataFormatter, {
|
6
|
-
visibleFilter: {
|
7
|
-
toBeTypes: ['Function']
|
8
|
-
},
|
9
|
-
sort: {
|
10
|
-
toBeTypes: ['Function', 'null']
|
11
|
-
},
|
12
|
-
seriesLabels: {
|
13
|
-
toBeTypes: ['string[]']
|
14
|
-
},
|
15
|
-
container: {
|
16
|
-
toBeTypes: ['object']
|
17
|
-
},
|
18
|
-
separateSeries: {
|
19
|
-
toBeTypes: ['boolean']
|
20
|
-
},
|
21
|
-
sumSeries: {
|
22
|
-
toBeTypes: ['boolean']
|
23
|
-
}
|
24
|
-
})
|
25
|
-
if (dataFormatter.container) {
|
26
|
-
const containerResult = validateColumns(dataFormatter.container, {
|
27
|
-
gap: {
|
28
|
-
toBeTypes: ['number']
|
29
|
-
},
|
30
|
-
rowAmount: {
|
31
|
-
toBeTypes: ['number']
|
32
|
-
},
|
33
|
-
columnAmount: {
|
34
|
-
toBeTypes: ['number']
|
35
|
-
}
|
36
|
-
})
|
37
|
-
if (containerResult.status === 'error') {
|
38
|
-
return containerResult
|
39
|
-
}
|
40
|
-
}
|
41
|
-
return result
|
1
|
+
import type { DataFormatterValidator, DataFormatterTypeMap } from '../../lib/core-types'
|
2
|
+
import { validateColumns } from '../utils/validator'
|
3
|
+
|
4
|
+
export const dataFormatterValidator: DataFormatterValidator<'series'> = (dataFormatter: DataFormatterTypeMap<'series'>) => {
|
5
|
+
const result = validateColumns(dataFormatter, {
|
6
|
+
visibleFilter: {
|
7
|
+
toBeTypes: ['Function']
|
8
|
+
},
|
9
|
+
sort: {
|
10
|
+
toBeTypes: ['Function', 'null']
|
11
|
+
},
|
12
|
+
seriesLabels: {
|
13
|
+
toBeTypes: ['string[]']
|
14
|
+
},
|
15
|
+
container: {
|
16
|
+
toBeTypes: ['object']
|
17
|
+
},
|
18
|
+
separateSeries: {
|
19
|
+
toBeTypes: ['boolean']
|
20
|
+
},
|
21
|
+
sumSeries: {
|
22
|
+
toBeTypes: ['boolean']
|
23
|
+
}
|
24
|
+
})
|
25
|
+
if (dataFormatter.container) {
|
26
|
+
const containerResult = validateColumns(dataFormatter.container, {
|
27
|
+
gap: {
|
28
|
+
toBeTypes: ['number']
|
29
|
+
},
|
30
|
+
rowAmount: {
|
31
|
+
toBeTypes: ['number']
|
32
|
+
},
|
33
|
+
columnAmount: {
|
34
|
+
toBeTypes: ['number']
|
35
|
+
}
|
36
|
+
})
|
37
|
+
if (containerResult.status === 'error') {
|
38
|
+
return containerResult
|
39
|
+
}
|
40
|
+
}
|
41
|
+
return result
|
42
42
|
}
|
@@ -1,13 +1,13 @@
|
|
1
|
-
import type { DataValidator, DataTypeMap } from '../../lib/core-types'
|
2
|
-
import { validateColumns } from '../utils/validator'
|
3
|
-
|
4
|
-
export const dataValidator: DataValidator<'series'> = (data: DataTypeMap<'series'>) => {
|
5
|
-
const result = validateColumns({ data }, {
|
6
|
-
data: {
|
7
|
-
toBe: '(DataSeriesDatum | DataSeriesValue)[][] | (DataSeriesDatum | DataSeriesValue)[]',
|
8
|
-
// 畢免資料量過大檢查不完,不深度檢查
|
9
|
-
test: (value) => Array.isArray(value)
|
10
|
-
}
|
11
|
-
})
|
12
|
-
return result
|
1
|
+
import type { DataValidator, DataTypeMap } from '../../lib/core-types'
|
2
|
+
import { validateColumns } from '../utils/validator'
|
3
|
+
|
4
|
+
export const dataValidator: DataValidator<'series'> = (data: DataTypeMap<'series'>) => {
|
5
|
+
const result = validateColumns({ data }, {
|
6
|
+
data: {
|
7
|
+
toBe: '(DataSeriesDatum | DataSeriesValue)[][] | (DataSeriesDatum | DataSeriesValue)[]',
|
8
|
+
// 畢免資料量過大檢查不完,不深度檢查
|
9
|
+
test: (value) => Array.isArray(value)
|
10
|
+
}
|
11
|
+
})
|
12
|
+
return result
|
13
13
|
}
|