@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,144 +1,159 @@
|
|
1
|
-
import type {
|
2
|
-
DataRelationshipObj,
|
3
|
-
DataRelationshipList,
|
4
|
-
Node,
|
5
|
-
Edge,
|
6
|
-
ComputedDataFn,
|
7
|
-
ComputedDataRelationship,
|
8
|
-
ComputedNode,
|
9
|
-
ComputedEdge
|
10
|
-
} from '../../lib/core-types'
|
11
|
-
import { createDefaultCategoryLabel, seriesColorPredicate } from '../utils/orbchartsUtils'
|
12
|
-
|
13
|
-
export const computedDataFn: ComputedDataFn<'relationship'> = (context) => {
|
14
|
-
const { data, dataFormatter, chartParams } = context
|
15
|
-
|
16
|
-
const defaultCategoryLabel = createDefaultCategoryLabel()
|
17
|
-
|
18
|
-
let computedNodes: ComputedNode[] = []
|
19
|
-
let computedEdges: ComputedEdge[] = []
|
20
|
-
|
21
|
-
try {
|
22
|
-
// -- 取得nodes和edges資料 --
|
23
|
-
let nodes: Node[] = []
|
24
|
-
let edges: Edge[] = []
|
25
|
-
if ((data as DataRelationshipObj).nodes) {
|
26
|
-
nodes = (data as DataRelationshipObj).nodes
|
27
|
-
edges = (data as DataRelationshipObj).edges
|
28
|
-
} else if ((data as DataRelationshipList)[0]) {
|
29
|
-
nodes = (data as DataRelationshipList)[0]
|
30
|
-
edges = (data as DataRelationshipList)[1]
|
31
|
-
} else {
|
32
|
-
// 無值直接回傳
|
33
|
-
return {
|
34
|
-
nodes: [],
|
35
|
-
edges: []
|
36
|
-
} as ComputedDataRelationship
|
37
|
-
}
|
38
|
-
|
39
|
-
const categoryLabels = (() => {
|
40
|
-
// 先使用 dataFormatter.categoryLabels
|
41
|
-
const CategoryLabelsSet = new Set(dataFormatter.categoryLabels)
|
42
|
-
// 再加入 datum 中的 categoryLabel
|
43
|
-
for (let datum of nodes) {
|
44
|
-
const categoryLabel = datum.categoryLabel ?? defaultCategoryLabel
|
45
|
-
CategoryLabelsSet.add(categoryLabel) // 不重覆
|
46
|
-
}
|
47
|
-
for (let datum of edges) {
|
48
|
-
const categoryLabel = datum.categoryLabel ?? defaultCategoryLabel
|
49
|
-
CategoryLabelsSet.add(categoryLabel) // 不重覆
|
50
|
-
}
|
51
|
-
return Array.from(CategoryLabelsSet)
|
52
|
-
})()
|
53
|
-
|
54
|
-
// <categoryLabel, categoryIndex>
|
55
|
-
const CategoryIndexMap = new Map<string, number>(
|
56
|
-
categoryLabels.map((label, index) => [label, index])
|
57
|
-
)
|
58
|
-
|
59
|
-
// -- nodes --
|
60
|
-
computedNodes = nodes.map((node, i) => {
|
61
|
-
const categoryLabel = node.categoryLabel ?? defaultCategoryLabel
|
62
|
-
const categoryIndex = CategoryIndexMap.get(categoryLabel) ?? 0
|
63
|
-
|
64
|
-
const computedNode: ComputedNode = {
|
65
|
-
id: node.id,
|
66
|
-
index: i,
|
67
|
-
label: node.label ?? '',
|
68
|
-
description: node.description ?? '',
|
69
|
-
data: node.data ?? {},
|
70
|
-
value: node.value ?? 0,
|
71
|
-
categoryIndex,
|
72
|
-
categoryLabel,
|
73
|
-
color: seriesColorPredicate(categoryIndex, chartParams),
|
74
|
-
// startNodes: [], // 後面再取得資料
|
75
|
-
// startNodeIds: [], // 後面再取得資料
|
76
|
-
// endNodes: [], // 後面再取得資料
|
77
|
-
// endNodeIds: [], // 後面再取得資料
|
78
|
-
visible: true // 先給預設值
|
79
|
-
}
|
80
|
-
|
81
|
-
computedNode.visible = dataFormatter.visibleFilter(computedNode, context)
|
82
|
-
|
83
|
-
return computedNode
|
84
|
-
})
|
85
|
-
|
86
|
-
const NodesMap: Map<string, ComputedNode> = new Map(computedNodes.map(d => [d.id, d]))
|
87
|
-
|
88
|
-
// const StartNodesMap: Map<string, ComputedNode[]> = (function () {
|
89
|
-
// const _StartNodesMap = new Map()
|
90
|
-
// computedEdges.forEach(edge => {
|
91
|
-
// const startNodes: ComputedNode[] = _StartNodesMap.get(edge.endNodeId) ?? []
|
92
|
-
// startNodes.push(edge.startNode)
|
93
|
-
// _StartNodesMap.set(edge.endNodeId, startNodes)
|
94
|
-
// })
|
95
|
-
// return _StartNodesMap
|
96
|
-
// })()
|
97
|
-
|
98
|
-
// const EndNodesMap: Map<string, ComputedNode[]> = (function () {
|
99
|
-
// const _EndNodesMap = new Map()
|
100
|
-
// computedEdges.forEach(edge => {
|
101
|
-
// const endNodes: ComputedNode[] = _EndNodesMap.get(edge.startNodeId) ?? []
|
102
|
-
// endNodes.push(edge.endNode)
|
103
|
-
// _EndNodesMap.set(edge.startNodeId, endNodes)
|
104
|
-
// })
|
105
|
-
// return _EndNodesMap
|
106
|
-
// })()
|
107
|
-
|
108
|
-
// -- edges --
|
109
|
-
computedEdges = edges
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
//
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
}
|
1
|
+
import type {
|
2
|
+
DataRelationshipObj,
|
3
|
+
DataRelationshipList,
|
4
|
+
Node,
|
5
|
+
Edge,
|
6
|
+
ComputedDataFn,
|
7
|
+
ComputedDataRelationship,
|
8
|
+
ComputedNode,
|
9
|
+
ComputedEdge
|
10
|
+
} from '../../lib/core-types'
|
11
|
+
import { createDefaultCategoryLabel, seriesColorPredicate } from '../utils/orbchartsUtils'
|
12
|
+
|
13
|
+
export const computedDataFn: ComputedDataFn<'relationship'> = (context) => {
|
14
|
+
const { data, dataFormatter, chartParams } = context
|
15
|
+
|
16
|
+
const defaultCategoryLabel = createDefaultCategoryLabel()
|
17
|
+
|
18
|
+
let computedNodes: ComputedNode[] = []
|
19
|
+
let computedEdges: ComputedEdge[] = []
|
20
|
+
|
21
|
+
try {
|
22
|
+
// -- 取得nodes和edges資料 --
|
23
|
+
let nodes: Node[] = []
|
24
|
+
let edges: Edge[] = []
|
25
|
+
if ((data as DataRelationshipObj).nodes) {
|
26
|
+
nodes = (data as DataRelationshipObj).nodes
|
27
|
+
edges = (data as DataRelationshipObj).edges
|
28
|
+
} else if ((data as DataRelationshipList)[0]) {
|
29
|
+
nodes = (data as DataRelationshipList)[0]
|
30
|
+
edges = (data as DataRelationshipList)[1]
|
31
|
+
} else {
|
32
|
+
// 無值直接回傳
|
33
|
+
return {
|
34
|
+
nodes: [],
|
35
|
+
edges: []
|
36
|
+
} as ComputedDataRelationship
|
37
|
+
}
|
38
|
+
|
39
|
+
const categoryLabels = (() => {
|
40
|
+
// 先使用 dataFormatter.categoryLabels
|
41
|
+
const CategoryLabelsSet = new Set(dataFormatter.categoryLabels)
|
42
|
+
// 再加入 datum 中的 categoryLabel
|
43
|
+
for (let datum of nodes) {
|
44
|
+
const categoryLabel = datum.categoryLabel ?? defaultCategoryLabel
|
45
|
+
CategoryLabelsSet.add(categoryLabel) // 不重覆
|
46
|
+
}
|
47
|
+
for (let datum of edges) {
|
48
|
+
const categoryLabel = datum.categoryLabel ?? defaultCategoryLabel
|
49
|
+
CategoryLabelsSet.add(categoryLabel) // 不重覆
|
50
|
+
}
|
51
|
+
return Array.from(CategoryLabelsSet)
|
52
|
+
})()
|
53
|
+
|
54
|
+
// <categoryLabel, categoryIndex>
|
55
|
+
const CategoryIndexMap = new Map<string, number>(
|
56
|
+
categoryLabels.map((label, index) => [label, index])
|
57
|
+
)
|
58
|
+
|
59
|
+
// -- nodes --
|
60
|
+
computedNodes = nodes.map((node, i) => {
|
61
|
+
const categoryLabel = node.categoryLabel ?? defaultCategoryLabel
|
62
|
+
const categoryIndex = CategoryIndexMap.get(categoryLabel) ?? 0
|
63
|
+
|
64
|
+
const computedNode: ComputedNode = {
|
65
|
+
id: node.id,
|
66
|
+
index: i,
|
67
|
+
label: node.label ?? '',
|
68
|
+
description: node.description ?? '',
|
69
|
+
data: node.data ?? {},
|
70
|
+
value: node.value ?? 0,
|
71
|
+
categoryIndex,
|
72
|
+
categoryLabel,
|
73
|
+
color: seriesColorPredicate(categoryIndex, chartParams),
|
74
|
+
// startNodes: [], // 後面再取得資料
|
75
|
+
// startNodeIds: [], // 後面再取得資料
|
76
|
+
// endNodes: [], // 後面再取得資料
|
77
|
+
// endNodeIds: [], // 後面再取得資料
|
78
|
+
visible: true // 先給預設值
|
79
|
+
}
|
80
|
+
|
81
|
+
computedNode.visible = dataFormatter.visibleFilter(computedNode, context)
|
82
|
+
|
83
|
+
return computedNode
|
84
|
+
})
|
85
|
+
|
86
|
+
const NodesMap: Map<string, ComputedNode> = new Map(computedNodes.map(d => [d.id, d]))
|
87
|
+
|
88
|
+
// const StartNodesMap: Map<string, ComputedNode[]> = (function () {
|
89
|
+
// const _StartNodesMap = new Map()
|
90
|
+
// computedEdges.forEach(edge => {
|
91
|
+
// const startNodes: ComputedNode[] = _StartNodesMap.get(edge.endNodeId) ?? []
|
92
|
+
// startNodes.push(edge.startNode)
|
93
|
+
// _StartNodesMap.set(edge.endNodeId, startNodes)
|
94
|
+
// })
|
95
|
+
// return _StartNodesMap
|
96
|
+
// })()
|
97
|
+
|
98
|
+
// const EndNodesMap: Map<string, ComputedNode[]> = (function () {
|
99
|
+
// const _EndNodesMap = new Map()
|
100
|
+
// computedEdges.forEach(edge => {
|
101
|
+
// const endNodes: ComputedNode[] = _EndNodesMap.get(edge.startNodeId) ?? []
|
102
|
+
// endNodes.push(edge.endNode)
|
103
|
+
// _EndNodesMap.set(edge.startNodeId, endNodes)
|
104
|
+
// })
|
105
|
+
// return _EndNodesMap
|
106
|
+
// })()
|
107
|
+
|
108
|
+
// -- edges --
|
109
|
+
computedEdges = edges
|
110
|
+
.map((edge, i) => {
|
111
|
+
const startNode = NodesMap.get(edge.start)
|
112
|
+
const endNode = NodesMap.get(edge.end)
|
113
|
+
return {
|
114
|
+
edge,
|
115
|
+
startNode,
|
116
|
+
endNode
|
117
|
+
}
|
118
|
+
})
|
119
|
+
.filter(({ edge }) => {
|
120
|
+
const startNode = NodesMap.get(edge.start)
|
121
|
+
const endNode = NodesMap.get(edge.end)
|
122
|
+
return startNode != null && endNode != null
|
123
|
+
})
|
124
|
+
.map(({ edge, startNode, endNode }, i) => {
|
125
|
+
const categoryLabel = edge.categoryLabel ?? defaultCategoryLabel
|
126
|
+
// const startNode = NodesMap.get(edge.start)
|
127
|
+
// const endNode = NodesMap.get(edge.end)
|
128
|
+
|
129
|
+
const computedEdge: ComputedEdge = {
|
130
|
+
id: edge.id,
|
131
|
+
index: i,
|
132
|
+
label: edge.label ?? '',
|
133
|
+
description: edge.description ?? '',
|
134
|
+
data: edge.data ?? {},
|
135
|
+
value: edge.value ?? 0,
|
136
|
+
categoryIndex: CategoryIndexMap.get(categoryLabel),
|
137
|
+
categoryLabel,
|
138
|
+
color: seriesColorPredicate(i, chartParams),
|
139
|
+
startNode,
|
140
|
+
// startNodeId: edge.start,
|
141
|
+
endNode,
|
142
|
+
// endNodeId: edge.end,
|
143
|
+
visible: startNode.visible && endNode.visible
|
144
|
+
}
|
145
|
+
|
146
|
+
return computedEdge
|
147
|
+
})
|
148
|
+
|
149
|
+
|
150
|
+
} catch (e) {
|
151
|
+
// console.error(e)
|
152
|
+
throw Error(e)
|
153
|
+
}
|
154
|
+
|
155
|
+
return {
|
156
|
+
nodes: computedNodes,
|
157
|
+
edges: computedEdges
|
158
|
+
}
|
159
|
+
}
|
@@ -1,80 +1,80 @@
|
|
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
|
+
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,14 @@
|
|
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<'relationship'> = (dataFormatter: DataFormatterTypeMap<'relationship'>) => {
|
5
|
+
const result = validateColumns(dataFormatter, {
|
6
|
+
visibleFilter: {
|
7
|
+
toBeTypes: ['Function']
|
8
|
+
},
|
9
|
+
categoryLabels: {
|
10
|
+
toBeTypes: ['string[]']
|
11
|
+
}
|
12
|
+
})
|
13
|
+
return result
|
10
14
|
}
|
@@ -1,10 +1,14 @@
|
|
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
|
+
import { isPlainObject } from '../utils'
|
4
|
+
|
5
|
+
export const dataValidator: DataValidator<'relationship'> = (data: DataTypeMap<'relationship'>) => {
|
6
|
+
const result = validateColumns({ data }, {
|
7
|
+
data: {
|
8
|
+
toBe: 'DataRelationshipObj | DataRelationshipList',
|
9
|
+
// 畢免資料量過大檢查不完,不深度檢查
|
10
|
+
test: (value) => isPlainObject(value) || Array.isArray(value)
|
11
|
+
}
|
12
|
+
})
|
13
|
+
return result
|
10
14
|
}
|