@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.
Files changed (76) hide show
  1. package/LICENSE +200 -200
  2. package/dist/orbcharts-core.es.js +2734 -2353
  3. package/dist/orbcharts-core.umd.js +4 -4
  4. package/dist/src/defaults.d.ts +2 -1
  5. package/dist/src/utils/gridObservables.d.ts +8 -4
  6. package/dist/src/utils/index.d.ts +0 -3
  7. package/dist/src/utils/multiGridObservables.d.ts +3 -2
  8. package/dist/src/utils/multiValueObservables.d.ts +76 -29
  9. package/dist/src/utils/observables.d.ts +8 -1
  10. package/dist/src/utils/orbchartsUtils.d.ts +9 -9
  11. package/dist/src/utils/seriesObservables.d.ts +1 -1
  12. package/lib/core-types.ts +7 -7
  13. package/package.json +42 -42
  14. package/src/AbstractChart.ts +57 -57
  15. package/src/GridChart.ts +24 -24
  16. package/src/MultiGridChart.ts +24 -24
  17. package/src/MultiValueChart.ts +24 -24
  18. package/src/RelationshipChart.ts +24 -24
  19. package/src/SeriesChart.ts +24 -24
  20. package/src/TreeChart.ts +24 -24
  21. package/src/base/createBaseChart.ts +506 -505
  22. package/src/base/createBasePlugin.ts +154 -153
  23. package/src/base/validators/chartOptionsValidator.ts +23 -23
  24. package/src/base/validators/chartParamsValidator.ts +133 -133
  25. package/src/base/validators/elementValidator.ts +13 -13
  26. package/src/base/validators/pluginsValidator.ts +14 -14
  27. package/src/defaults.ts +282 -238
  28. package/src/defineGridPlugin.ts +3 -3
  29. package/src/defineMultiGridPlugin.ts +3 -3
  30. package/src/defineMultiValuePlugin.ts +3 -3
  31. package/src/defineNoneDataPlugin.ts +4 -4
  32. package/src/defineRelationshipPlugin.ts +3 -3
  33. package/src/defineSeriesPlugin.ts +3 -3
  34. package/src/defineTreePlugin.ts +3 -3
  35. package/src/grid/computedDataFn.ts +129 -129
  36. package/src/grid/contextObserverCallback.ts +198 -176
  37. package/src/grid/dataFormatterValidator.ts +120 -101
  38. package/src/grid/dataValidator.ts +12 -12
  39. package/src/index.ts +20 -20
  40. package/src/multiGrid/computedDataFn.ts +123 -123
  41. package/src/multiGrid/contextObserverCallback.ts +72 -41
  42. package/src/multiGrid/dataFormatterValidator.ts +115 -115
  43. package/src/multiGrid/dataValidator.ts +12 -12
  44. package/src/multiValue/computedDataFn.ts +113 -110
  45. package/src/multiValue/contextObserverCallback.ts +276 -160
  46. package/src/multiValue/dataFormatterValidator.ts +89 -9
  47. package/src/multiValue/dataValidator.ts +12 -9
  48. package/src/relationship/computedDataFn.ts +159 -144
  49. package/src/relationship/contextObserverCallback.ts +80 -80
  50. package/src/relationship/dataFormatterValidator.ts +13 -9
  51. package/src/relationship/dataValidator.ts +13 -9
  52. package/src/series/computedDataFn.ts +88 -88
  53. package/src/series/contextObserverCallback.ts +107 -100
  54. package/src/series/dataFormatterValidator.ts +41 -41
  55. package/src/series/dataValidator.ts +12 -12
  56. package/src/tree/computedDataFn.ts +129 -129
  57. package/src/tree/contextObserverCallback.ts +58 -58
  58. package/src/tree/dataFormatterValidator.ts +13 -13
  59. package/src/tree/dataValidator.ts +13 -13
  60. package/src/utils/commonUtils.ts +55 -55
  61. package/src/utils/d3Scale.ts +198 -198
  62. package/src/utils/errorMessage.ts +42 -42
  63. package/src/utils/gridObservables.ts +705 -683
  64. package/src/utils/index.ts +10 -10
  65. package/src/utils/multiGridObservables.ts +401 -392
  66. package/src/utils/multiValueObservables.ts +1044 -662
  67. package/src/utils/observables.ts +281 -219
  68. package/src/utils/orbchartsUtils.ts +377 -377
  69. package/src/utils/relationshipObservables.ts +84 -84
  70. package/src/utils/seriesObservables.ts +175 -175
  71. package/src/utils/treeObservables.ts +105 -105
  72. package/src/utils/validator.ts +126 -126
  73. package/tsconfig.base.json +13 -13
  74. package/tsconfig.json +2 -2
  75. package/vite-env.d.ts +6 -6
  76. package/vite.config.js +22 -22
