@orbcharts/core 4.0.0-alpha.0 → 4.0.0-beta.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 +876 -865
- package/dist/orbcharts-core.umd.js +3 -3
- package/dist/src/types/Plugin.d.ts +1 -1
- package/package.json +1 -1
- package/src/OrbCharts.ts +34 -34
- package/src/chart/createChart.ts +1013 -996
- package/src/chart/createGraphData.ts +391 -391
- package/src/chart/createGridData.ts +247 -247
- package/src/chart/createMultivariateData.ts +181 -181
- package/src/chart/createSeriesData.ts +297 -297
- package/src/chart/createTreeData.ts +344 -344
- package/src/chart/defaults.ts +119 -119
- package/src/defineCanvasLayer.ts +23 -23
- package/src/defineCanvasPlugin.ts +38 -38
- package/src/defineSVGLayer.ts +23 -23
- package/src/defineSVGPlugin.ts +38 -38
- package/src/index.ts +8 -8
- package/src/layer/createLayer.ts +137 -137
- package/src/plugin/createPlugin.ts +487 -469
- package/src/test/createGraphData.test.ts +103 -103
- package/src/test/createTreeData.test.ts +97 -97
- package/src/test/simple-graph-test.js +51 -51
- package/src/test/simple-tree-test.js +58 -58
- package/src/types/Chart.ts +62 -62
- package/src/types/ChartContext.ts +41 -41
- package/src/types/Common.ts +4 -4
- package/src/types/Encoding.ts +42 -42
- package/src/types/Event.ts +25 -25
- package/src/types/Layers.ts +92 -92
- package/src/types/ModelData.ts +94 -94
- package/src/types/Plugin.ts +101 -98
- package/src/types/RawData.ts +67 -67
- package/src/types/RenderData.ts +15 -15
- package/src/types/Theme.ts +20 -20
- package/src/types/Validator.ts +35 -35
- package/src/types/index.ts +12 -12
- package/src/utils/aggregateUtils.ts +99 -99
- package/src/utils/colorUtils.ts +63 -63
- package/src/utils/commonUtils.ts +56 -56
- package/src/utils/dom-lifecycle.ts +164 -164
- package/src/utils/dom.ts +54 -54
- package/src/utils/errorMessage.ts +40 -40
- package/src/utils/index.ts +7 -7
- package/src/utils/observables.ts +16 -16
- package/src/utils/orbchartsUtils.ts +8 -8
- package/src/utils/validator.ts +127 -127
package/src/types/ModelData.ts
CHANGED
|
@@ -1,95 +1,95 @@
|
|
|
1
|
-
export type ModelType = 'series' | 'grid' | 'multivariate' | 'graph' | 'tree'
|
|
2
|
-
|
|
3
|
-
export interface ModelDatumBase {
|
|
4
|
-
id: string
|
|
5
|
-
index: number // 在同類別中的索引
|
|
6
|
-
modelType: ModelType
|
|
7
|
-
name: string // 原始資料的 name 欄位
|
|
8
|
-
data: any // 原始資料的 data 欄位
|
|
9
|
-
value: number | null // 經過 aggregate 後的數值
|
|
10
|
-
color: string // 經過色彩對應後的顏色(hex)
|
|
11
|
-
// rawData: RawDataColumn // 原始資料
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export interface ModelDatumSeries extends ModelDatumBase {
|
|
15
|
-
series: string
|
|
16
|
-
seriesIndex: number
|
|
17
|
-
category: string
|
|
18
|
-
categoryIndex: number
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export interface ModelDatumGrid extends ModelDatumBase {
|
|
22
|
-
series: string
|
|
23
|
-
seriesIndex: number
|
|
24
|
-
category: string
|
|
25
|
-
categoryIndex: number
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export interface ModelDatumMultivariate extends ModelDatumBase {
|
|
29
|
-
series: string
|
|
30
|
-
seriesIndex: number
|
|
31
|
-
category: string
|
|
32
|
-
categoryIndex: number
|
|
33
|
-
multivariate: Array<{
|
|
34
|
-
index: number // 維度
|
|
35
|
-
name: string // multivariate 的 label
|
|
36
|
-
value: number | null
|
|
37
|
-
}>
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export interface ModelDatumGraphNode extends ModelDatumBase {
|
|
41
|
-
series: string
|
|
42
|
-
seriesIndex: number
|
|
43
|
-
category: string
|
|
44
|
-
categoryIndex: number
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export interface ModelDatumGraphEdge extends ModelDatumBase {
|
|
48
|
-
series: string
|
|
49
|
-
seriesIndex: number
|
|
50
|
-
category: string
|
|
51
|
-
categoryIndex: number
|
|
52
|
-
source: string // 來源節點名稱
|
|
53
|
-
sourceIndex: number // 來源節點在所有節點中的索引
|
|
54
|
-
target: string // 目標節點名稱
|
|
55
|
-
targetIndex: number // 目標節點在所有節點中的索引
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
export interface ModelDatumTree extends ModelDatumBase {
|
|
59
|
-
parent: string | null // 父節點名稱
|
|
60
|
-
parentIndex: number | null // 父節點在所有節點中的索引
|
|
61
|
-
depth: number // 節點深度(根節點為 0)
|
|
62
|
-
seq: number // 同一層級中的順序
|
|
63
|
-
children: ModelDatumTree[] // 子節點
|
|
64
|
-
series: string
|
|
65
|
-
seriesIndex: number
|
|
66
|
-
category: string
|
|
67
|
-
categoryIndex: number
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
export type ModelDatum<T extends ModelType> = T extends 'series' ? ModelDatumSeries
|
|
71
|
-
: T extends 'grid' ? ModelDatumGrid
|
|
72
|
-
: T extends 'multivariate' ? ModelDatumMultivariate
|
|
73
|
-
: T extends 'graph' ? ModelDatumGraphNode
|
|
74
|
-
: T extends 'tree' ? ModelDatumTree
|
|
75
|
-
: unknown
|
|
76
|
-
|
|
77
|
-
export type ModelDataSeries = ModelDatum<'series'>[][]
|
|
78
|
-
|
|
79
|
-
export type ModelDataGrid = ModelDatum<'grid'>[][]
|
|
80
|
-
|
|
81
|
-
export type ModelDataMultivariate = ModelDatum<'multivariate'>[][]
|
|
82
|
-
|
|
83
|
-
export interface ModelDataGraph {
|
|
84
|
-
nodes: ModelDatumGraphNode[]
|
|
85
|
-
edges: ModelDatumGraphEdge[]
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
export type ModelDataTree = ModelDatum<'tree'>
|
|
89
|
-
|
|
90
|
-
export type ModelData<T extends ModelType = ModelType> = T extends 'series' ? ModelDataSeries
|
|
91
|
-
: T extends 'grid' ? ModelDataGrid
|
|
92
|
-
: T extends 'multivariate' ? ModelDataMultivariate
|
|
93
|
-
: T extends 'graph' ? ModelDataGraph
|
|
94
|
-
: T extends 'tree' ? ModelDataTree
|
|
1
|
+
export type ModelType = 'series' | 'grid' | 'multivariate' | 'graph' | 'tree'
|
|
2
|
+
|
|
3
|
+
export interface ModelDatumBase {
|
|
4
|
+
id: string
|
|
5
|
+
index: number // 在同類別中的索引
|
|
6
|
+
modelType: ModelType
|
|
7
|
+
name: string // 原始資料的 name 欄位
|
|
8
|
+
data: any // 原始資料的 data 欄位
|
|
9
|
+
value: number | null // 經過 aggregate 後的數值
|
|
10
|
+
color: string // 經過色彩對應後的顏色(hex)
|
|
11
|
+
// rawData: RawDataColumn // 原始資料
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface ModelDatumSeries extends ModelDatumBase {
|
|
15
|
+
series: string
|
|
16
|
+
seriesIndex: number
|
|
17
|
+
category: string
|
|
18
|
+
categoryIndex: number
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface ModelDatumGrid extends ModelDatumBase {
|
|
22
|
+
series: string
|
|
23
|
+
seriesIndex: number
|
|
24
|
+
category: string
|
|
25
|
+
categoryIndex: number
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface ModelDatumMultivariate extends ModelDatumBase {
|
|
29
|
+
series: string
|
|
30
|
+
seriesIndex: number
|
|
31
|
+
category: string
|
|
32
|
+
categoryIndex: number
|
|
33
|
+
multivariate: Array<{
|
|
34
|
+
index: number // 維度
|
|
35
|
+
name: string // multivariate 的 label
|
|
36
|
+
value: number | null
|
|
37
|
+
}>
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export interface ModelDatumGraphNode extends ModelDatumBase {
|
|
41
|
+
series: string
|
|
42
|
+
seriesIndex: number
|
|
43
|
+
category: string
|
|
44
|
+
categoryIndex: number
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export interface ModelDatumGraphEdge extends ModelDatumBase {
|
|
48
|
+
series: string
|
|
49
|
+
seriesIndex: number
|
|
50
|
+
category: string
|
|
51
|
+
categoryIndex: number
|
|
52
|
+
source: string // 來源節點名稱
|
|
53
|
+
sourceIndex: number // 來源節點在所有節點中的索引
|
|
54
|
+
target: string // 目標節點名稱
|
|
55
|
+
targetIndex: number // 目標節點在所有節點中的索引
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export interface ModelDatumTree extends ModelDatumBase {
|
|
59
|
+
parent: string | null // 父節點名稱
|
|
60
|
+
parentIndex: number | null // 父節點在所有節點中的索引
|
|
61
|
+
depth: number // 節點深度(根節點為 0)
|
|
62
|
+
seq: number // 同一層級中的順序
|
|
63
|
+
children: ModelDatumTree[] // 子節點
|
|
64
|
+
series: string
|
|
65
|
+
seriesIndex: number
|
|
66
|
+
category: string
|
|
67
|
+
categoryIndex: number
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export type ModelDatum<T extends ModelType> = T extends 'series' ? ModelDatumSeries
|
|
71
|
+
: T extends 'grid' ? ModelDatumGrid
|
|
72
|
+
: T extends 'multivariate' ? ModelDatumMultivariate
|
|
73
|
+
: T extends 'graph' ? ModelDatumGraphNode
|
|
74
|
+
: T extends 'tree' ? ModelDatumTree
|
|
75
|
+
: unknown
|
|
76
|
+
|
|
77
|
+
export type ModelDataSeries = ModelDatum<'series'>[][]
|
|
78
|
+
|
|
79
|
+
export type ModelDataGrid = ModelDatum<'grid'>[][]
|
|
80
|
+
|
|
81
|
+
export type ModelDataMultivariate = ModelDatum<'multivariate'>[][]
|
|
82
|
+
|
|
83
|
+
export interface ModelDataGraph {
|
|
84
|
+
nodes: ModelDatumGraphNode[]
|
|
85
|
+
edges: ModelDatumGraphEdge[]
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export type ModelDataTree = ModelDatum<'tree'>
|
|
89
|
+
|
|
90
|
+
export type ModelData<T extends ModelType = ModelType> = T extends 'series' ? ModelDataSeries
|
|
91
|
+
: T extends 'grid' ? ModelDataGrid
|
|
92
|
+
: T extends 'multivariate' ? ModelDataMultivariate
|
|
93
|
+
: T extends 'graph' ? ModelDataGraph
|
|
94
|
+
: T extends 'tree' ? ModelDataTree
|
|
95
95
|
: unknown
|
package/src/types/Plugin.ts
CHANGED
|
@@ -1,98 +1,101 @@
|
|
|
1
|
-
import { Observable, Subject } from 'rxjs'
|
|
2
|
-
import type {
|
|
3
|
-
DeepPartial,
|
|
4
|
-
LayerEntity,
|
|
5
|
-
ChartContext,
|
|
6
|
-
ExtendableContext
|
|
7
|
-
} from './index'
|
|
8
|
-
import { ValidatorResult } from '../types/Validator'
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
export interface PluginInfo {
|
|
12
|
-
id: string
|
|
13
|
-
name: string
|
|
14
|
-
elementType: 'svg' | 'canvas'
|
|
15
|
-
shownLayers: string[]
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
// export interface PluginSetupProps<ExtendContext extends ExtendableContext, PluginParams extends Record<string, any>> {
|
|
19
|
-
// context: ChartContext<ExtendContext>
|
|
20
|
-
// svg: SVGElement
|
|
21
|
-
// canvas: HTMLCanvasElement
|
|
22
|
-
// pluginParams$: Observable<PluginParams>
|
|
23
|
-
// }
|
|
24
|
-
|
|
25
|
-
// export interface SVGPluginSetupProps<ExtendContext extends ExtendableContext, PluginParams extends Record<string, any>> {
|
|
26
|
-
// context: ChartContext<ExtendContext>
|
|
27
|
-
// svgG: SVGGElement
|
|
28
|
-
// pluginParams$: Observable<PluginParams>
|
|
29
|
-
// }
|
|
30
|
-
|
|
31
|
-
// export interface CanvasPluginSetupProps<ExtendContext extends ExtendableContext, PluginParams extends Record<string, any>> {
|
|
32
|
-
// context: ChartContext<ExtendContext>
|
|
33
|
-
// canvas: HTMLCanvasElement
|
|
34
|
-
// pluginParams$: Observable<PluginParams>
|
|
35
|
-
// }
|
|
36
|
-
|
|
37
|
-
// export type PluginSetupProps<ElementType extends 'svg' | 'canvas', ExtendContext extends ExtendableContext, PluginParams extends Record<string, any>> =
|
|
38
|
-
// ElementType extends 'svg' ? SVGPluginSetupProps<ExtendContext, PluginParams> :
|
|
39
|
-
// ElementType extends 'canvas' ? CanvasPluginSetupProps<ExtendContext, PluginParams> :
|
|
40
|
-
// never
|
|
41
|
-
|
|
42
|
-
export interface PluginSetupProps<ExtendContext extends ExtendableContext, PluginParams extends Record<string, any>> {
|
|
43
|
-
context: ChartContext<ExtendContext>
|
|
44
|
-
pluginParams$: Observable<PluginParams>
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export interface DefinePluginConfig<ExtendContext extends ExtendableContext, PluginParams extends Record<string, any>, AllLayerParams extends Record<string, any>>{
|
|
48
|
-
name: string
|
|
49
|
-
defaultParams?: PluginParams
|
|
50
|
-
validator?: (params: DeepPartial<AllLayerParams | PluginParams>) => ValidatorResult
|
|
51
|
-
// { valid: boolean; errors?: string[] }
|
|
52
|
-
|
|
53
|
-
//
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
//
|
|
85
|
-
//
|
|
86
|
-
//
|
|
87
|
-
//
|
|
88
|
-
//
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
//
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
1
|
+
import { Observable, Subject } from 'rxjs'
|
|
2
|
+
import type {
|
|
3
|
+
DeepPartial,
|
|
4
|
+
LayerEntity,
|
|
5
|
+
ChartContext,
|
|
6
|
+
ExtendableContext
|
|
7
|
+
} from './index'
|
|
8
|
+
import { ValidatorResult } from '../types/Validator'
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
export interface PluginInfo {
|
|
12
|
+
id: string
|
|
13
|
+
name: string
|
|
14
|
+
elementType: 'svg' | 'canvas'
|
|
15
|
+
shownLayers: string[]
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// export interface PluginSetupProps<ExtendContext extends ExtendableContext, PluginParams extends Record<string, any>> {
|
|
19
|
+
// context: ChartContext<ExtendContext>
|
|
20
|
+
// svg: SVGElement
|
|
21
|
+
// canvas: HTMLCanvasElement
|
|
22
|
+
// pluginParams$: Observable<PluginParams>
|
|
23
|
+
// }
|
|
24
|
+
|
|
25
|
+
// export interface SVGPluginSetupProps<ExtendContext extends ExtendableContext, PluginParams extends Record<string, any>> {
|
|
26
|
+
// context: ChartContext<ExtendContext>
|
|
27
|
+
// svgG: SVGGElement
|
|
28
|
+
// pluginParams$: Observable<PluginParams>
|
|
29
|
+
// }
|
|
30
|
+
|
|
31
|
+
// export interface CanvasPluginSetupProps<ExtendContext extends ExtendableContext, PluginParams extends Record<string, any>> {
|
|
32
|
+
// context: ChartContext<ExtendContext>
|
|
33
|
+
// canvas: HTMLCanvasElement
|
|
34
|
+
// pluginParams$: Observable<PluginParams>
|
|
35
|
+
// }
|
|
36
|
+
|
|
37
|
+
// export type PluginSetupProps<ElementType extends 'svg' | 'canvas', ExtendContext extends ExtendableContext, PluginParams extends Record<string, any>> =
|
|
38
|
+
// ElementType extends 'svg' ? SVGPluginSetupProps<ExtendContext, PluginParams> :
|
|
39
|
+
// ElementType extends 'canvas' ? CanvasPluginSetupProps<ExtendContext, PluginParams> :
|
|
40
|
+
// never
|
|
41
|
+
|
|
42
|
+
export interface PluginSetupProps<ExtendContext extends ExtendableContext, PluginParams extends Record<string, any>> {
|
|
43
|
+
context: ChartContext<ExtendContext>
|
|
44
|
+
pluginParams$: Observable<PluginParams>
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export interface DefinePluginConfig<ExtendContext extends ExtendableContext, PluginParams extends Record<string, any>, AllLayerParams extends Record<string, any>>{
|
|
48
|
+
name: string
|
|
49
|
+
defaultParams?: PluginParams
|
|
50
|
+
validator?: (params: DeepPartial<AllLayerParams | PluginParams>) => ValidatorResult
|
|
51
|
+
// { valid: boolean; errors?: string[] }
|
|
52
|
+
// Layer 建構子陣列——由 createPlugin 在「每個 plugin 實例」建立時各自實例化。
|
|
53
|
+
// (Layer 內部狀態(enableProps$ 等)不可跨 plugin 實例共用,否則同頁多個
|
|
54
|
+
// plugin 實例會互搶 layer,造成部分圖表不繪製)
|
|
55
|
+
layers?: (new () => LayerEntity<ExtendContext, PluginParams, AllLayerParams[keyof AllLayerParams]>)[]
|
|
56
|
+
// extendContext?: (context: Readonly<ChartContext>) => ExtendContext
|
|
57
|
+
setup?: (props: PluginSetupProps<ExtendContext, PluginParams>) => () => void
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// export interface CreatePlugin<PluginParams> {
|
|
61
|
+
// (config: DefinePluginConfig<PluginParams>): PluginEntity<PluginParams>
|
|
62
|
+
// }
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
export interface PluginEntity<ElementType extends 'svg' | 'canvas', PluginParams extends Record<string, any>, AllLayerParams extends Record<string, any>> {
|
|
66
|
+
readonly _name: string
|
|
67
|
+
readonly _elementType: ElementType
|
|
68
|
+
_getId: () => string
|
|
69
|
+
_setId: (id: string) => void
|
|
70
|
+
_injectContext(context: ChartContext<{}>): void
|
|
71
|
+
// layer visibility controls
|
|
72
|
+
show(names: (keyof AllLayerParams) | (keyof AllLayerParams)[]): void
|
|
73
|
+
showOnly(names: (keyof AllLayerParams) | (keyof AllLayerParams)[]): void
|
|
74
|
+
showAll(): void
|
|
75
|
+
hide(names: (keyof AllLayerParams) | (keyof AllLayerParams)[]): void
|
|
76
|
+
hideAll(): void
|
|
77
|
+
toggle(names: (keyof AllLayerParams) | (keyof AllLayerParams)[]): void
|
|
78
|
+
getShownLayerNames(): (keyof AllLayerParams)[]
|
|
79
|
+
// layer params
|
|
80
|
+
// setLayers(partial: DeepPartial<PluginParams>): void // deep-merge with default
|
|
81
|
+
updateParams(patch: DeepPartial<PluginParams | AllLayerParams>): void // deep-merge with previous
|
|
82
|
+
forceReplaceParams(full: PluginParams | AllLayerParams): void // replace(特殊需求,可節省效能)
|
|
83
|
+
getParams(): Readonly<PluginParams | AllLayerParams>
|
|
84
|
+
// layer<LayerName extends keyof PluginParams>(name: LayerName): {
|
|
85
|
+
// // set(partial: DeepPartial<PluginParams[LayerName]>): void // deep-merge with default 該 layer 的 params
|
|
86
|
+
// update(patch: DeepPartial<PluginParams[LayerName]>): void // deep-merge with previous 該 layer 的 params
|
|
87
|
+
// replace(full: PluginParams[LayerName]): void // replace(特殊需求,可節省效能)
|
|
88
|
+
// show(): void
|
|
89
|
+
// hide(): void
|
|
90
|
+
// toggle(): void
|
|
91
|
+
// }
|
|
92
|
+
|
|
93
|
+
destroy(): void
|
|
94
|
+
|
|
95
|
+
// outputs (observables)
|
|
96
|
+
// layers$: Observable<LayersConfig> // 各 layer 的有效參數(合併後)
|
|
97
|
+
// visibleLayerNames$: Observable<string[]> // 目前可見的 layer 清單(原 show$)
|
|
98
|
+
// event$: Observable<{ data: EventData; event: Event }> // 互動事件
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
|
package/src/types/RawData.ts
CHANGED
|
@@ -1,67 +1,67 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
// RawData -> ModelData (DataEndoding & ModelType) -> RenderData (Plugin)
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export type RawData = RawDataColumn[] | RawDataColumn[][] // 二維陣列會轉化為多個dataset
|
|
8
|
-
|
|
9
|
-
// 可透過 DataEncoding 更改欄位名稱的預設欄位
|
|
10
|
-
export type DynamicDefaultRawDataFields = {
|
|
11
|
-
value?: number | null
|
|
12
|
-
x?: number | null // multivariate
|
|
13
|
-
y?: number | null // multivariate
|
|
14
|
-
z?: number | null // multivariate
|
|
15
|
-
dataset?: string
|
|
16
|
-
series?: string
|
|
17
|
-
category?: string
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export type RawDataColumn<DynamicFields extends Record<string, any> = DynamicDefaultRawDataFields> = {
|
|
21
|
-
// 不可變更的基本欄位
|
|
22
|
-
id?: string
|
|
23
|
-
name?: string
|
|
24
|
-
source?: string
|
|
25
|
-
target?: string
|
|
26
|
-
parent?: string
|
|
27
|
-
data?: any
|
|
28
|
-
} & DynamicFields // 可變更的欄位
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
// export type DynamicRawDataColumn<
|
|
33
|
-
// ValueField extends string = 'value',
|
|
34
|
-
// DatasetField extends string = 'dataset',
|
|
35
|
-
// SeriesField extends string = 'series',
|
|
36
|
-
// CategoryField extends string = 'category'
|
|
37
|
-
// > = {
|
|
38
|
-
// id?: string
|
|
39
|
-
// name?: string
|
|
40
|
-
// source?: string
|
|
41
|
-
// target?: string
|
|
42
|
-
// parent?: string
|
|
43
|
-
// data?: any
|
|
44
|
-
// } & {
|
|
45
|
-
// [K in ValueField]: number | null
|
|
46
|
-
// } & {
|
|
47
|
-
// [K in DatasetField]?: string
|
|
48
|
-
// } & {
|
|
49
|
-
// [K in SeriesField]?: string
|
|
50
|
-
// } & {
|
|
51
|
-
// [K in CategoryField]?: string
|
|
52
|
-
// }
|
|
53
|
-
|
|
54
|
-
// export type FlexibleRawDataColumn<T extends Record<string, any> = {}> = {
|
|
55
|
-
// id?: string
|
|
56
|
-
// value?: number | null
|
|
57
|
-
// name?: string
|
|
58
|
-
// dataset?: string
|
|
59
|
-
// series?: string
|
|
60
|
-
// category?: string
|
|
61
|
-
// source?: string
|
|
62
|
-
// target?: string
|
|
63
|
-
// parent?: string
|
|
64
|
-
// data?: any
|
|
65
|
-
// } & T
|
|
66
|
-
|
|
67
|
-
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
// RawData -> ModelData (DataEndoding & ModelType) -> RenderData (Plugin)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
export type RawData = RawDataColumn[] | RawDataColumn[][] // 二維陣列會轉化為多個dataset
|
|
8
|
+
|
|
9
|
+
// 可透過 DataEncoding 更改欄位名稱的預設欄位
|
|
10
|
+
export type DynamicDefaultRawDataFields = {
|
|
11
|
+
value?: number | null
|
|
12
|
+
x?: number | null // multivariate
|
|
13
|
+
y?: number | null // multivariate
|
|
14
|
+
z?: number | null // multivariate
|
|
15
|
+
dataset?: string
|
|
16
|
+
series?: string
|
|
17
|
+
category?: string
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export type RawDataColumn<DynamicFields extends Record<string, any> = DynamicDefaultRawDataFields> = {
|
|
21
|
+
// 不可變更的基本欄位
|
|
22
|
+
id?: string
|
|
23
|
+
name?: string
|
|
24
|
+
source?: string
|
|
25
|
+
target?: string
|
|
26
|
+
parent?: string
|
|
27
|
+
data?: any
|
|
28
|
+
} & DynamicFields // 可變更的欄位
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
// export type DynamicRawDataColumn<
|
|
33
|
+
// ValueField extends string = 'value',
|
|
34
|
+
// DatasetField extends string = 'dataset',
|
|
35
|
+
// SeriesField extends string = 'series',
|
|
36
|
+
// CategoryField extends string = 'category'
|
|
37
|
+
// > = {
|
|
38
|
+
// id?: string
|
|
39
|
+
// name?: string
|
|
40
|
+
// source?: string
|
|
41
|
+
// target?: string
|
|
42
|
+
// parent?: string
|
|
43
|
+
// data?: any
|
|
44
|
+
// } & {
|
|
45
|
+
// [K in ValueField]: number | null
|
|
46
|
+
// } & {
|
|
47
|
+
// [K in DatasetField]?: string
|
|
48
|
+
// } & {
|
|
49
|
+
// [K in SeriesField]?: string
|
|
50
|
+
// } & {
|
|
51
|
+
// [K in CategoryField]?: string
|
|
52
|
+
// }
|
|
53
|
+
|
|
54
|
+
// export type FlexibleRawDataColumn<T extends Record<string, any> = {}> = {
|
|
55
|
+
// id?: string
|
|
56
|
+
// value?: number | null
|
|
57
|
+
// name?: string
|
|
58
|
+
// dataset?: string
|
|
59
|
+
// series?: string
|
|
60
|
+
// category?: string
|
|
61
|
+
// source?: string
|
|
62
|
+
// target?: string
|
|
63
|
+
// parent?: string
|
|
64
|
+
// data?: any
|
|
65
|
+
// } & T
|
|
66
|
+
|
|
67
|
+
|
package/src/types/RenderData.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
ModelType,
|
|
3
|
-
ModelDatum,
|
|
4
|
-
ModelDatumGraphEdge
|
|
5
|
-
} from './index'
|
|
6
|
-
|
|
7
|
-
// 基礎型別,其他欄位留給 Plugin 擴充
|
|
8
|
-
// export interface RenderDatumBase<T extends ModelType> {
|
|
9
|
-
// modelDatum: ModelDatum<T>
|
|
10
|
-
// }
|
|
11
|
-
export type RenderDatumBase<
|
|
12
|
-
T extends ModelType,
|
|
13
|
-
ExtendTypes extends Record<string, any> = {}
|
|
14
|
-
> = ModelDatum<T> & ExtendTypes
|
|
15
|
-
|
|
1
|
+
import type {
|
|
2
|
+
ModelType,
|
|
3
|
+
ModelDatum,
|
|
4
|
+
ModelDatumGraphEdge
|
|
5
|
+
} from './index'
|
|
6
|
+
|
|
7
|
+
// 基礎型別,其他欄位留給 Plugin 擴充
|
|
8
|
+
// export interface RenderDatumBase<T extends ModelType> {
|
|
9
|
+
// modelDatum: ModelDatum<T>
|
|
10
|
+
// }
|
|
11
|
+
export type RenderDatumBase<
|
|
12
|
+
T extends ModelType,
|
|
13
|
+
ExtendTypes extends Record<string, any> = {}
|
|
14
|
+
> = ModelDatum<T> & ExtendTypes
|
|
15
|
+
|
|
16
16
|
export type RenderDatumGraphEdge<ExtendTypes extends Record<string, any> = {}> = ModelDatumGraphEdge & ExtendTypes
|
package/src/types/Theme.ts
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
export interface Colors {
|
|
3
|
-
data: string[],
|
|
4
|
-
primary: string,
|
|
5
|
-
secondary: string,
|
|
6
|
-
dataContrast: string[],
|
|
7
|
-
background: string
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export type ColorScheme = 'light' | 'dark'
|
|
11
|
-
|
|
12
|
-
export interface Theme {
|
|
13
|
-
colorScheme: ColorScheme | 'auto'
|
|
14
|
-
colors: {
|
|
15
|
-
light: Colors,
|
|
16
|
-
dark: Colors
|
|
17
|
-
},
|
|
18
|
-
fontSize: string | number
|
|
19
|
-
}
|
|
20
|
-
|
|
1
|
+
|
|
2
|
+
export interface Colors {
|
|
3
|
+
data: string[],
|
|
4
|
+
primary: string,
|
|
5
|
+
secondary: string,
|
|
6
|
+
dataContrast: string[],
|
|
7
|
+
background: string
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export type ColorScheme = 'light' | 'dark'
|
|
11
|
+
|
|
12
|
+
export interface Theme {
|
|
13
|
+
colorScheme: ColorScheme | 'auto'
|
|
14
|
+
colors: {
|
|
15
|
+
light: Colors,
|
|
16
|
+
dark: Colors
|
|
17
|
+
},
|
|
18
|
+
fontSize: string | number
|
|
19
|
+
}
|
|
20
|
+
|
|
21
21
|
export type ColorType = 'none' | keyof Colors
|