@orbcharts/core 3.0.5 → 3.0.6
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 +2217 -2164
- package/dist/orbcharts-core.umd.js +5 -5
- package/lib/core-types.ts +7 -7
- package/package.json +46 -46
- 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 +524 -524
- package/src/base/createBasePlugin.ts +154 -154
- 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 +284 -284
- 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 +209 -201
- package/src/grid/dataFormatterValidator.ts +125 -125
- package/src/grid/dataValidator.ts +12 -12
- package/src/grid/gridObservables.ts +698 -694
- package/src/index.ts +20 -20
- package/src/multiGrid/computedDataFn.ts +123 -123
- package/src/multiGrid/contextObserverCallback.ts +109 -75
- package/src/multiGrid/dataFormatterValidator.ts +120 -120
- package/src/multiGrid/dataValidator.ts +12 -12
- package/src/multiGrid/multiGridObservables.ts +366 -357
- package/src/multiValue/computedDataFn.ts +113 -113
- package/src/multiValue/contextObserverCallback.ts +328 -328
- package/src/multiValue/dataFormatterValidator.ts +94 -94
- package/src/multiValue/dataValidator.ts +12 -12
- package/src/multiValue/multiValueObservables.ts +865 -865
- package/src/relationship/computedDataFn.ts +159 -159
- package/src/relationship/contextObserverCallback.ts +80 -80
- package/src/relationship/dataFormatterValidator.ts +13 -13
- package/src/relationship/dataValidator.ts +13 -13
- package/src/relationship/relationshipObservables.ts +84 -84
- package/src/series/computedDataFn.ts +88 -88
- package/src/series/contextObserverCallback.ts +132 -132
- package/src/series/dataFormatterValidator.ts +46 -46
- package/src/series/dataValidator.ts +12 -12
- package/src/series/seriesObservables.ts +209 -209
- 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/tree/treeObservables.ts +105 -105
- package/src/utils/commonUtils.ts +55 -55
- package/src/utils/d3Scale.ts +198 -198
- package/src/utils/errorMessage.ts +40 -40
- package/src/utils/index.ts +3 -3
- package/src/utils/observables.ts +308 -308
- package/src/utils/orbchartsUtils.ts +396 -396
- 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,126 +1,126 @@
|
|
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
|
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
126
|
}
|
@@ -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<'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
|
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
13
|
}
|