@@ -1,160 +1,276 @@
1
- import { map, shareReplay, distinctUntilChanged } from 'rxjs'
2
- import type { ContextObserverCallback, ContextObserverTypeMap } from '../../lib/core-types'
3
- import {
4
- highlightObservable,
5
- categoryDataMapObservable,
6
- textSizePxObservable
7
- } from '../utils/observables'
8
- import {
9
- multiValueComputedLayoutDataObservable,
10
- // multiValueAxesTransformObservable,
11
- // multiValueAxesReverseTransformObservable,
12
- multiValueGraphicTransformObservable,
13
- multiValueGraphicReverseScaleObservable,
14
- multiValueCategoryLabelsObservable,
15
- multiValueVisibleComputedDataObservable,
16
- multiValueVisibleComputedLayoutDataObservable,
17
- multiValueContainerPositionObservable,
18
- minMaxXYObservable,
19
- filteredMinMaxXYDataObservable
20
- } from '../utils/multiValueObservables'
21
-
22
- export const contextObserverCallback: ContextObserverCallback<'multiValue'> = ({ subject, observer }) => {
23
-
24
- const textSizePx$ = textSizePxObservable(observer.fullChartParams$).pipe(
25
- shareReplay(1)
26
- )
27
-
28
- const isCategorySeprate$ = observer.fullDataFormatter$.pipe(
29
- map(d => d.separateCategory),
30
- distinctUntilChanged(),
31
- shareReplay(1)
32
- )
33
-
34
- const multiValueContainerPosition$ = multiValueContainerPositionObservable({
35
- computedData$: observer.computedData$,
36
- fullDataFormatter$: observer.fullDataFormatter$,
37
- layout$: observer.layout$,
38
- })
39
-
40
- // const multiValueAxesSize$ = multiValueAxesSizeObservable({
41
- // fullDataFormatter$: observer.fullDataFormatter$,
42
- // layout$: observer.layout$
43
- // }).pipe(
44
- // shareReplay(1)
45
- // )
46
-
47
- const datumList$ = observer.computedData$.pipe(
48
- map(d => d.flat().flat())
49
- ).pipe(
50
- shareReplay(1)
51
- )
52
-
53
- const multiValueHighlight$ = highlightObservable({
54
- datumList$,
55
- fullChartParams$: observer.fullChartParams$,
56
- event$: subject.event$
57
- }).pipe(
58
- shareReplay(1)
59
- )
60
-
61
- const categoryLabels$ = multiValueCategoryLabelsObservable({
62
- computedData$: observer.computedData$,
63
- fullDataFormatter$: observer.fullDataFormatter$,
64
- })
65
-
66
- const CategoryDataMap$ = categoryDataMapObservable({
67
- datumList$: datumList$
68
- }).pipe(
69
- shareReplay(1)
70
- )
71
-
72
- const minMaxXY$ = minMaxXYObservable({
73
- computedData$: observer.computedData$
74
- }).pipe(
75
- shareReplay(1)
76
- )
77
-
78
-
79
- const computedLayoutData$ = multiValueComputedLayoutDataObservable({
80
- computedData$: observer.computedData$,
81
- minMaxXY$,
82
- fullDataFormatter$: observer.fullDataFormatter$,
83
- layout$: observer.layout$,
84
- }).pipe(
85
- shareReplay(1)
86
- )
87
-
88
- const visibleComputedData$ = multiValueVisibleComputedDataObservable({
89
- computedData$: observer.computedData$,
90
- }).pipe(
91
- shareReplay(1)
92
- )
93
-
94
- const visibleComputedLayoutData$ = multiValueVisibleComputedLayoutDataObservable({
95
- computedLayoutData$: computedLayoutData$,
96
- }).pipe(
97
- shareReplay(1)
98
- )
99
-
100
- const filteredMinMaxXYData$ = filteredMinMaxXYDataObservable({
101
- visibleComputedLayoutData$: visibleComputedLayoutData$,
102
- minMaxXY$,
103
- fullDataFormatter$: observer.fullDataFormatter$,
104
- }).pipe(
105
- shareReplay(1)
106
- )
107
-
108
- // const multiValueAxesTransform$ = multiValueAxesTransformObservable({
109
- // fullDataFormatter$: observer.fullDataFormatter$,
110
- // layout$: observer.layout$
111
- // }).pipe(
112
- // shareReplay(1)
113
- // )
114
-
115
- // const multiValueAxesReverseTransform$ = multiValueAxesReverseTransformObservable({
116
- // multiValueAxesTransform$
117
- // }).pipe(
118
- // shareReplay(1)
119
- // )
120
-
121
- const multiValueGraphicTransform$ = multiValueGraphicTransformObservable({
122
- minMaxXY$,
123
- filteredMinMaxXYData$,
124
- fullDataFormatter$: observer.fullDataFormatter$,
125
- layout$: observer.layout$
126
- }).pipe(
127
- shareReplay(1)
128
- )
129
-
130
- const multiValueGraphicReverseScale$ = multiValueGraphicReverseScaleObservable({
131
- multiValueContainerPosition$: multiValueContainerPosition$,
132
- // multiValueAxesTransform$: multiValueAxesTransform$,
133
- multiValueGraphicTransform$: multiValueGraphicTransform$,
134
- })
135
-
136
-
137
- return <ContextObserverTypeMap<'multiValue', any>>{
138
- fullParams$: observer.fullParams$,
139
- fullChartParams$: observer.fullChartParams$,
140
- fullDataFormatter$: observer.fullDataFormatter$,
141
- computedData$: observer.computedData$,
142
- layout$: observer.layout$,
143
- textSizePx$,
144
- isCategorySeprate$,
145
- multiValueContainerPosition$,
146
- // multiValueAxesSize$,
147
- multiValueHighlight$,
148
- categoryLabels$,
149
- CategoryDataMap$,
150
- minMaxXY$,
151
- computedLayoutData$,
152
- visibleComputedData$,
153
- visibleComputedLayoutData$,
154
- filteredMinMaxXYData$,
155
- // multiValueAxesTransform$,
156
- // multiValueAxesReverseTransform$,
157
- multiValueGraphicTransform$,
158
- multiValueGraphicReverseScale$,
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
- export const dataFormatterValidator: DataFormatterValidator<'multiValue'> = (dataFormatter: DataFormatterTypeMap<'multiValue'>) => {
4
-
5
- return {
6
- status: 'success',
7
- columnName: '',
8
- expectToBe: ''
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
- export const dataValidator: DataValidator<'multiValue'> = (data: DataTypeMap<'multiValue'>) => {
4
-
5
- return {
6
- status: 'success',
7
- columnName: '',
8
- expectToBe: ''
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
  }