@orbcharts/core 3.0.7 → 4.0.0-alpha.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 +2826 -6582
- package/dist/orbcharts-core.umd.js +6 -6
- package/dist/src/OrbCharts.d.ts +18 -0
- package/dist/src/chart/createChart.d.ts +3 -0
- package/dist/src/chart/createGraphData.d.ts +3 -0
- package/dist/src/chart/createGridData.d.ts +3 -0
- package/dist/src/chart/createMultivariateData.d.ts +3 -0
- package/dist/src/chart/createSeriesData.d.ts +3 -0
- package/dist/src/chart/createTreeData.d.ts +3 -0
- package/dist/src/chart/defaults.d.ts +5 -0
- package/dist/src/defineCanvasLayer.d.ts +16 -0
- package/dist/src/defineCanvasPlugin.d.ts +22 -0
- package/dist/src/defineSVGLayer.d.ts +16 -0
- package/dist/src/defineSVGPlugin.d.ts +22 -0
- package/dist/src/index.d.ts +6 -14
- package/dist/src/layer/createLayer.d.ts +3 -0
- package/dist/src/plugin/createPlugin.d.ts +3 -0
- package/dist/src/test/createGraphData.test.d.ts +1 -0
- package/dist/src/test/createTreeData.test.d.ts +1 -0
- package/dist/src/test/simple-graph-test.d.ts +74 -0
- package/dist/src/test/simple-tree-test.d.ts +13 -0
- package/dist/src/types/Chart.d.ts +39 -0
- package/dist/src/types/ChartContext.d.ts +27 -0
- package/dist/src/types/Common.d.ts +3 -0
- package/dist/src/types/Encoding.d.ts +33 -0
- package/dist/src/types/Event.d.ts +12 -0
- package/dist/src/types/Layers.d.ts +55 -0
- package/dist/src/types/ModelData.d.ts +70 -0
- package/dist/src/types/Plugin.d.ts +39 -0
- package/dist/src/types/RawData.d.ts +18 -0
- package/dist/src/types/RenderData.d.ts +4 -0
- package/dist/src/types/Theme.d.ts +17 -0
- package/dist/src/types/Validator.d.ts +20 -0
- package/dist/src/types/index.d.ts +12 -0
- package/dist/src/utils/aggregateUtils.d.ts +37 -0
- package/dist/src/utils/colorUtils.d.ts +22 -0
- package/dist/src/utils/commonUtils.d.ts +3 -5
- package/dist/src/utils/dom-lifecycle.d.ts +37 -0
- package/dist/src/utils/dom.d.ts +6 -0
- package/dist/src/utils/index.d.ts +5 -1
- package/dist/src/utils/observables.d.ts +1 -25
- package/dist/src/utils/orbchartsUtils.d.ts +2 -53
- package/dist/src/utils/validator.d.ts +2 -2
- package/dist/test/aggregateTest.d.ts +1 -0
- package/package.json +24 -13
- package/src/OrbCharts.ts +35 -0
- package/src/chart/createChart.ts +997 -0
- package/src/chart/createGraphData.ts +391 -0
- package/src/chart/createGridData.ts +247 -0
- package/src/chart/createMultivariateData.ts +181 -0
- package/src/chart/createSeriesData.ts +297 -0
- package/src/chart/createTreeData.ts +344 -0
- package/src/chart/defaults.ts +120 -0
- package/src/defineCanvasLayer.ts +24 -0
- package/src/defineCanvasPlugin.ts +39 -0
- package/src/defineSVGLayer.ts +24 -0
- package/src/defineSVGPlugin.ts +39 -0
- package/src/index.ts +6 -18
- package/src/layer/createLayer.ts +138 -0
- package/src/plugin/createPlugin.ts +470 -0
- package/src/test/createGraphData.test.ts +103 -0
- package/src/test/createTreeData.test.ts +97 -0
- package/src/test/simple-graph-test.js +51 -0
- package/src/test/simple-tree-test.js +58 -0
- package/src/types/Chart.ts +62 -0
- package/src/types/ChartContext.ts +42 -0
- package/src/types/Common.ts +5 -0
- package/src/types/Encoding.ts +43 -0
- package/src/types/Event.ts +26 -0
- package/src/types/Layers.ts +93 -0
- package/src/types/ModelData.ts +95 -0
- package/src/types/Plugin.ts +98 -0
- package/src/types/RawData.ts +67 -0
- package/src/types/RenderData.ts +16 -0
- package/src/types/Theme.ts +21 -0
- package/src/types/Validator.ts +36 -0
- package/src/types/index.ts +12 -0
- package/src/utils/aggregateUtils.ts +99 -0
- package/src/utils/colorUtils.ts +63 -0
- package/src/utils/commonUtils.ts +12 -11
- package/src/utils/dom-lifecycle.ts +164 -0
- package/src/utils/dom.ts +55 -0
- package/src/utils/index.ts +6 -2
- package/src/utils/observables.ts +1 -292
- package/src/utils/orbchartsUtils.ts +6 -393
- package/src/utils/validator.ts +15 -14
- package/dist/lib/core-types.d.ts +0 -1
- package/dist/src/AbstractChart.d.ts +0 -19
- package/dist/src/GridChart.d.ts +0 -6
- package/dist/src/MultiGridChart.d.ts +0 -6
- package/dist/src/MultiValueChart.d.ts +0 -6
- package/dist/src/RelationshipChart.d.ts +0 -6
- package/dist/src/SeriesChart.d.ts +0 -6
- package/dist/src/TreeChart.d.ts +0 -6
- package/dist/src/base/createBaseChart.d.ts +0 -3
- package/dist/src/base/createBasePlugin.d.ts +0 -3
- package/dist/src/base/validators/chartOptionsValidator.d.ts +0 -3
- package/dist/src/base/validators/chartParamsValidator.d.ts +0 -3
- package/dist/src/base/validators/elementValidator.d.ts +0 -3
- package/dist/src/base/validators/pluginsValidator.d.ts +0 -3
- package/dist/src/defaults.d.ts +0 -25
- package/dist/src/defineGridPlugin.d.ts +0 -1
- package/dist/src/defineMultiGridPlugin.d.ts +0 -1
- package/dist/src/defineMultiValuePlugin.d.ts +0 -1
- package/dist/src/defineNoneDataPlugin.d.ts +0 -1
- package/dist/src/defineRelationshipPlugin.d.ts +0 -1
- package/dist/src/defineSeriesPlugin.d.ts +0 -1
- package/dist/src/defineTreePlugin.d.ts +0 -1
- package/dist/src/grid/computedDataFn.d.ts +0 -4
- package/dist/src/grid/contextObserverCallback.d.ts +0 -3
- package/dist/src/grid/dataFormatterValidator.d.ts +0 -3
- package/dist/src/grid/dataValidator.d.ts +0 -3
- package/dist/src/grid/gridObservables.d.ts +0 -64
- package/dist/src/multiGrid/computedDataFn.d.ts +0 -3
- package/dist/src/multiGrid/contextObserverCallback.d.ts +0 -3
- package/dist/src/multiGrid/dataFormatterValidator.d.ts +0 -3
- package/dist/src/multiGrid/dataValidator.d.ts +0 -3
- package/dist/src/multiGrid/multiGridObservables.d.ts +0 -16
- package/dist/src/multiValue/computedDataFn.d.ts +0 -3
- package/dist/src/multiValue/contextObserverCallback.d.ts +0 -3
- package/dist/src/multiValue/dataFormatterValidator.d.ts +0 -3
- package/dist/src/multiValue/dataValidator.d.ts +0 -3
- package/dist/src/multiValue/multiValueObservables.d.ts +0 -130
- package/dist/src/relationship/computedDataFn.d.ts +0 -3
- package/dist/src/relationship/contextObserverCallback.d.ts +0 -3
- package/dist/src/relationship/dataFormatterValidator.d.ts +0 -3
- package/dist/src/relationship/dataValidator.d.ts +0 -3
- package/dist/src/relationship/relationshipObservables.d.ts +0 -13
- package/dist/src/series/computedDataFn.d.ts +0 -3
- package/dist/src/series/contextObserverCallback.d.ts +0 -3
- package/dist/src/series/dataFormatterValidator.d.ts +0 -3
- package/dist/src/series/dataValidator.d.ts +0 -3
- package/dist/src/series/seriesObservables.d.ts +0 -37
- package/dist/src/tree/computedDataFn.d.ts +0 -3
- package/dist/src/tree/contextObserverCallback.d.ts +0 -3
- package/dist/src/tree/dataFormatterValidator.d.ts +0 -3
- package/dist/src/tree/dataValidator.d.ts +0 -3
- package/dist/src/tree/treeObservables.d.ts +0 -10
- package/dist/src/utils/d3Scale.d.ts +0 -28
- package/lib/core-types.ts +0 -7
- package/src/AbstractChart.ts +0 -57
- package/src/GridChart.ts +0 -25
- package/src/MultiGridChart.ts +0 -25
- package/src/MultiValueChart.ts +0 -25
- package/src/RelationshipChart.ts +0 -25
- package/src/SeriesChart.ts +0 -25
- package/src/TreeChart.ts +0 -25
- package/src/base/createBaseChart.ts +0 -524
- package/src/base/createBasePlugin.ts +0 -154
- package/src/base/validators/chartOptionsValidator.ts +0 -24
- package/src/base/validators/chartParamsValidator.ts +0 -134
- package/src/base/validators/elementValidator.ts +0 -14
- package/src/base/validators/pluginsValidator.ts +0 -15
- package/src/defaults.ts +0 -284
- package/src/defineGridPlugin.ts +0 -3
- package/src/defineMultiGridPlugin.ts +0 -3
- package/src/defineMultiValuePlugin.ts +0 -3
- package/src/defineNoneDataPlugin.ts +0 -4
- package/src/defineRelationshipPlugin.ts +0 -3
- package/src/defineSeriesPlugin.ts +0 -3
- package/src/defineTreePlugin.ts +0 -3
- package/src/grid/computedDataFn.ts +0 -129
- package/src/grid/contextObserverCallback.ts +0 -209
- package/src/grid/dataFormatterValidator.ts +0 -126
- package/src/grid/dataValidator.ts +0 -13
- package/src/grid/gridObservables.ts +0 -699
- package/src/multiGrid/computedDataFn.ts +0 -123
- package/src/multiGrid/contextObserverCallback.ts +0 -109
- package/src/multiGrid/dataFormatterValidator.ts +0 -121
- package/src/multiGrid/dataValidator.ts +0 -13
- package/src/multiGrid/multiGridObservables.ts +0 -367
- package/src/multiValue/computedDataFn.ts +0 -113
- package/src/multiValue/contextObserverCallback.ts +0 -328
- package/src/multiValue/dataFormatterValidator.ts +0 -95
- package/src/multiValue/dataValidator.ts +0 -13
- package/src/multiValue/multiValueObservables.ts +0 -865
- package/src/relationship/computedDataFn.ts +0 -159
- package/src/relationship/contextObserverCallback.ts +0 -80
- package/src/relationship/dataFormatterValidator.ts +0 -14
- package/src/relationship/dataValidator.ts +0 -14
- package/src/relationship/relationshipObservables.ts +0 -85
- package/src/series/computedDataFn.ts +0 -88
- package/src/series/contextObserverCallback.ts +0 -132
- package/src/series/dataFormatterValidator.ts +0 -47
- package/src/series/dataValidator.ts +0 -13
- package/src/series/seriesObservables.ts +0 -210
- package/src/tree/computedDataFn.ts +0 -129
- package/src/tree/contextObserverCallback.ts +0 -58
- package/src/tree/dataFormatterValidator.ts +0 -14
- package/src/tree/dataValidator.ts +0 -14
- package/src/tree/treeObservables.ts +0 -106
- package/src/utils/d3Scale.ts +0 -198
- package/tsconfig.base.json +0 -14
- package/tsconfig.json +0 -3
- package/vite-env.d.ts +0 -7
- package/vite.config.js +0 -23
|
@@ -1,209 +0,0 @@
|
|
|
1
|
-
import { map, shareReplay, distinctUntilChanged } from 'rxjs'
|
|
2
|
-
import type { ContextObserverCallback } from '../../lib/core-types'
|
|
3
|
-
import {
|
|
4
|
-
highlightObservable,
|
|
5
|
-
seriesDataMapObservable,
|
|
6
|
-
groupDataMapObservable,
|
|
7
|
-
textSizePxObservable,
|
|
8
|
-
containerSizeObservable } from '../utils/observables'
|
|
9
|
-
import {
|
|
10
|
-
gridComputedAxesDataObservable,
|
|
11
|
-
gridAxesSizeObservable,
|
|
12
|
-
gridAxesContainerSizeObservable,
|
|
13
|
-
gridSeriesLabelsObservable,
|
|
14
|
-
gridVisibleComputedDataObservable,
|
|
15
|
-
gridVisibleComputedAxesDataObservable,
|
|
16
|
-
// isSeriesSeprateObservable,
|
|
17
|
-
gridContainerPositionObservable,
|
|
18
|
-
computedStackedDataObservables,
|
|
19
|
-
groupScaleDomainValueObservable,
|
|
20
|
-
filteredMinMaxValueObservable,
|
|
21
|
-
gridAxesTransformObservable,
|
|
22
|
-
gridAxesReverseTransformObservable,
|
|
23
|
-
gridGraphicTransformObservable,
|
|
24
|
-
gridGraphicReverseScaleObservable,
|
|
25
|
-
} from './gridObservables'
|
|
26
|
-
|
|
27
|
-
export const contextObserverCallback: ContextObserverCallback<'grid'> = ({ subject, observer }) => {
|
|
28
|
-
|
|
29
|
-
const textSizePx$ = textSizePxObservable(observer.fullChartParams$).pipe(
|
|
30
|
-
shareReplay(1)
|
|
31
|
-
)
|
|
32
|
-
|
|
33
|
-
const isSeriesSeprate$ = observer.fullDataFormatter$.pipe(
|
|
34
|
-
map(d => d.separateSeries),
|
|
35
|
-
distinctUntilChanged(),
|
|
36
|
-
shareReplay(1)
|
|
37
|
-
)
|
|
38
|
-
|
|
39
|
-
const gridContainerPosition$ = gridContainerPositionObservable({
|
|
40
|
-
computedData$: observer.computedData$,
|
|
41
|
-
fullDataFormatter$: observer.fullDataFormatter$,
|
|
42
|
-
layout$: observer.layout$,
|
|
43
|
-
}).pipe(
|
|
44
|
-
shareReplay(1)
|
|
45
|
-
)
|
|
46
|
-
|
|
47
|
-
const containerSize$ = containerSizeObservable({
|
|
48
|
-
layout$: observer.layout$,
|
|
49
|
-
containerPosition$: gridContainerPosition$,
|
|
50
|
-
container$: observer.fullDataFormatter$.pipe(
|
|
51
|
-
map(d => d.container)
|
|
52
|
-
)
|
|
53
|
-
}).pipe(
|
|
54
|
-
shareReplay(1)
|
|
55
|
-
)
|
|
56
|
-
|
|
57
|
-
const gridAxesSize$ = gridAxesSizeObservable({
|
|
58
|
-
fullDataFormatter$: observer.fullDataFormatter$,
|
|
59
|
-
layout$: observer.layout$
|
|
60
|
-
}).pipe(
|
|
61
|
-
shareReplay(1)
|
|
62
|
-
)
|
|
63
|
-
|
|
64
|
-
const gridAxesContainerSize$ = gridAxesContainerSizeObservable({
|
|
65
|
-
fullDataFormatter$: observer.fullDataFormatter$,
|
|
66
|
-
containerSize$
|
|
67
|
-
}).pipe(
|
|
68
|
-
shareReplay(1)
|
|
69
|
-
)
|
|
70
|
-
|
|
71
|
-
const datumList$ = observer.computedData$.pipe(
|
|
72
|
-
map(d => d.flat())
|
|
73
|
-
).pipe(
|
|
74
|
-
shareReplay(1)
|
|
75
|
-
)
|
|
76
|
-
|
|
77
|
-
const gridHighlight$ = highlightObservable({
|
|
78
|
-
datumList$,
|
|
79
|
-
fullChartParams$: observer.fullChartParams$,
|
|
80
|
-
event$: subject.event$
|
|
81
|
-
}).pipe(
|
|
82
|
-
shareReplay(1)
|
|
83
|
-
)
|
|
84
|
-
|
|
85
|
-
const seriesLabels$ = gridSeriesLabelsObservable({
|
|
86
|
-
computedData$: observer.computedData$,
|
|
87
|
-
})
|
|
88
|
-
|
|
89
|
-
const SeriesDataMap$ = seriesDataMapObservable({
|
|
90
|
-
datumList$: datumList$
|
|
91
|
-
}).pipe(
|
|
92
|
-
shareReplay(1)
|
|
93
|
-
)
|
|
94
|
-
|
|
95
|
-
const GroupDataMap$ = groupDataMapObservable({
|
|
96
|
-
datumList$: datumList$
|
|
97
|
-
}).pipe(
|
|
98
|
-
shareReplay(1)
|
|
99
|
-
)
|
|
100
|
-
|
|
101
|
-
const computedAxesData$ = gridComputedAxesDataObservable({
|
|
102
|
-
computedData$: observer.computedData$,
|
|
103
|
-
fullDataFormatter$: observer.fullDataFormatter$,
|
|
104
|
-
layout$: observer.layout$,
|
|
105
|
-
}).pipe(
|
|
106
|
-
shareReplay(1)
|
|
107
|
-
)
|
|
108
|
-
|
|
109
|
-
const visibleComputedData$ = gridVisibleComputedDataObservable({
|
|
110
|
-
computedData$: observer.computedData$,
|
|
111
|
-
}).pipe(
|
|
112
|
-
shareReplay(1)
|
|
113
|
-
)
|
|
114
|
-
|
|
115
|
-
const visibleComputedAxesData$ = gridVisibleComputedAxesDataObservable({
|
|
116
|
-
computedAxesData$: computedAxesData$,
|
|
117
|
-
}).pipe(
|
|
118
|
-
shareReplay(1)
|
|
119
|
-
)
|
|
120
|
-
|
|
121
|
-
const computedStackedData$ = computedStackedDataObservables({
|
|
122
|
-
computedData$: observer.computedData$,
|
|
123
|
-
isSeriesSeprate$: isSeriesSeprate$
|
|
124
|
-
}).pipe(
|
|
125
|
-
shareReplay(1)
|
|
126
|
-
)
|
|
127
|
-
|
|
128
|
-
const groupScaleDomainValue$ = groupScaleDomainValueObservable({
|
|
129
|
-
computedData$: observer.computedData$,
|
|
130
|
-
fullDataFormatter$: observer.fullDataFormatter$,
|
|
131
|
-
}).pipe(
|
|
132
|
-
shareReplay(1)
|
|
133
|
-
)
|
|
134
|
-
|
|
135
|
-
const filteredMinMaxValue$ = filteredMinMaxValueObservable({
|
|
136
|
-
computedData$: observer.computedData$,
|
|
137
|
-
groupScaleDomainValue$: groupScaleDomainValue$,
|
|
138
|
-
}).pipe(
|
|
139
|
-
shareReplay(1)
|
|
140
|
-
)
|
|
141
|
-
|
|
142
|
-
const filteredStackedMinMaxValue$ = filteredMinMaxValueObservable({
|
|
143
|
-
computedData$: computedStackedData$,
|
|
144
|
-
groupScaleDomainValue$: groupScaleDomainValue$,
|
|
145
|
-
}).pipe(
|
|
146
|
-
shareReplay(1)
|
|
147
|
-
)
|
|
148
|
-
|
|
149
|
-
const gridAxesTransform$ = gridAxesTransformObservable({
|
|
150
|
-
fullDataFormatter$: observer.fullDataFormatter$,
|
|
151
|
-
layout$: observer.layout$
|
|
152
|
-
}).pipe(
|
|
153
|
-
shareReplay(1)
|
|
154
|
-
)
|
|
155
|
-
|
|
156
|
-
const gridAxesReverseTransform$ = gridAxesReverseTransformObservable({
|
|
157
|
-
gridAxesTransform$
|
|
158
|
-
}).pipe(
|
|
159
|
-
shareReplay(1)
|
|
160
|
-
)
|
|
161
|
-
|
|
162
|
-
const gridGraphicTransform$ = gridGraphicTransformObservable({
|
|
163
|
-
computedData$: observer.computedData$,
|
|
164
|
-
groupScaleDomainValue$: groupScaleDomainValue$,
|
|
165
|
-
filteredMinMaxValue$: filteredMinMaxValue$,
|
|
166
|
-
fullDataFormatter$: observer.fullDataFormatter$,
|
|
167
|
-
layout$: observer.layout$
|
|
168
|
-
}).pipe(
|
|
169
|
-
shareReplay(1)
|
|
170
|
-
)
|
|
171
|
-
|
|
172
|
-
const gridGraphicReverseScale$ = gridGraphicReverseScaleObservable({
|
|
173
|
-
gridContainerPosition$: gridContainerPosition$,
|
|
174
|
-
gridAxesTransform$: gridAxesTransform$,
|
|
175
|
-
gridGraphicTransform$: gridGraphicTransform$,
|
|
176
|
-
}).pipe(
|
|
177
|
-
shareReplay(1)
|
|
178
|
-
)
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
return {
|
|
182
|
-
fullParams$: observer.fullParams$,
|
|
183
|
-
fullChartParams$: observer.fullChartParams$,
|
|
184
|
-
fullDataFormatter$: observer.fullDataFormatter$,
|
|
185
|
-
computedData$: observer.computedData$,
|
|
186
|
-
layout$: observer.layout$,
|
|
187
|
-
textSizePx$,
|
|
188
|
-
isSeriesSeprate$,
|
|
189
|
-
gridContainerPosition$,
|
|
190
|
-
containerSize$,
|
|
191
|
-
gridAxesSize$,
|
|
192
|
-
gridAxesContainerSize$,
|
|
193
|
-
gridHighlight$,
|
|
194
|
-
seriesLabels$,
|
|
195
|
-
SeriesDataMap$,
|
|
196
|
-
GroupDataMap$,
|
|
197
|
-
computedAxesData$,
|
|
198
|
-
visibleComputedData$,
|
|
199
|
-
visibleComputedAxesData$,
|
|
200
|
-
computedStackedData$,
|
|
201
|
-
groupScaleDomainValue$,
|
|
202
|
-
filteredMinMaxValue$,
|
|
203
|
-
filteredStackedMinMaxValue$,
|
|
204
|
-
gridAxesTransform$,
|
|
205
|
-
gridAxesReverseTransform$,
|
|
206
|
-
gridGraphicTransform$,
|
|
207
|
-
gridGraphicReverseScale$,
|
|
208
|
-
}
|
|
209
|
-
}
|
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
import type { DataFormatterValidator, DataFormatterTypeMap } from '../../lib/core-types'
|
|
2
|
-
import { validateColumns } from '../utils/validator'
|
|
3
|
-
|
|
4
|
-
export const dataFormatterValidator: DataFormatterValidator<'grid'> = (dataFormatter: DataFormatterTypeMap<'grid'>) => {
|
|
5
|
-
const result = validateColumns(dataFormatter, {
|
|
6
|
-
visibleFilter: {
|
|
7
|
-
toBeTypes: ['Function']
|
|
8
|
-
},
|
|
9
|
-
// grid: {
|
|
10
|
-
// toBeTypes: ['object']
|
|
11
|
-
// },
|
|
12
|
-
container: {
|
|
13
|
-
toBeTypes: ['object']
|
|
14
|
-
},
|
|
15
|
-
seriesDirection: {
|
|
16
|
-
toBe: '"row" | "column"',
|
|
17
|
-
test: (value) => value === 'row' || value === 'column'
|
|
18
|
-
},
|
|
19
|
-
rowLabels: {
|
|
20
|
-
toBeTypes: ['string[]']
|
|
21
|
-
},
|
|
22
|
-
columnLabels: {
|
|
23
|
-
toBeTypes: ['string[]']
|
|
24
|
-
},
|
|
25
|
-
valueAxis: {
|
|
26
|
-
toBeTypes: ['object']
|
|
27
|
-
},
|
|
28
|
-
groupAxis: {
|
|
29
|
-
toBeTypes: ['object']
|
|
30
|
-
},
|
|
31
|
-
separateSeries: {
|
|
32
|
-
toBeTypes: ['boolean']
|
|
33
|
-
}
|
|
34
|
-
})
|
|
35
|
-
// if (dataFormatter.grid) {
|
|
36
|
-
// const visibleFilterResult = validateColumns(dataFormatter, {
|
|
37
|
-
// seriesDirection: {
|
|
38
|
-
// toBe: '"row" | "column"',
|
|
39
|
-
// test: (value) => value === 'row' || value === 'column'
|
|
40
|
-
// },
|
|
41
|
-
// rowLabels: {
|
|
42
|
-
// toBeTypes: ['string[]']
|
|
43
|
-
// },
|
|
44
|
-
// columnLabels: {
|
|
45
|
-
// toBeTypes: ['string[]']
|
|
46
|
-
// },
|
|
47
|
-
// valueAxis: {
|
|
48
|
-
// toBeTypes: ['object']
|
|
49
|
-
// },
|
|
50
|
-
// groupAxis: {
|
|
51
|
-
// toBeTypes: ['object']
|
|
52
|
-
// },
|
|
53
|
-
// separateSeries: {
|
|
54
|
-
// toBeTypes: ['boolean']
|
|
55
|
-
// }
|
|
56
|
-
// })
|
|
57
|
-
if (result.status === 'error') {
|
|
58
|
-
return result
|
|
59
|
-
}
|
|
60
|
-
if (dataFormatter.valueAxis) {
|
|
61
|
-
const valueAxisResult = validateColumns(dataFormatter.valueAxis, {
|
|
62
|
-
position: {
|
|
63
|
-
toBe: '"bottom" | "left" | "top" | "right"',
|
|
64
|
-
test: (value) => value === 'bottom' || value === 'left' || value === 'top' || value === 'right'
|
|
65
|
-
},
|
|
66
|
-
scaleDomain: {
|
|
67
|
-
toBe: '[number | "min" | "auto", number | "max" | "auto"]',
|
|
68
|
-
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')
|
|
69
|
-
},
|
|
70
|
-
scaleRange: {
|
|
71
|
-
toBe: '[number, number]',
|
|
72
|
-
test: (value) => Array.isArray(value) && value.length === 2 && typeof value[0] === 'number' && typeof value[1] === 'number'
|
|
73
|
-
},
|
|
74
|
-
label: {
|
|
75
|
-
toBeTypes: ['string']
|
|
76
|
-
}
|
|
77
|
-
})
|
|
78
|
-
if (valueAxisResult.status === 'error') {
|
|
79
|
-
return valueAxisResult
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
if (dataFormatter.groupAxis) {
|
|
83
|
-
const groupAxisResult = validateColumns(dataFormatter.groupAxis, {
|
|
84
|
-
position: {
|
|
85
|
-
toBe: '"bottom" | "left" | "top" | "right"',
|
|
86
|
-
test: (value) => value === 'bottom' || value === 'left' || value === 'top' || value === 'right'
|
|
87
|
-
},
|
|
88
|
-
scaleDomain: {
|
|
89
|
-
toBe: '[number, number | "max"]',
|
|
90
|
-
test: (value) => Array.isArray(value) && value.length === 2 && typeof value[0] === 'number' && (typeof value[1] === 'number' || value[1] === 'max')
|
|
91
|
-
},
|
|
92
|
-
scalePadding: {
|
|
93
|
-
toBeTypes: ['number']
|
|
94
|
-
},
|
|
95
|
-
label: {
|
|
96
|
-
toBeTypes: ['string']
|
|
97
|
-
}
|
|
98
|
-
})
|
|
99
|
-
if (groupAxisResult.status === 'error') {
|
|
100
|
-
return groupAxisResult
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
// }
|
|
104
|
-
if (dataFormatter.container) {
|
|
105
|
-
const containerResult = validateColumns(dataFormatter.container, {
|
|
106
|
-
columnAmount: {
|
|
107
|
-
toBeTypes: ['number']
|
|
108
|
-
},
|
|
109
|
-
rowAmount: {
|
|
110
|
-
toBeTypes: ['number']
|
|
111
|
-
},
|
|
112
|
-
columnGap: {
|
|
113
|
-
toBe: '"auto" | number',
|
|
114
|
-
test: (value: any) => value === 'auto' || typeof value === 'number'
|
|
115
|
-
},
|
|
116
|
-
rowGap: {
|
|
117
|
-
toBe: '"auto" | number',
|
|
118
|
-
test: (value: any) => value === 'auto' || typeof value === 'number'
|
|
119
|
-
},
|
|
120
|
-
})
|
|
121
|
-
if (containerResult.status === 'error') {
|
|
122
|
-
return containerResult
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
return result
|
|
126
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { DataValidator, DataTypeMap } from '../../lib/core-types'
|
|
2
|
-
import { validateColumns } from '../utils/validator'
|
|
3
|
-
|
|
4
|
-
export const dataValidator: DataValidator<'grid'> = (data: DataTypeMap<'grid'>) => {
|
|
5
|
-
const result = validateColumns({ data }, {
|
|
6
|
-
data: {
|
|
7
|
-
toBe: '(DataGridDatum | DataGridValue)[][]',
|
|
8
|
-
// 畢免資料量過大檢查不完,不深度檢查
|
|
9
|
-
test: (value) => Array.isArray(value)
|
|
10
|
-
}
|
|
11
|
-
})
|
|
12
|
-
return result
|
|
13
|
-
}
|