@orbcharts/core 3.0.0-beta.5 → 3.0.0-beta.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 +1453 -1384
- package/dist/orbcharts-core.umd.js +4 -4
- package/dist/src/defaults.d.ts +22 -22
- package/dist/src/utils/orbchartsUtils.d.ts +7 -7
- package/dist/src/utils/relationshipObservables.d.ts +13 -0
- 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 -235
- 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 -176
- 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 -110
- package/src/multiValue/contextObserverCallback.ts +160 -160
- package/src/multiValue/dataFormatterValidator.ts +9 -9
- package/src/multiValue/dataValidator.ts +9 -9
- package/src/relationship/computedDataFn.ts +144 -125
- package/src/relationship/contextObserverCallback.ts +80 -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 -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 +683 -683
- package/src/utils/index.ts +9 -9
- package/src/utils/multiGridObservables.ts +392 -392
- package/src/utils/multiValueObservables.ts +661 -661
- package/src/utils/observables.ts +219 -219
- package/src/utils/orbchartsUtils.ts +377 -377
- package/src/utils/relationshipObservables.ts +85 -0
- 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,12 +1,80 @@
|
|
1
|
-
import
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
1
|
+
import { map, shareReplay } from 'rxjs'
|
2
|
+
import type { ContextObserverCallback } from '../../lib/core-types'
|
3
|
+
import { highlightObservable, categoryDataMapObservable, textSizePxObservable } from '../utils/observables'
|
4
|
+
import {
|
5
|
+
categoryLabelsObservable,
|
6
|
+
NodeMapObservable,
|
7
|
+
EdgeMapObservable,
|
8
|
+
relationshipVisibleComputedDataObservable
|
9
|
+
} from '../utils/relationshipObservables'
|
10
|
+
|
11
|
+
export const contextObserverCallback: ContextObserverCallback<'relationship'> = ({ subject, observer }) => {
|
12
|
+
|
13
|
+
const textSizePx$ = textSizePxObservable(observer.fullChartParams$).pipe(
|
14
|
+
shareReplay(1)
|
15
|
+
)
|
16
|
+
|
17
|
+
const relationshipHighlightNodes$ = highlightObservable({
|
18
|
+
datumList$: observer.computedData$.pipe(map(data => data.nodes)),
|
19
|
+
fullChartParams$: observer.fullChartParams$,
|
20
|
+
event$: subject.event$
|
21
|
+
}).pipe(
|
22
|
+
shareReplay(1)
|
23
|
+
)
|
24
|
+
|
25
|
+
const relationshipHighlightEdges$ = highlightObservable({
|
26
|
+
datumList$: observer.computedData$.pipe(map(data => data.edges)),
|
27
|
+
fullChartParams$: observer.fullChartParams$,
|
28
|
+
event$: subject.event$
|
29
|
+
}).pipe(
|
30
|
+
shareReplay(1)
|
31
|
+
)
|
32
|
+
|
33
|
+
const CategoryNodeMap$ = categoryDataMapObservable({
|
34
|
+
datumList$: observer.computedData$.pipe(map(data => data.nodes))
|
35
|
+
}).pipe(
|
36
|
+
shareReplay(1)
|
37
|
+
)
|
38
|
+
|
39
|
+
const CategoryEdgeMap$ = categoryDataMapObservable({
|
40
|
+
datumList$: observer.computedData$.pipe(map(data => data.edges))
|
41
|
+
}).pipe(
|
42
|
+
shareReplay(1)
|
43
|
+
)
|
44
|
+
|
45
|
+
const NodeMap$ = NodeMapObservable(observer.computedData$).pipe(
|
46
|
+
shareReplay(1)
|
47
|
+
)
|
48
|
+
|
49
|
+
const EdgeMap$ = EdgeMapObservable(observer.computedData$).pipe(
|
50
|
+
shareReplay(1)
|
51
|
+
)
|
52
|
+
|
53
|
+
const categoryLabels$ = categoryLabelsObservable(CategoryNodeMap$, CategoryEdgeMap$).pipe(
|
54
|
+
shareReplay(1)
|
55
|
+
)
|
56
|
+
|
57
|
+
const visibleComputedData$ = relationshipVisibleComputedDataObservable({
|
58
|
+
computedData$: observer.computedData$,
|
59
|
+
NodeMap$
|
60
|
+
}).pipe(
|
61
|
+
shareReplay(1)
|
62
|
+
)
|
63
|
+
|
64
|
+
return {
|
65
|
+
fullParams$: observer.fullParams$,
|
66
|
+
fullChartParams$: observer.fullChartParams$,
|
67
|
+
fullDataFormatter$: observer.fullDataFormatter$,
|
68
|
+
computedData$: observer.computedData$,
|
69
|
+
layout$: observer.layout$,
|
70
|
+
textSizePx$,
|
71
|
+
relationshipHighlightNodes$,
|
72
|
+
relationshipHighlightEdges$,
|
73
|
+
categoryLabels$,
|
74
|
+
CategoryNodeMap$,
|
75
|
+
CategoryEdgeMap$,
|
76
|
+
NodeMap$,
|
77
|
+
EdgeMap$,
|
78
|
+
visibleComputedData$
|
79
|
+
}
|
80
|
+
}
|
@@ -1,10 +1,10 @@
|
|
1
|
-
import type { DataFormatterValidator, DataFormatterTypeMap } from '../../lib/core-types'
|
2
|
-
|
3
|
-
export const dataFormatterValidator: DataFormatterValidator<'relationship'> = (dataFormatter: DataFormatterTypeMap<'relationship'>) => {
|
4
|
-
|
5
|
-
return {
|
6
|
-
status: 'success',
|
7
|
-
columnName: '',
|
8
|
-
expectToBe: ''
|
9
|
-
}
|
1
|
+
import type { DataFormatterValidator, DataFormatterTypeMap } from '../../lib/core-types'
|
2
|
+
|
3
|
+
export const dataFormatterValidator: DataFormatterValidator<'relationship'> = (dataFormatter: DataFormatterTypeMap<'relationship'>) => {
|
4
|
+
|
5
|
+
return {
|
6
|
+
status: 'success',
|
7
|
+
columnName: '',
|
8
|
+
expectToBe: ''
|
9
|
+
}
|
10
10
|
}
|
@@ -1,10 +1,10 @@
|
|
1
|
-
import type { DataValidator, DataTypeMap } from '../../lib/core-types'
|
2
|
-
|
3
|
-
export const dataValidator: DataValidator<'relationship'> = (data: DataTypeMap<'relationship'>) => {
|
4
|
-
|
5
|
-
return {
|
6
|
-
status: 'success',
|
7
|
-
columnName: '',
|
8
|
-
expectToBe: ''
|
9
|
-
}
|
1
|
+
import type { DataValidator, DataTypeMap } from '../../lib/core-types'
|
2
|
+
|
3
|
+
export const dataValidator: DataValidator<'relationship'> = (data: DataTypeMap<'relationship'>) => {
|
4
|
+
|
5
|
+
return {
|
6
|
+
status: 'success',
|
7
|
+
columnName: '',
|
8
|
+
expectToBe: ''
|
9
|
+
}
|
10
10
|
}
|
@@ -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
|
}
|