@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/chart/defaults.ts
CHANGED
|
@@ -1,120 +1,120 @@
|
|
|
1
|
-
import type { Encoding, Theme, SizeConfig } from '../types'
|
|
2
|
-
|
|
3
|
-
// export const DEFAULT_CHART_WIDTH = 800
|
|
4
|
-
|
|
5
|
-
// export const DEFAULT_CHART_HEIGHT = 500
|
|
6
|
-
|
|
7
|
-
export const DEFAULT_SIZE_CONFIG: SizeConfig = {
|
|
8
|
-
width: 'auto',
|
|
9
|
-
height: 'auto',
|
|
10
|
-
resizeDebounce: 50
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export const DEFAULT_DATA_ENCODING: Encoding = {
|
|
14
|
-
dataset: {
|
|
15
|
-
from: 'dataset',
|
|
16
|
-
sort: 'original'
|
|
17
|
-
},
|
|
18
|
-
series: {
|
|
19
|
-
from: 'series',
|
|
20
|
-
sort: 'original'
|
|
21
|
-
},
|
|
22
|
-
category: {
|
|
23
|
-
from: 'category',
|
|
24
|
-
sort: 'original'
|
|
25
|
-
},
|
|
26
|
-
value: {
|
|
27
|
-
from: 'value',
|
|
28
|
-
sort: 'original',
|
|
29
|
-
aggregate: 'none'
|
|
30
|
-
},
|
|
31
|
-
multivariate: [
|
|
32
|
-
{ from: 'x', name: 'x' },
|
|
33
|
-
{ from: 'y', name: 'y' },
|
|
34
|
-
{ from: 'z', name: 'z' },
|
|
35
|
-
],
|
|
36
|
-
color: {
|
|
37
|
-
from: 'series',
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export const DEFAULT_THEME: Theme = {
|
|
42
|
-
// colorScheme: 'light',
|
|
43
|
-
// colors: {
|
|
44
|
-
// light: {
|
|
45
|
-
// data: ['#5B8FF9', '#61DDAA', '#65789B', '#F6BD16', '#7262FD', '#78D3F8', '#9661BC', '#F6903D', '#008685', '#F08BB4'],
|
|
46
|
-
// primary: '#000000',
|
|
47
|
-
// secondary: '#595959',
|
|
48
|
-
// dataContrast: ['#FF4D4F', '#FAAD14', '#52C41A', '#1890FF', '#722ED1', '#EB2F96', '#13C2C2', '#FA541C', '#2F54EB', '#A0D911'],
|
|
49
|
-
// background: '#FFFFFF'
|
|
50
|
-
// },
|
|
51
|
-
// dark: {
|
|
52
|
-
// data: ['#5B8FF9', '#61DDAA', '#65789B', '#F6BD16', '#7262FD', '#78D3F8', '#9661BC', '#F6903D', '#008685', '#F08BB4'],
|
|
53
|
-
// primary: '#FFFFFF',
|
|
54
|
-
// secondary: '#BFBFBF',
|
|
55
|
-
// dataContrast: ['#FF4D4F', '#FAAD14', '#52C41A', '#1890FF', '#722ED1', '#EB2F96', '#13C2C2', '#FA541C', '#2F54EB', '#A0D911'],
|
|
56
|
-
// background: '#1F1F1F'
|
|
57
|
-
// }
|
|
58
|
-
// },
|
|
59
|
-
// fontSize: '12px'
|
|
60
|
-
colorScheme: 'light',
|
|
61
|
-
colors: {
|
|
62
|
-
light: {
|
|
63
|
-
data: [
|
|
64
|
-
// "#0088FF",
|
|
65
|
-
// "#FF3232",
|
|
66
|
-
// "#38BEA8",
|
|
67
|
-
// "#6F3BD5",
|
|
68
|
-
// "#314285",
|
|
69
|
-
// "#42C724",
|
|
70
|
-
// "#D52580",
|
|
71
|
-
// "#F4721B",
|
|
72
|
-
// "#D117EA",
|
|
73
|
-
// "#7E7D7D"
|
|
74
|
-
'#4E79A7', // blue
|
|
75
|
-
'#F28E2B', // orange
|
|
76
|
-
'#E15759', // red
|
|
77
|
-
'#76B7B2', // teal
|
|
78
|
-
'#59A14F', // green
|
|
79
|
-
'#EDC948', // yellow (已調過不刺眼)
|
|
80
|
-
'#B07AA1', // purple
|
|
81
|
-
'#FF9DA7', // pink
|
|
82
|
-
'#9C755F', // brown
|
|
83
|
-
'#BAB0AC', // gray
|
|
84
|
-
],
|
|
85
|
-
primary: '#000000',
|
|
86
|
-
secondary: '#e0e0e0',
|
|
87
|
-
dataContrast: ['#ffffff', '#000000'],
|
|
88
|
-
background: '#FFFFFF'
|
|
89
|
-
},
|
|
90
|
-
dark: {
|
|
91
|
-
data: [
|
|
92
|
-
// "#4BABFF",
|
|
93
|
-
// "#FF6C6C",
|
|
94
|
-
// "#7DD3C4",
|
|
95
|
-
// "#8E6BC9",
|
|
96
|
-
// "#5366AC",
|
|
97
|
-
// "#86DC72",
|
|
98
|
-
// "#FF72BB",
|
|
99
|
-
// "#F9B052",
|
|
100
|
-
// "#EF76FF",
|
|
101
|
-
// "#C4C4C4"
|
|
102
|
-
'#7EA6E0', // blue (亮化)
|
|
103
|
-
'#FFB86B', // orange
|
|
104
|
-
'#FF7A7A', // red
|
|
105
|
-
'#6ED0CC', // teal
|
|
106
|
-
'#7ED97A', // green
|
|
107
|
-
'#FFE06E', // yellow
|
|
108
|
-
'#D4A5D8', // purple
|
|
109
|
-
'#FFB3BA', // pink
|
|
110
|
-
'#C89F7A', // brown
|
|
111
|
-
'#D3D3D3', // gray
|
|
112
|
-
],
|
|
113
|
-
primary: '#FFFFFF',
|
|
114
|
-
secondary: '#e0e0e0',
|
|
115
|
-
dataContrast: ['#ffffff', '#000000'],
|
|
116
|
-
background: '#000000'
|
|
117
|
-
}
|
|
118
|
-
},
|
|
119
|
-
fontSize: '0.875rem'
|
|
1
|
+
import type { Encoding, Theme, SizeConfig } from '../types'
|
|
2
|
+
|
|
3
|
+
// export const DEFAULT_CHART_WIDTH = 800
|
|
4
|
+
|
|
5
|
+
// export const DEFAULT_CHART_HEIGHT = 500
|
|
6
|
+
|
|
7
|
+
export const DEFAULT_SIZE_CONFIG: SizeConfig = {
|
|
8
|
+
width: 'auto',
|
|
9
|
+
height: 'auto',
|
|
10
|
+
resizeDebounce: 50
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const DEFAULT_DATA_ENCODING: Encoding = {
|
|
14
|
+
dataset: {
|
|
15
|
+
from: 'dataset',
|
|
16
|
+
sort: 'original'
|
|
17
|
+
},
|
|
18
|
+
series: {
|
|
19
|
+
from: 'series',
|
|
20
|
+
sort: 'original'
|
|
21
|
+
},
|
|
22
|
+
category: {
|
|
23
|
+
from: 'category',
|
|
24
|
+
sort: 'original'
|
|
25
|
+
},
|
|
26
|
+
value: {
|
|
27
|
+
from: 'value',
|
|
28
|
+
sort: 'original',
|
|
29
|
+
aggregate: 'none'
|
|
30
|
+
},
|
|
31
|
+
multivariate: [
|
|
32
|
+
{ from: 'x', name: 'x' },
|
|
33
|
+
{ from: 'y', name: 'y' },
|
|
34
|
+
{ from: 'z', name: 'z' },
|
|
35
|
+
],
|
|
36
|
+
color: {
|
|
37
|
+
from: 'series',
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export const DEFAULT_THEME: Theme = {
|
|
42
|
+
// colorScheme: 'light',
|
|
43
|
+
// colors: {
|
|
44
|
+
// light: {
|
|
45
|
+
// data: ['#5B8FF9', '#61DDAA', '#65789B', '#F6BD16', '#7262FD', '#78D3F8', '#9661BC', '#F6903D', '#008685', '#F08BB4'],
|
|
46
|
+
// primary: '#000000',
|
|
47
|
+
// secondary: '#595959',
|
|
48
|
+
// dataContrast: ['#FF4D4F', '#FAAD14', '#52C41A', '#1890FF', '#722ED1', '#EB2F96', '#13C2C2', '#FA541C', '#2F54EB', '#A0D911'],
|
|
49
|
+
// background: '#FFFFFF'
|
|
50
|
+
// },
|
|
51
|
+
// dark: {
|
|
52
|
+
// data: ['#5B8FF9', '#61DDAA', '#65789B', '#F6BD16', '#7262FD', '#78D3F8', '#9661BC', '#F6903D', '#008685', '#F08BB4'],
|
|
53
|
+
// primary: '#FFFFFF',
|
|
54
|
+
// secondary: '#BFBFBF',
|
|
55
|
+
// dataContrast: ['#FF4D4F', '#FAAD14', '#52C41A', '#1890FF', '#722ED1', '#EB2F96', '#13C2C2', '#FA541C', '#2F54EB', '#A0D911'],
|
|
56
|
+
// background: '#1F1F1F'
|
|
57
|
+
// }
|
|
58
|
+
// },
|
|
59
|
+
// fontSize: '12px'
|
|
60
|
+
colorScheme: 'light',
|
|
61
|
+
colors: {
|
|
62
|
+
light: {
|
|
63
|
+
data: [
|
|
64
|
+
// "#0088FF",
|
|
65
|
+
// "#FF3232",
|
|
66
|
+
// "#38BEA8",
|
|
67
|
+
// "#6F3BD5",
|
|
68
|
+
// "#314285",
|
|
69
|
+
// "#42C724",
|
|
70
|
+
// "#D52580",
|
|
71
|
+
// "#F4721B",
|
|
72
|
+
// "#D117EA",
|
|
73
|
+
// "#7E7D7D"
|
|
74
|
+
'#4E79A7', // blue
|
|
75
|
+
'#F28E2B', // orange
|
|
76
|
+
'#E15759', // red
|
|
77
|
+
'#76B7B2', // teal
|
|
78
|
+
'#59A14F', // green
|
|
79
|
+
'#EDC948', // yellow (已調過不刺眼)
|
|
80
|
+
'#B07AA1', // purple
|
|
81
|
+
'#FF9DA7', // pink
|
|
82
|
+
'#9C755F', // brown
|
|
83
|
+
'#BAB0AC', // gray
|
|
84
|
+
],
|
|
85
|
+
primary: '#000000',
|
|
86
|
+
secondary: '#e0e0e0',
|
|
87
|
+
dataContrast: ['#ffffff', '#000000'],
|
|
88
|
+
background: '#FFFFFF'
|
|
89
|
+
},
|
|
90
|
+
dark: {
|
|
91
|
+
data: [
|
|
92
|
+
// "#4BABFF",
|
|
93
|
+
// "#FF6C6C",
|
|
94
|
+
// "#7DD3C4",
|
|
95
|
+
// "#8E6BC9",
|
|
96
|
+
// "#5366AC",
|
|
97
|
+
// "#86DC72",
|
|
98
|
+
// "#FF72BB",
|
|
99
|
+
// "#F9B052",
|
|
100
|
+
// "#EF76FF",
|
|
101
|
+
// "#C4C4C4"
|
|
102
|
+
'#7EA6E0', // blue (亮化)
|
|
103
|
+
'#FFB86B', // orange
|
|
104
|
+
'#FF7A7A', // red
|
|
105
|
+
'#6ED0CC', // teal
|
|
106
|
+
'#7ED97A', // green
|
|
107
|
+
'#FFE06E', // yellow
|
|
108
|
+
'#D4A5D8', // purple
|
|
109
|
+
'#FFB3BA', // pink
|
|
110
|
+
'#C89F7A', // brown
|
|
111
|
+
'#D3D3D3', // gray
|
|
112
|
+
],
|
|
113
|
+
primary: '#FFFFFF',
|
|
114
|
+
secondary: '#e0e0e0',
|
|
115
|
+
dataContrast: ['#ffffff', '#000000'],
|
|
116
|
+
background: '#000000'
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
fontSize: '0.875rem'
|
|
120
120
|
}
|
package/src/defineCanvasLayer.ts
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import type { ChartContext, DefineLayerConfig, LayerEntity, ExtendableContext, LayerEnableProps } from "./types"
|
|
2
|
-
import { createLayer } from "./layer/createLayer"
|
|
3
|
-
|
|
4
|
-
export const defineCanvasLayer = <
|
|
5
|
-
ExtendContext extends ExtendableContext,
|
|
6
|
-
PluginParams extends Record<string, any>,
|
|
7
|
-
LayerParams extends Record<string, any>,
|
|
8
|
-
>(config: DefineLayerConfig<'canvas', ExtendContext, PluginParams, LayerParams>) => {
|
|
9
|
-
return class Layer implements LayerEntity<ExtendContext, PluginParams, LayerParams> {
|
|
10
|
-
_name: string
|
|
11
|
-
_defaultParams: LayerParams
|
|
12
|
-
_layerIndex: number
|
|
13
|
-
_initShow: boolean
|
|
14
|
-
_enable: (enableProps: LayerEnableProps<'canvas', ExtendContext, PluginParams, LayerParams>) => void
|
|
15
|
-
_disable: () => void
|
|
16
|
-
_updateParams: (params: Partial<LayerParams>) => void
|
|
17
|
-
_forceReplaceParams: (params: LayerParams) => void
|
|
18
|
-
_getParams: () => Readonly<LayerParams>
|
|
19
|
-
_destroy: () => void
|
|
20
|
-
constructor () {
|
|
21
|
-
return createLayer<ExtendContext, PluginParams, LayerParams>('canvas', config)
|
|
22
|
-
}
|
|
23
|
-
}
|
|
1
|
+
import type { ChartContext, DefineLayerConfig, LayerEntity, ExtendableContext, LayerEnableProps } from "./types"
|
|
2
|
+
import { createLayer } from "./layer/createLayer"
|
|
3
|
+
|
|
4
|
+
export const defineCanvasLayer = <
|
|
5
|
+
ExtendContext extends ExtendableContext,
|
|
6
|
+
PluginParams extends Record<string, any>,
|
|
7
|
+
LayerParams extends Record<string, any>,
|
|
8
|
+
>(config: DefineLayerConfig<'canvas', ExtendContext, PluginParams, LayerParams>) => {
|
|
9
|
+
return class Layer implements LayerEntity<ExtendContext, PluginParams, LayerParams> {
|
|
10
|
+
_name: string
|
|
11
|
+
_defaultParams: LayerParams
|
|
12
|
+
_layerIndex: number
|
|
13
|
+
_initShow: boolean
|
|
14
|
+
_enable: (enableProps: LayerEnableProps<'canvas', ExtendContext, PluginParams, LayerParams>) => void
|
|
15
|
+
_disable: () => void
|
|
16
|
+
_updateParams: (params: Partial<LayerParams>) => void
|
|
17
|
+
_forceReplaceParams: (params: LayerParams) => void
|
|
18
|
+
_getParams: () => Readonly<LayerParams>
|
|
19
|
+
_destroy: () => void
|
|
20
|
+
constructor () {
|
|
21
|
+
return createLayer<ExtendContext, PluginParams, LayerParams>('canvas', config)
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
24
|
}
|
|
@@ -1,39 +1,39 @@
|
|
|
1
|
-
import type { DeepPartial, DefinePluginConfig, PluginEntity, ChartContext, ExtendableContext } from './types'
|
|
2
|
-
import { createPlugin } from './plugin/createPlugin'
|
|
3
|
-
|
|
4
|
-
export const defineCanvasPlugin = <
|
|
5
|
-
ExtendContext extends ExtendableContext,
|
|
6
|
-
PluginParams extends Record<string, any>,
|
|
7
|
-
AllLayerParams extends Record<string, any>,
|
|
8
|
-
>(config: DefinePluginConfig<ExtendContext, PluginParams, AllLayerParams>) => {
|
|
9
|
-
return class Plugin implements PluginEntity<'canvas', PluginParams, AllLayerParams> {
|
|
10
|
-
_name: string
|
|
11
|
-
_elementType: 'canvas'
|
|
12
|
-
_getId: () => string
|
|
13
|
-
_setId: (id: string) => void
|
|
14
|
-
_injectContext: (context: ChartContext<{}>) => void
|
|
15
|
-
show: (names: (keyof AllLayerParams) | (keyof AllLayerParams)[]) => void
|
|
16
|
-
showOnly: (names: (keyof AllLayerParams) | (keyof AllLayerParams)[]) => void
|
|
17
|
-
showAll: () => void
|
|
18
|
-
hide: (names: (keyof AllLayerParams) | (keyof AllLayerParams)[]) => void
|
|
19
|
-
hideAll: () => void
|
|
20
|
-
toggle: (names: (keyof AllLayerParams) | (keyof AllLayerParams)[]) => void
|
|
21
|
-
// setLayers: (partial: DeepPartial<PluginParams>) => void
|
|
22
|
-
getShownLayerNames: () => (keyof AllLayerParams)[]
|
|
23
|
-
updateParams: (patch: DeepPartial<PluginParams | AllLayerParams>) => void
|
|
24
|
-
forceReplaceParams: (full: PluginParams | AllLayerParams) => void
|
|
25
|
-
getParams: () => Readonly<PluginParams | AllLayerParams>
|
|
26
|
-
// layer: <LayerName extends keyof PluginParams>(name: LayerName) => {
|
|
27
|
-
// // set: (partial: DeepPartial<PluginParams[LayerName]>) => void
|
|
28
|
-
// update: (patch: DeepPartial<PluginParams[LayerName]>) => void
|
|
29
|
-
// replace: (full: PluginParams[LayerName]) => void
|
|
30
|
-
// show: () => void
|
|
31
|
-
// hide: () => void
|
|
32
|
-
// toggle: () => void
|
|
33
|
-
// }
|
|
34
|
-
destroy: () => void
|
|
35
|
-
constructor (params?: DeepPartial<PluginParams | AllLayerParams>) {
|
|
36
|
-
return createPlugin('canvas', config, params)
|
|
37
|
-
}
|
|
38
|
-
}
|
|
1
|
+
import type { DeepPartial, DefinePluginConfig, PluginEntity, ChartContext, ExtendableContext } from './types'
|
|
2
|
+
import { createPlugin } from './plugin/createPlugin'
|
|
3
|
+
|
|
4
|
+
export const defineCanvasPlugin = <
|
|
5
|
+
ExtendContext extends ExtendableContext,
|
|
6
|
+
PluginParams extends Record<string, any>,
|
|
7
|
+
AllLayerParams extends Record<string, any>,
|
|
8
|
+
>(config: DefinePluginConfig<ExtendContext, PluginParams, AllLayerParams>) => {
|
|
9
|
+
return class Plugin implements PluginEntity<'canvas', PluginParams, AllLayerParams> {
|
|
10
|
+
_name: string
|
|
11
|
+
_elementType: 'canvas'
|
|
12
|
+
_getId: () => string
|
|
13
|
+
_setId: (id: string) => void
|
|
14
|
+
_injectContext: (context: ChartContext<{}>) => void
|
|
15
|
+
show: (names: (keyof AllLayerParams) | (keyof AllLayerParams)[]) => void
|
|
16
|
+
showOnly: (names: (keyof AllLayerParams) | (keyof AllLayerParams)[]) => void
|
|
17
|
+
showAll: () => void
|
|
18
|
+
hide: (names: (keyof AllLayerParams) | (keyof AllLayerParams)[]) => void
|
|
19
|
+
hideAll: () => void
|
|
20
|
+
toggle: (names: (keyof AllLayerParams) | (keyof AllLayerParams)[]) => void
|
|
21
|
+
// setLayers: (partial: DeepPartial<PluginParams>) => void
|
|
22
|
+
getShownLayerNames: () => (keyof AllLayerParams)[]
|
|
23
|
+
updateParams: (patch: DeepPartial<PluginParams | AllLayerParams>) => void
|
|
24
|
+
forceReplaceParams: (full: PluginParams | AllLayerParams) => void
|
|
25
|
+
getParams: () => Readonly<PluginParams | AllLayerParams>
|
|
26
|
+
// layer: <LayerName extends keyof PluginParams>(name: LayerName) => {
|
|
27
|
+
// // set: (partial: DeepPartial<PluginParams[LayerName]>) => void
|
|
28
|
+
// update: (patch: DeepPartial<PluginParams[LayerName]>) => void
|
|
29
|
+
// replace: (full: PluginParams[LayerName]) => void
|
|
30
|
+
// show: () => void
|
|
31
|
+
// hide: () => void
|
|
32
|
+
// toggle: () => void
|
|
33
|
+
// }
|
|
34
|
+
destroy: () => void
|
|
35
|
+
constructor (params?: DeepPartial<PluginParams | AllLayerParams>) {
|
|
36
|
+
return createPlugin('canvas', config, params)
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
39
|
}
|
package/src/defineSVGLayer.ts
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import type { ChartContext, DefineLayerConfig, LayerEntity, ExtendableContext, LayerEnableProps } from "./types"
|
|
2
|
-
import { createLayer } from "./layer/createLayer"
|
|
3
|
-
|
|
4
|
-
export const defineSVGLayer = <
|
|
5
|
-
ExtendContext extends ExtendableContext,
|
|
6
|
-
PluginParams extends Record<string, any>,
|
|
7
|
-
LayerParams extends Record<string, any>,
|
|
8
|
-
>(config: DefineLayerConfig<'svg', ExtendContext, PluginParams, LayerParams>) => {
|
|
9
|
-
return class Layer implements LayerEntity<ExtendContext, PluginParams, LayerParams> {
|
|
10
|
-
_name: string
|
|
11
|
-
_defaultParams: LayerParams
|
|
12
|
-
_layerIndex: number
|
|
13
|
-
_initShow: boolean
|
|
14
|
-
_enable: (enableProps: LayerEnableProps<'svg', ExtendContext, PluginParams, LayerParams>) => void
|
|
15
|
-
_disable: () => void
|
|
16
|
-
_updateParams: (params: Partial<LayerParams>) => void
|
|
17
|
-
_forceReplaceParams: (params: LayerParams) => void
|
|
18
|
-
_getParams: () => Readonly<LayerParams>
|
|
19
|
-
_destroy: () => void
|
|
20
|
-
constructor () {
|
|
21
|
-
return createLayer<ExtendContext, PluginParams, LayerParams>('svg', config)
|
|
22
|
-
}
|
|
23
|
-
}
|
|
1
|
+
import type { ChartContext, DefineLayerConfig, LayerEntity, ExtendableContext, LayerEnableProps } from "./types"
|
|
2
|
+
import { createLayer } from "./layer/createLayer"
|
|
3
|
+
|
|
4
|
+
export const defineSVGLayer = <
|
|
5
|
+
ExtendContext extends ExtendableContext,
|
|
6
|
+
PluginParams extends Record<string, any>,
|
|
7
|
+
LayerParams extends Record<string, any>,
|
|
8
|
+
>(config: DefineLayerConfig<'svg', ExtendContext, PluginParams, LayerParams>) => {
|
|
9
|
+
return class Layer implements LayerEntity<ExtendContext, PluginParams, LayerParams> {
|
|
10
|
+
_name: string
|
|
11
|
+
_defaultParams: LayerParams
|
|
12
|
+
_layerIndex: number
|
|
13
|
+
_initShow: boolean
|
|
14
|
+
_enable: (enableProps: LayerEnableProps<'svg', ExtendContext, PluginParams, LayerParams>) => void
|
|
15
|
+
_disable: () => void
|
|
16
|
+
_updateParams: (params: Partial<LayerParams>) => void
|
|
17
|
+
_forceReplaceParams: (params: LayerParams) => void
|
|
18
|
+
_getParams: () => Readonly<LayerParams>
|
|
19
|
+
_destroy: () => void
|
|
20
|
+
constructor () {
|
|
21
|
+
return createLayer<ExtendContext, PluginParams, LayerParams>('svg', config)
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
24
|
}
|
package/src/defineSVGPlugin.ts
CHANGED
|
@@ -1,39 +1,39 @@
|
|
|
1
|
-
import type { DeepPartial, DefinePluginConfig, PluginEntity, ChartContext, ExtendableContext } from './types'
|
|
2
|
-
import { createPlugin } from './plugin/createPlugin'
|
|
3
|
-
|
|
4
|
-
export const defineSVGPlugin = <
|
|
5
|
-
ExtendContext extends ExtendableContext,
|
|
6
|
-
PluginParams extends Record<string, any>,
|
|
7
|
-
AllLayerParams extends Record<string, any>,
|
|
8
|
-
>(config: DefinePluginConfig<ExtendContext, PluginParams, AllLayerParams>) => {
|
|
9
|
-
return class Plugin implements PluginEntity<'svg', PluginParams, AllLayerParams> {
|
|
10
|
-
_name: string
|
|
11
|
-
_elementType: 'svg'
|
|
12
|
-
_getId: () => string
|
|
13
|
-
_setId: (id: string) => void
|
|
14
|
-
_injectContext: (context: ChartContext<{}>) => void
|
|
15
|
-
show: (names: (keyof AllLayerParams) | (keyof AllLayerParams)[]) => void
|
|
16
|
-
showOnly: (names: (keyof AllLayerParams) | (keyof AllLayerParams)[]) => void
|
|
17
|
-
showAll: () => void
|
|
18
|
-
hide: (names: (keyof AllLayerParams) | (keyof AllLayerParams)[]) => void
|
|
19
|
-
hideAll: () => void
|
|
20
|
-
toggle: (names: (keyof AllLayerParams) | (keyof AllLayerParams)[]) => void
|
|
21
|
-
// setLayers: (partial: DeepPartial<PluginParams>) => void
|
|
22
|
-
getShownLayerNames: () => (keyof AllLayerParams)[]
|
|
23
|
-
updateParams: (patch: DeepPartial<PluginParams | AllLayerParams>) => void
|
|
24
|
-
forceReplaceParams: (full: PluginParams | AllLayerParams) => void
|
|
25
|
-
getParams: () => Readonly<PluginParams | AllLayerParams>
|
|
26
|
-
// layer: <LayerName extends keyof PluginParams>(name: LayerName) => {
|
|
27
|
-
// // set: (partial: DeepPartial<PluginParams[LayerName]>) => void
|
|
28
|
-
// update: (patch: DeepPartial<PluginParams[LayerName]>) => void
|
|
29
|
-
// replace: (full: PluginParams[LayerName]) => void
|
|
30
|
-
// show: () => void
|
|
31
|
-
// hide: () => void
|
|
32
|
-
// toggle: () => void
|
|
33
|
-
// }
|
|
34
|
-
destroy: () => void
|
|
35
|
-
constructor (params?: DeepPartial<PluginParams | AllLayerParams>) {
|
|
36
|
-
return createPlugin('svg', config, params)
|
|
37
|
-
}
|
|
38
|
-
}
|
|
1
|
+
import type { DeepPartial, DefinePluginConfig, PluginEntity, ChartContext, ExtendableContext } from './types'
|
|
2
|
+
import { createPlugin } from './plugin/createPlugin'
|
|
3
|
+
|
|
4
|
+
export const defineSVGPlugin = <
|
|
5
|
+
ExtendContext extends ExtendableContext,
|
|
6
|
+
PluginParams extends Record<string, any>,
|
|
7
|
+
AllLayerParams extends Record<string, any>,
|
|
8
|
+
>(config: DefinePluginConfig<ExtendContext, PluginParams, AllLayerParams>) => {
|
|
9
|
+
return class Plugin implements PluginEntity<'svg', PluginParams, AllLayerParams> {
|
|
10
|
+
_name: string
|
|
11
|
+
_elementType: 'svg'
|
|
12
|
+
_getId: () => string
|
|
13
|
+
_setId: (id: string) => void
|
|
14
|
+
_injectContext: (context: ChartContext<{}>) => void
|
|
15
|
+
show: (names: (keyof AllLayerParams) | (keyof AllLayerParams)[]) => void
|
|
16
|
+
showOnly: (names: (keyof AllLayerParams) | (keyof AllLayerParams)[]) => void
|
|
17
|
+
showAll: () => void
|
|
18
|
+
hide: (names: (keyof AllLayerParams) | (keyof AllLayerParams)[]) => void
|
|
19
|
+
hideAll: () => void
|
|
20
|
+
toggle: (names: (keyof AllLayerParams) | (keyof AllLayerParams)[]) => void
|
|
21
|
+
// setLayers: (partial: DeepPartial<PluginParams>) => void
|
|
22
|
+
getShownLayerNames: () => (keyof AllLayerParams)[]
|
|
23
|
+
updateParams: (patch: DeepPartial<PluginParams | AllLayerParams>) => void
|
|
24
|
+
forceReplaceParams: (full: PluginParams | AllLayerParams) => void
|
|
25
|
+
getParams: () => Readonly<PluginParams | AllLayerParams>
|
|
26
|
+
// layer: <LayerName extends keyof PluginParams>(name: LayerName) => {
|
|
27
|
+
// // set: (partial: DeepPartial<PluginParams[LayerName]>) => void
|
|
28
|
+
// update: (patch: DeepPartial<PluginParams[LayerName]>) => void
|
|
29
|
+
// replace: (full: PluginParams[LayerName]) => void
|
|
30
|
+
// show: () => void
|
|
31
|
+
// hide: () => void
|
|
32
|
+
// toggle: () => void
|
|
33
|
+
// }
|
|
34
|
+
destroy: () => void
|
|
35
|
+
constructor (params?: DeepPartial<PluginParams | AllLayerParams>) {
|
|
36
|
+
return createPlugin('svg', config, params)
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
39
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
export { OrbCharts } from './OrbCharts'
|
|
3
|
-
export { defineSVGPlugin } from './defineSVGPlugin'
|
|
4
|
-
export { defineSVGLayer } from './defineSVGLayer'
|
|
5
|
-
export { defineCanvasPlugin } from './defineCanvasPlugin'
|
|
6
|
-
export { defineCanvasLayer } from './defineCanvasLayer'
|
|
7
|
-
export * from './types'
|
|
8
|
-
export * from './utils'
|
|
1
|
+
|
|
2
|
+
export { OrbCharts } from './OrbCharts'
|
|
3
|
+
export { defineSVGPlugin } from './defineSVGPlugin'
|
|
4
|
+
export { defineSVGLayer } from './defineSVGLayer'
|
|
5
|
+
export { defineCanvasPlugin } from './defineCanvasPlugin'
|
|
6
|
+
export { defineCanvasLayer } from './defineCanvasLayer'
|
|
7
|
+
export * from './types'
|
|
8
|
+
export * from './utils'
|