@orbcharts/core 3.0.0-beta.8 → 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/LICENSE +200 -200
- package/dist/orbcharts-core.es.js +2734 -2353
- 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/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 +506 -505
- package/src/base/createBasePlugin.ts +154 -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 +282 -238
- 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 +198 -176
- package/src/grid/dataFormatterValidator.ts +120 -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 +72 -41
- package/src/multiGrid/dataFormatterValidator.ts +115 -115
- package/src/multiGrid/dataValidator.ts +12 -12
- package/src/multiValue/computedDataFn.ts +113 -110
- package/src/multiValue/contextObserverCallback.ts +276 -160
- package/src/multiValue/dataFormatterValidator.ts +89 -9
- package/src/multiValue/dataValidator.ts +12 -9
- package/src/relationship/computedDataFn.ts +159 -144
- package/src/relationship/contextObserverCallback.ts +80 -80
- package/src/relationship/dataFormatterValidator.ts +13 -9
- package/src/relationship/dataValidator.ts +13 -9
- package/src/series/computedDataFn.ts +88 -88
- package/src/series/contextObserverCallback.ts +107 -100
- package/src/series/dataFormatterValidator.ts +41 -41
- package/src/series/dataValidator.ts +12 -12
- package/src/tree/computedDataFn.ts +129 -129
- package/src/tree/contextObserverCallback.ts +58 -58
- 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 -198
- package/src/utils/errorMessage.ts +42 -42
- package/src/utils/gridObservables.ts +705 -683
- package/src/utils/index.ts +10 -10
- package/src/utils/multiGridObservables.ts +401 -392
- package/src/utils/multiValueObservables.ts +1044 -662
- package/src/utils/observables.ts +281 -219
- package/src/utils/orbchartsUtils.ts +377 -377
- package/src/utils/relationshipObservables.ts +84 -84
- package/src/utils/seriesObservables.ts +175 -175
- package/src/utils/treeObservables.ts +105 -105
- package/src/utils/validator.ts +126 -126
- package/tsconfig.base.json +13 -13
- package/tsconfig.json +2 -2
- package/vite-env.d.ts +6 -6
- package/vite.config.js +22 -22
@@ -1,160 +1,276 @@
|
|
1
|
-
import { map, shareReplay, distinctUntilChanged } from 'rxjs'
|
2
|
-
import type {
|
3
|
-
import {
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
}).pipe(
|
58
|
-
shareReplay(1)
|
59
|
-
)
|
60
|
-
|
61
|
-
const
|
62
|
-
|
63
|
-
|
64
|
-
})
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
)
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
)
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
const
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
1
|
+
import { map, shareReplay, distinctUntilChanged } from 'rxjs'
|
2
|
+
import type { Observable } from 'rxjs'
|
3
|
+
import type { ContextObserverCallback, ContextObserverTypeMap } from '../../lib/core-types'
|
4
|
+
import {
|
5
|
+
highlightObservable,
|
6
|
+
categoryDataMapObservable,
|
7
|
+
textSizePxObservable,
|
8
|
+
containerSizeObservable
|
9
|
+
} from '../utils/observables'
|
10
|
+
import {
|
11
|
+
computedXYDataObservable,
|
12
|
+
// multiValueAxesTransformObservable,
|
13
|
+
// multiValueAxesReverseTransformObservable,
|
14
|
+
graphicTransformObservable,
|
15
|
+
graphicReverseScaleObservable,
|
16
|
+
categoryLabelsObservable,
|
17
|
+
visibleComputedDataObservable,
|
18
|
+
visibleComputedSumDataObservable,
|
19
|
+
visibleComputedRankingByIndexDataObservable,
|
20
|
+
visibleComputedRankingBySumDataObservable,
|
21
|
+
visibleComputedXYDataObservable,
|
22
|
+
containerPositionObservable,
|
23
|
+
// containerSizeObservable,
|
24
|
+
xyMinMaxObservable,
|
25
|
+
filteredXYMinMaxDataObservable,
|
26
|
+
// visibleComputedRankingDataObservable,
|
27
|
+
// rankingAmountLimitObservable,
|
28
|
+
// rankingScaleObservable
|
29
|
+
xScaleObservable,
|
30
|
+
xSumScaleObservable,
|
31
|
+
yScaleObservable
|
32
|
+
} from '../utils/multiValueObservables'
|
33
|
+
|
34
|
+
export const contextObserverCallback: ContextObserverCallback<'multiValue'> = ({ subject, observer }) => {
|
35
|
+
|
36
|
+
const textSizePx$ = textSizePxObservable(observer.fullChartParams$).pipe(
|
37
|
+
shareReplay(1)
|
38
|
+
)
|
39
|
+
|
40
|
+
const isCategorySeprate$ = observer.fullDataFormatter$.pipe(
|
41
|
+
map(d => d.separateCategory),
|
42
|
+
distinctUntilChanged(),
|
43
|
+
shareReplay(1)
|
44
|
+
)
|
45
|
+
|
46
|
+
const containerPosition$ = containerPositionObservable({
|
47
|
+
computedData$: observer.computedData$,
|
48
|
+
fullDataFormatter$: observer.fullDataFormatter$,
|
49
|
+
layout$: observer.layout$,
|
50
|
+
}).pipe(
|
51
|
+
shareReplay(1)
|
52
|
+
)
|
53
|
+
|
54
|
+
const containerSize$ = containerSizeObservable({
|
55
|
+
layout$: observer.layout$,
|
56
|
+
containerPosition$
|
57
|
+
}).pipe(
|
58
|
+
shareReplay(1)
|
59
|
+
)
|
60
|
+
|
61
|
+
// const multiValueAxesSize$ = multiValueAxesSizeObservable({
|
62
|
+
// fullDataFormatter$: observer.fullDataFormatter$,
|
63
|
+
// layout$: observer.layout$
|
64
|
+
// }).pipe(
|
65
|
+
// shareReplay(1)
|
66
|
+
// )
|
67
|
+
|
68
|
+
// [xValueIndex, yValueIndex]
|
69
|
+
const xyValueIndex$: Observable<[number, number]> = observer.fullDataFormatter$.pipe(
|
70
|
+
map(d => [d.xAxis.valueIndex, d.yAxis.valueIndex] as [number, number]),
|
71
|
+
distinctUntilChanged((a, b) => a[0] === b[0] && a[1] === b[1]),
|
72
|
+
shareReplay(1)
|
73
|
+
)
|
74
|
+
|
75
|
+
const datumList$ = observer.computedData$.pipe(
|
76
|
+
map(d => d.flat().flat())
|
77
|
+
).pipe(
|
78
|
+
shareReplay(1)
|
79
|
+
)
|
80
|
+
|
81
|
+
const highlight$ = highlightObservable({
|
82
|
+
datumList$,
|
83
|
+
fullChartParams$: observer.fullChartParams$,
|
84
|
+
event$: subject.event$
|
85
|
+
}).pipe(
|
86
|
+
shareReplay(1)
|
87
|
+
)
|
88
|
+
|
89
|
+
const categoryLabels$ = categoryLabelsObservable({
|
90
|
+
computedData$: observer.computedData$,
|
91
|
+
fullDataFormatter$: observer.fullDataFormatter$,
|
92
|
+
}).pipe(
|
93
|
+
shareReplay(1)
|
94
|
+
)
|
95
|
+
|
96
|
+
const CategoryDataMap$ = categoryDataMapObservable({
|
97
|
+
datumList$: datumList$
|
98
|
+
}).pipe(
|
99
|
+
shareReplay(1)
|
100
|
+
)
|
101
|
+
|
102
|
+
const xyMinMax$ = xyMinMaxObservable({
|
103
|
+
computedData$: observer.computedData$,
|
104
|
+
xyValueIndex$
|
105
|
+
}).pipe(
|
106
|
+
shareReplay(1)
|
107
|
+
)
|
108
|
+
|
109
|
+
const visibleComputedData$ = visibleComputedDataObservable({
|
110
|
+
computedData$: observer.computedData$,
|
111
|
+
}).pipe(
|
112
|
+
shareReplay(1)
|
113
|
+
)
|
114
|
+
|
115
|
+
const visibleComputedSumData$ = visibleComputedSumDataObservable({
|
116
|
+
visibleComputedData$
|
117
|
+
}).pipe(
|
118
|
+
shareReplay(1)
|
119
|
+
)
|
120
|
+
|
121
|
+
// const valueIndex$ = observer.fullDataFormatter$.pipe(
|
122
|
+
// map(d => d.yAxis.valueIndex),
|
123
|
+
// distinctUntilChanged()
|
124
|
+
// )
|
125
|
+
|
126
|
+
const visibleComputedRankingByIndexData$ = visibleComputedRankingByIndexDataObservable({
|
127
|
+
xyValueIndex$, // * 依據 valueIndex 來取得 visibleComputedData
|
128
|
+
isCategorySeprate$,
|
129
|
+
visibleComputedData$
|
130
|
+
}).pipe(
|
131
|
+
shareReplay(1)
|
132
|
+
)
|
133
|
+
|
134
|
+
const visibleComputedRankingBySumData$ = visibleComputedRankingBySumDataObservable({
|
135
|
+
isCategorySeprate$,
|
136
|
+
visibleComputedSumData$
|
137
|
+
}).pipe(
|
138
|
+
shareReplay(1)
|
139
|
+
)
|
140
|
+
|
141
|
+
const computedXYData$ = computedXYDataObservable({
|
142
|
+
computedData$: observer.computedData$,
|
143
|
+
xyMinMax$,
|
144
|
+
xyValueIndex$,
|
145
|
+
fullDataFormatter$: observer.fullDataFormatter$,
|
146
|
+
layout$: observer.layout$,
|
147
|
+
}).pipe(
|
148
|
+
shareReplay(1)
|
149
|
+
)
|
150
|
+
|
151
|
+
const visibleComputedXYData$ = visibleComputedXYDataObservable({
|
152
|
+
computedXYData$: computedXYData$,
|
153
|
+
}).pipe(
|
154
|
+
shareReplay(1)
|
155
|
+
)
|
156
|
+
|
157
|
+
const filteredXYMinMaxData$ = filteredXYMinMaxDataObservable({
|
158
|
+
visibleComputedXYData$: visibleComputedXYData$,
|
159
|
+
xyMinMax$,
|
160
|
+
xyValueIndex$,
|
161
|
+
fullDataFormatter$: observer.fullDataFormatter$,
|
162
|
+
}).pipe(
|
163
|
+
shareReplay(1)
|
164
|
+
)
|
165
|
+
|
166
|
+
// const visibleComputedRankingData$ = visibleComputedRankingDataObservable({
|
167
|
+
// visibleComputedData$
|
168
|
+
// }).pipe(
|
169
|
+
// shareReplay(1)
|
170
|
+
// )
|
171
|
+
|
172
|
+
// const rankingAmountLimit$ = rankingAmountLimitObservable({
|
173
|
+
// layout$: observer.layout$,
|
174
|
+
// textSizePx$
|
175
|
+
// }).pipe(
|
176
|
+
// shareReplay(1)
|
177
|
+
// )
|
178
|
+
|
179
|
+
// const rankingScale$ = rankingScaleObservable({
|
180
|
+
// layout$: observer.layout$,
|
181
|
+
// visibleComputedRankingData$,
|
182
|
+
// rankingAmountLimit$
|
183
|
+
// }).pipe(
|
184
|
+
// shareReplay(1)
|
185
|
+
// )
|
186
|
+
|
187
|
+
// const multiValueAxesTransform$ = multiValueAxesTransformObservable({
|
188
|
+
// fullDataFormatter$: observer.fullDataFormatter$,
|
189
|
+
// layout$: observer.layout$
|
190
|
+
// }).pipe(
|
191
|
+
// shareReplay(1)
|
192
|
+
// )
|
193
|
+
|
194
|
+
// const multiValueAxesReverseTransform$ = multiValueAxesReverseTransformObservable({
|
195
|
+
// multiValueAxesTransform$
|
196
|
+
// }).pipe(
|
197
|
+
// shareReplay(1)
|
198
|
+
// )
|
199
|
+
|
200
|
+
const graphicTransform$ = graphicTransformObservable({
|
201
|
+
xyMinMax$,
|
202
|
+
xyValueIndex$,
|
203
|
+
filteredXYMinMaxData$,
|
204
|
+
fullDataFormatter$: observer.fullDataFormatter$,
|
205
|
+
layout$: observer.layout$
|
206
|
+
}).pipe(
|
207
|
+
shareReplay(1)
|
208
|
+
)
|
209
|
+
|
210
|
+
const graphicReverseScale$ = graphicReverseScaleObservable({
|
211
|
+
containerPosition$: containerPosition$,
|
212
|
+
// multiValueAxesTransform$: multiValueAxesTransform$,
|
213
|
+
graphicTransform$: graphicTransform$,
|
214
|
+
}).pipe(
|
215
|
+
shareReplay(1)
|
216
|
+
)
|
217
|
+
|
218
|
+
const xScale$ = xScaleObservable({
|
219
|
+
visibleComputedSumData$,
|
220
|
+
fullDataFormatter$: observer.fullDataFormatter$,
|
221
|
+
filteredXYMinMaxData$,
|
222
|
+
containerSize$: containerSize$,
|
223
|
+
}).pipe(
|
224
|
+
shareReplay(1)
|
225
|
+
)
|
226
|
+
|
227
|
+
const xSumScale$ = xSumScaleObservable({
|
228
|
+
fullDataFormatter$: observer.fullDataFormatter$,
|
229
|
+
filteredXYMinMaxData$,
|
230
|
+
containerSize$: containerSize$,
|
231
|
+
}).pipe(
|
232
|
+
shareReplay(1)
|
233
|
+
)
|
234
|
+
|
235
|
+
const yScale$ = yScaleObservable({
|
236
|
+
fullDataFormatter$: observer.fullDataFormatter$,
|
237
|
+
filteredXYMinMaxData$,
|
238
|
+
containerSize$: containerSize$,
|
239
|
+
}).pipe(
|
240
|
+
shareReplay(1)
|
241
|
+
)
|
242
|
+
|
243
|
+
return <ContextObserverTypeMap<'multiValue', any>>{
|
244
|
+
fullParams$: observer.fullParams$,
|
245
|
+
fullChartParams$: observer.fullChartParams$,
|
246
|
+
fullDataFormatter$: observer.fullDataFormatter$,
|
247
|
+
computedData$: observer.computedData$,
|
248
|
+
layout$: observer.layout$,
|
249
|
+
textSizePx$,
|
250
|
+
isCategorySeprate$,
|
251
|
+
containerPosition$,
|
252
|
+
containerSize$,
|
253
|
+
// multiValueAxesSize$,
|
254
|
+
highlight$,
|
255
|
+
categoryLabels$,
|
256
|
+
CategoryDataMap$,
|
257
|
+
xyMinMax$,
|
258
|
+
xyValueIndex$,
|
259
|
+
// computedXYData$,
|
260
|
+
visibleComputedData$,
|
261
|
+
visibleComputedSumData$,
|
262
|
+
visibleComputedRankingByIndexData$,
|
263
|
+
visibleComputedRankingBySumData$,
|
264
|
+
visibleComputedXYData$,
|
265
|
+
filteredXYMinMaxData$,
|
266
|
+
// visibleComputedRankingData$,
|
267
|
+
// rankingScale$,
|
268
|
+
// multiValueAxesTransform$,
|
269
|
+
// multiValueAxesReverseTransform$,
|
270
|
+
graphicTransform$,
|
271
|
+
graphicReverseScale$,
|
272
|
+
xScale$,
|
273
|
+
xSumScale$,
|
274
|
+
yScale$
|
275
|
+
}
|
276
|
+
}
|
@@ -1,10 +1,90 @@
|
|
1
|
-
import type { DataFormatterValidator, DataFormatterTypeMap } from '../../lib/core-types'
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
1
|
+
import type { DataFormatterValidator, DataFormatterTypeMap } from '../../lib/core-types'
|
2
|
+
import { validateColumns } from '../utils/validator'
|
3
|
+
|
4
|
+
export const dataFormatterValidator: DataFormatterValidator<'multiValue'> = (dataFormatter: DataFormatterTypeMap<'multiValue'>) => {
|
5
|
+
const result = validateColumns(dataFormatter, {
|
6
|
+
visibleFilter: {
|
7
|
+
toBeTypes: ['Function']
|
8
|
+
},
|
9
|
+
container: {
|
10
|
+
toBeTypes: ['object']
|
11
|
+
},
|
12
|
+
categoryLabels: {
|
13
|
+
toBeTypes: ['string[]']
|
14
|
+
},
|
15
|
+
valueLabels: {
|
16
|
+
toBeTypes: ['string[]']
|
17
|
+
},
|
18
|
+
xAxis: {
|
19
|
+
toBeTypes: ['object']
|
20
|
+
},
|
21
|
+
yAxis: {
|
22
|
+
toBeTypes: ['object']
|
23
|
+
},
|
24
|
+
separateCategory: {
|
25
|
+
toBeTypes: ['boolean']
|
26
|
+
}
|
27
|
+
})
|
28
|
+
if (result.status === 'error') {
|
29
|
+
return result
|
30
|
+
}
|
31
|
+
if (dataFormatter.yAxis) {
|
32
|
+
const valueAxisResult = validateColumns(dataFormatter.yAxis, {
|
33
|
+
scaleDomain: {
|
34
|
+
toBe: '[number | "min" | "auto", number | "max" | "auto"]',
|
35
|
+
test: (value) => Array.isArray(value) && value.length === 2 && (typeof value[0] === 'number' || value[0] === 'min' || value[0] === 'auto') && (typeof value[1] === 'number' || value[1] === 'max' || value[1] === 'auto')
|
36
|
+
},
|
37
|
+
scaleRange: {
|
38
|
+
toBe: '[number, number]',
|
39
|
+
test: (value) => Array.isArray(value) && value.length === 2 && typeof value[0] === 'number' && typeof value[1] === 'number'
|
40
|
+
},
|
41
|
+
label: {
|
42
|
+
toBeTypes: ['string']
|
43
|
+
},
|
44
|
+
valueIndex: {
|
45
|
+
toBeTypes: ['number']
|
46
|
+
}
|
47
|
+
})
|
48
|
+
if (valueAxisResult.status === 'error') {
|
49
|
+
return valueAxisResult
|
50
|
+
}
|
51
|
+
}
|
52
|
+
if (dataFormatter.xAxis) {
|
53
|
+
const groupAxisResult = validateColumns(dataFormatter.xAxis, {
|
54
|
+
scaleDomain: {
|
55
|
+
toBe: '[number | "min" | "auto", number | "max" | "auto"]',
|
56
|
+
test: (value) => Array.isArray(value) && value.length === 2 && (typeof value[0] === 'number' || value[0] === 'min' || value[0] === 'auto') && (typeof value[1] === 'number' || value[1] === 'max' || value[1] === 'auto')
|
57
|
+
},
|
58
|
+
scaleRange: {
|
59
|
+
toBe: '[number, number]',
|
60
|
+
test: (value) => Array.isArray(value) && value.length === 2 && typeof value[0] === 'number' && typeof value[1] === 'number'
|
61
|
+
},
|
62
|
+
label: {
|
63
|
+
toBeTypes: ['string']
|
64
|
+
},
|
65
|
+
valueIndex: {
|
66
|
+
toBeTypes: ['number']
|
67
|
+
}
|
68
|
+
})
|
69
|
+
if (groupAxisResult.status === 'error') {
|
70
|
+
return groupAxisResult
|
71
|
+
}
|
72
|
+
}
|
73
|
+
if (dataFormatter.container) {
|
74
|
+
const containerResult = validateColumns(dataFormatter.container, {
|
75
|
+
gap: {
|
76
|
+
toBeTypes: ['number']
|
77
|
+
},
|
78
|
+
rowAmount: {
|
79
|
+
toBeTypes: ['number']
|
80
|
+
},
|
81
|
+
columnAmount: {
|
82
|
+
toBeTypes: ['number']
|
83
|
+
}
|
84
|
+
})
|
85
|
+
if (containerResult.status === 'error') {
|
86
|
+
return containerResult
|
87
|
+
}
|
88
|
+
}
|
89
|
+
return result
|
10
90
|
}
|
@@ -1,10 +1,13 @@
|
|
1
|
-
import type { DataValidator, DataTypeMap } from '../../lib/core-types'
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
1
|
+
import type { DataValidator, DataTypeMap } from '../../lib/core-types'
|
2
|
+
import { validateColumns } from '../utils/validator'
|
3
|
+
|
4
|
+
export const dataValidator: DataValidator<'multiValue'> = (data: DataTypeMap<'multiValue'>) => {
|
5
|
+
const result = validateColumns({ data }, {
|
6
|
+
data: {
|
7
|
+
toBe: '(DataMultiValueDatum | DataMultiValueValue[])[]',
|
8
|
+
// 畢免資料量過大檢查不完,不深度檢查
|
9
|
+
test: (value) => Array.isArray(value)
|
10
|
+
}
|
11
|
+
})
|
12
|
+
return result
|
10
13
|
}
|