@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/Chart.ts
CHANGED
|
@@ -1,62 +1,62 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
DeepPartial,
|
|
3
|
-
ChartContext,
|
|
4
|
-
Encoding,
|
|
5
|
-
PluginEntity,
|
|
6
|
-
RawData,
|
|
7
|
-
Theme
|
|
8
|
-
} from './index'
|
|
9
|
-
|
|
10
|
-
export interface SizeConfig {
|
|
11
|
-
width: number | 'auto'
|
|
12
|
-
height: number | 'auto'
|
|
13
|
-
resizeDebounce: number
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
// export interface ChartDefaults {
|
|
17
|
-
// theme: Theme
|
|
18
|
-
// encoding: Encoding
|
|
19
|
-
// }
|
|
20
|
-
|
|
21
|
-
export interface ChartOptions {
|
|
22
|
-
size: SizeConfig
|
|
23
|
-
// defaults: ChartDefaults
|
|
24
|
-
theme: Theme
|
|
25
|
-
data: RawData
|
|
26
|
-
encoding: Encoding
|
|
27
|
-
plugins: PluginEntity<any, any, any>[]
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export interface PartialChartOptions {
|
|
31
|
-
size?: Partial<SizeConfig>
|
|
32
|
-
theme?: DeepPartial<Theme>
|
|
33
|
-
data?: RawData
|
|
34
|
-
encoding?: DeepPartial<Encoding>
|
|
35
|
-
plugins?: PluginEntity<any, any, any>[]
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export interface CreateChart {
|
|
39
|
-
(element: HTMLElement | Element, options?: PartialChartOptions): ChartEntity
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export interface ChartEntity {
|
|
43
|
-
// Commands
|
|
44
|
-
resize(sizeConfig: SizeConfig): void
|
|
45
|
-
setData(data: RawData): void // replace
|
|
46
|
-
// setEncoding(partial: Partial<Encoding>): void // deep-merge with default
|
|
47
|
-
updateEncoding(patch: DeepPartial<Encoding>): void // deep-merge with previous
|
|
48
|
-
forceReplaceEncoding(full: Encoding): void // replace
|
|
49
|
-
getEncoding(): Readonly<Encoding>
|
|
50
|
-
setPlugins(plugins: PluginEntity<any, any, any>[]): void // replace all
|
|
51
|
-
addPlugin(plugin: PluginEntity<any, any, any>): void
|
|
52
|
-
removePlugin(id: string): void
|
|
53
|
-
// setTheme(theme: Theme): void // replace all
|
|
54
|
-
updateTheme(patch: DeepPartial<Theme>): void // deep-merge with previous
|
|
55
|
-
forceReplaceTheme(full: Theme): void // replace all
|
|
56
|
-
getTheme(): Readonly<Theme>
|
|
57
|
-
destroy(): void;
|
|
58
|
-
|
|
59
|
-
// context
|
|
60
|
-
context: ChartContext<{}>
|
|
61
|
-
}
|
|
62
|
-
|
|
1
|
+
import type {
|
|
2
|
+
DeepPartial,
|
|
3
|
+
ChartContext,
|
|
4
|
+
Encoding,
|
|
5
|
+
PluginEntity,
|
|
6
|
+
RawData,
|
|
7
|
+
Theme
|
|
8
|
+
} from './index'
|
|
9
|
+
|
|
10
|
+
export interface SizeConfig {
|
|
11
|
+
width: number | 'auto'
|
|
12
|
+
height: number | 'auto'
|
|
13
|
+
resizeDebounce: number
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// export interface ChartDefaults {
|
|
17
|
+
// theme: Theme
|
|
18
|
+
// encoding: Encoding
|
|
19
|
+
// }
|
|
20
|
+
|
|
21
|
+
export interface ChartOptions {
|
|
22
|
+
size: SizeConfig
|
|
23
|
+
// defaults: ChartDefaults
|
|
24
|
+
theme: Theme
|
|
25
|
+
data: RawData
|
|
26
|
+
encoding: Encoding
|
|
27
|
+
plugins: PluginEntity<any, any, any>[]
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface PartialChartOptions {
|
|
31
|
+
size?: Partial<SizeConfig>
|
|
32
|
+
theme?: DeepPartial<Theme>
|
|
33
|
+
data?: RawData
|
|
34
|
+
encoding?: DeepPartial<Encoding>
|
|
35
|
+
plugins?: PluginEntity<any, any, any>[]
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface CreateChart {
|
|
39
|
+
(element: HTMLElement | Element, options?: PartialChartOptions): ChartEntity
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export interface ChartEntity {
|
|
43
|
+
// Commands
|
|
44
|
+
resize(sizeConfig: SizeConfig): void
|
|
45
|
+
setData(data: RawData): void // replace
|
|
46
|
+
// setEncoding(partial: Partial<Encoding>): void // deep-merge with default
|
|
47
|
+
updateEncoding(patch: DeepPartial<Encoding>): void // deep-merge with previous
|
|
48
|
+
forceReplaceEncoding(full: Encoding): void // replace
|
|
49
|
+
getEncoding(): Readonly<Encoding>
|
|
50
|
+
setPlugins(plugins: PluginEntity<any, any, any>[]): void // replace all
|
|
51
|
+
addPlugin(plugin: PluginEntity<any, any, any>): void
|
|
52
|
+
removePlugin(id: string): void
|
|
53
|
+
// setTheme(theme: Theme): void // replace all
|
|
54
|
+
updateTheme(patch: DeepPartial<Theme>): void // deep-merge with previous
|
|
55
|
+
forceReplaceTheme(full: Theme): void // replace all
|
|
56
|
+
getTheme(): Readonly<Theme>
|
|
57
|
+
destroy(): void;
|
|
58
|
+
|
|
59
|
+
// context
|
|
60
|
+
context: ChartContext<{}>
|
|
61
|
+
}
|
|
62
|
+
|
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
import type { Observable, Subject } from 'rxjs'
|
|
2
|
-
import type {
|
|
3
|
-
RawData,
|
|
4
|
-
Encoding,
|
|
5
|
-
ModelData,
|
|
6
|
-
PluginInfo,
|
|
7
|
-
Theme,
|
|
8
|
-
EventData,
|
|
9
|
-
LayerInfo,
|
|
10
|
-
} from './index'
|
|
11
|
-
|
|
12
|
-
export interface Size {
|
|
13
|
-
width: number
|
|
14
|
-
height: number
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
// 定義可擴展的 context 類型 - 只包含新增的欄位
|
|
18
|
-
export interface ExtendableContext {
|
|
19
|
-
// 只能添加新的欄位,不能修改現有的 ChartContext
|
|
20
|
-
[key: string]: Observable<any> | Subject<any> | Function | any
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export type ChartContext<ExtendContext extends ExtendableContext> = {
|
|
24
|
-
// svgSelection: d3.Selection<SVGGElement, unknown, HTMLElement, any>
|
|
25
|
-
// canvasSelection: d3.Selection<HTMLCanvasElement, unknown, HTMLElement, any>
|
|
26
|
-
root: HTMLElement | Element
|
|
27
|
-
svg: SVGElement | null
|
|
28
|
-
canvas: HTMLCanvasElement | null
|
|
29
|
-
// rawData$: Observable<RawData>
|
|
30
|
-
encoding$: Observable<Encoding>
|
|
31
|
-
seriesData$: Observable<ModelData<'series'>[]>
|
|
32
|
-
gridData$: Observable<ModelData<'grid'>[]>
|
|
33
|
-
multivariateData$: Observable<ModelData<'multivariate'>[]>
|
|
34
|
-
graphData$: Observable<ModelData<'graph'>[]>
|
|
35
|
-
treeData$: Observable<ModelData<'tree'>[]>
|
|
36
|
-
plugins$: Observable<readonly PluginInfo[]>
|
|
37
|
-
theme$: Observable<Theme>
|
|
38
|
-
event$: Observable<EventData>
|
|
39
|
-
eventTrigger$: Subject<EventData>
|
|
40
|
-
size$: Observable<Size>
|
|
41
|
-
_updateLayerElements: <ElementType extends "svg" | "canvas">(elementType: ElementType, fromPluginName: string, fetchLayerInfo: LayerInfo[]) => Record<string, ElementType extends "svg" ? SVGGElement : HTMLCanvasElement>
|
|
1
|
+
import type { Observable, Subject } from 'rxjs'
|
|
2
|
+
import type {
|
|
3
|
+
RawData,
|
|
4
|
+
Encoding,
|
|
5
|
+
ModelData,
|
|
6
|
+
PluginInfo,
|
|
7
|
+
Theme,
|
|
8
|
+
EventData,
|
|
9
|
+
LayerInfo,
|
|
10
|
+
} from './index'
|
|
11
|
+
|
|
12
|
+
export interface Size {
|
|
13
|
+
width: number
|
|
14
|
+
height: number
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// 定義可擴展的 context 類型 - 只包含新增的欄位
|
|
18
|
+
export interface ExtendableContext {
|
|
19
|
+
// 只能添加新的欄位,不能修改現有的 ChartContext
|
|
20
|
+
[key: string]: Observable<any> | Subject<any> | Function | any
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export type ChartContext<ExtendContext extends ExtendableContext> = {
|
|
24
|
+
// svgSelection: d3.Selection<SVGGElement, unknown, HTMLElement, any>
|
|
25
|
+
// canvasSelection: d3.Selection<HTMLCanvasElement, unknown, HTMLElement, any>
|
|
26
|
+
root: HTMLElement | Element
|
|
27
|
+
svg: SVGElement | null
|
|
28
|
+
canvas: HTMLCanvasElement | null
|
|
29
|
+
// rawData$: Observable<RawData>
|
|
30
|
+
encoding$: Observable<Encoding>
|
|
31
|
+
seriesData$: Observable<ModelData<'series'>[]>
|
|
32
|
+
gridData$: Observable<ModelData<'grid'>[]>
|
|
33
|
+
multivariateData$: Observable<ModelData<'multivariate'>[]>
|
|
34
|
+
graphData$: Observable<ModelData<'graph'>[]>
|
|
35
|
+
treeData$: Observable<ModelData<'tree'>[]>
|
|
36
|
+
plugins$: Observable<readonly PluginInfo[]>
|
|
37
|
+
theme$: Observable<Theme>
|
|
38
|
+
event$: Observable<EventData>
|
|
39
|
+
eventTrigger$: Subject<EventData>
|
|
40
|
+
size$: Observable<Size>
|
|
41
|
+
_updateLayerElements: <ElementType extends "svg" | "canvas">(elementType: ElementType, fromPluginName: string, fetchLayerInfo: LayerInfo[]) => Record<string, ElementType extends "svg" ? SVGGElement : HTMLCanvasElement>
|
|
42
42
|
} & ExtendContext
|
package/src/types/Common.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export type DeepPartial<T> = Partial<{
|
|
4
|
-
[P in keyof T]: DeepPartial<T[P]>
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
export type DeepPartial<T> = Partial<{
|
|
4
|
+
[P in keyof T]: DeepPartial<T[P]>
|
|
5
5
|
}>
|
package/src/types/Encoding.ts
CHANGED
|
@@ -1,43 +1,43 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export interface EncodingDataset {
|
|
5
|
-
from: string
|
|
6
|
-
sort: 'original' | 'alphabetical' | string[]
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export interface EncodingSeries {
|
|
10
|
-
from: string
|
|
11
|
-
sort: 'original' | 'alphabetical' | string[]
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export interface EncodingCategory {
|
|
15
|
-
from: string
|
|
16
|
-
sort: 'original' | 'alphabetical' | string[]
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export interface EncodingValue {
|
|
20
|
-
from: string
|
|
21
|
-
sort: 'original' | 'asc' | 'desc'
|
|
22
|
-
aggregate: 'sum' | 'mean' | 'median' | 'min' | 'max' | 'count' | 'none'
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export interface EncodingMultivariateItem {
|
|
26
|
-
from: string
|
|
27
|
-
name: string
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export type EncodingMultivariate = EncodingMultivariateItem[]
|
|
31
|
-
|
|
32
|
-
export interface EncodingColor {
|
|
33
|
-
from: 'index' | 'series' | 'category' | 'dataset'
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export interface Encoding {
|
|
37
|
-
dataset: EncodingDataset
|
|
38
|
-
series: EncodingSeries
|
|
39
|
-
category: EncodingCategory
|
|
40
|
-
value: EncodingValue
|
|
41
|
-
multivariate: EncodingMultivariate
|
|
42
|
-
color: EncodingColor
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
export interface EncodingDataset {
|
|
5
|
+
from: string
|
|
6
|
+
sort: 'original' | 'alphabetical' | string[]
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface EncodingSeries {
|
|
10
|
+
from: string
|
|
11
|
+
sort: 'original' | 'alphabetical' | string[]
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface EncodingCategory {
|
|
15
|
+
from: string
|
|
16
|
+
sort: 'original' | 'alphabetical' | string[]
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface EncodingValue {
|
|
20
|
+
from: string
|
|
21
|
+
sort: 'original' | 'asc' | 'desc'
|
|
22
|
+
aggregate: 'sum' | 'mean' | 'median' | 'min' | 'max' | 'count' | 'none'
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface EncodingMultivariateItem {
|
|
26
|
+
from: string
|
|
27
|
+
name: string
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export type EncodingMultivariate = EncodingMultivariateItem[]
|
|
31
|
+
|
|
32
|
+
export interface EncodingColor {
|
|
33
|
+
from: 'index' | 'series' | 'category' | 'dataset'
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export interface Encoding {
|
|
37
|
+
dataset: EncodingDataset
|
|
38
|
+
series: EncodingSeries
|
|
39
|
+
category: EncodingCategory
|
|
40
|
+
value: EncodingValue
|
|
41
|
+
multivariate: EncodingMultivariate
|
|
42
|
+
color: EncodingColor
|
|
43
43
|
}
|
package/src/types/Event.ts
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
ModelType,
|
|
3
|
-
RenderDatumBase
|
|
4
|
-
} from '../../../core/src/types/index'
|
|
5
|
-
|
|
6
|
-
export type EventType = 'click'
|
|
7
|
-
| 'mouseover'
|
|
8
|
-
| 'mousemove'
|
|
9
|
-
| 'mouseout'
|
|
10
|
-
| 'dragstart'
|
|
11
|
-
| 'drag'
|
|
12
|
-
| 'dragend'
|
|
13
|
-
// | 'resize'
|
|
14
|
-
| 'zoom'
|
|
15
|
-
| 'transitionMove'
|
|
16
|
-
| 'transitionEnd'
|
|
17
|
-
|
|
18
|
-
export interface EventData<T extends ModelType = ModelType, ExtendTypes extends Record<string, any> = {}> {
|
|
19
|
-
eventName: EventType
|
|
20
|
-
pluginName: string
|
|
21
|
-
layerName: string
|
|
22
|
-
target: RenderDatumBase<T, ExtendTypes> | null
|
|
23
|
-
data?: any
|
|
24
|
-
tween?: number
|
|
25
|
-
event?: Event
|
|
1
|
+
import type {
|
|
2
|
+
ModelType,
|
|
3
|
+
RenderDatumBase
|
|
4
|
+
} from '../../../core/src/types/index'
|
|
5
|
+
|
|
6
|
+
export type EventType = 'click'
|
|
7
|
+
| 'mouseover'
|
|
8
|
+
| 'mousemove'
|
|
9
|
+
| 'mouseout'
|
|
10
|
+
| 'dragstart'
|
|
11
|
+
| 'drag'
|
|
12
|
+
| 'dragend'
|
|
13
|
+
// | 'resize'
|
|
14
|
+
| 'zoom'
|
|
15
|
+
| 'transitionMove'
|
|
16
|
+
| 'transitionEnd'
|
|
17
|
+
|
|
18
|
+
export interface EventData<T extends ModelType = ModelType, ExtendTypes extends Record<string, any> = {}> {
|
|
19
|
+
eventName: EventType
|
|
20
|
+
pluginName: string
|
|
21
|
+
layerName: string
|
|
22
|
+
target: RenderDatumBase<T, ExtendTypes> | null
|
|
23
|
+
data?: any
|
|
24
|
+
tween?: number
|
|
25
|
+
event?: Event
|
|
26
26
|
}
|
package/src/types/Layers.ts
CHANGED
|
@@ -1,93 +1,93 @@
|
|
|
1
|
-
import type { Observable } from 'rxjs'
|
|
2
|
-
import type { DeepPartial, ChartContext, ExtendableContext, ValidatorResult } from './index'
|
|
3
|
-
|
|
4
|
-
// export type LayerParamsBase<LayerName extends string> = {
|
|
5
|
-
// [K in LayerName]: unknown
|
|
6
|
-
// }
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
// export type LayerParams<LayerName extends string, Params = any> = Record<LayerName, Params>
|
|
10
|
-
|
|
11
|
-
// export interface LayerContext<ExtendContext extends ExtendableContext = {}> {
|
|
12
|
-
// svgSelection: d3.Selection<SVGGElement, unknown, HTMLElement, any>
|
|
13
|
-
// canvasSelection: d3.Selection<HTMLCanvasElement, unknown, HTMLElement, any>
|
|
14
|
-
// name: string
|
|
15
|
-
// context: ChartContext<ExtendContext>
|
|
16
|
-
// }
|
|
17
|
-
|
|
18
|
-
// export type LayerContext<ExtendContext, LayerParams extends Record<string, any> = Record<string, any>> = ChartContext<ExtendContext> & {
|
|
19
|
-
// layerParams$: Observable<LayerParams>
|
|
20
|
-
// }
|
|
21
|
-
|
|
22
|
-
export interface LayerInfo {
|
|
23
|
-
pluginId: string
|
|
24
|
-
pluginName: string
|
|
25
|
-
layerName: string
|
|
26
|
-
layerIndex: number
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export interface SVGLayerEnableProps<ExtendContext extends ExtendableContext, PluginParams, LayerParams> {
|
|
30
|
-
context: ChartContext<ExtendContext>
|
|
31
|
-
svgG: SVGGElement
|
|
32
|
-
// canvas: HTMLCanvasElement
|
|
33
|
-
pluginParams$: Observable<PluginParams>
|
|
34
|
-
initLayerParams: DeepPartial<LayerParams>
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export interface CanvasLayerEnableProps<ExtendContext extends ExtendableContext, PluginParams, LayerParams> {
|
|
38
|
-
context: ChartContext<ExtendContext>
|
|
39
|
-
// svgG: SVGGElement
|
|
40
|
-
canvas: HTMLCanvasElement
|
|
41
|
-
pluginParams$: Observable<PluginParams>
|
|
42
|
-
initLayerParams: DeepPartial<LayerParams>
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export type LayerEnableProps<ElementType extends 'svg' | 'canvas', ExtendContext extends ExtendableContext, PluginParams, LayerParams> =
|
|
46
|
-
ElementType extends 'svg' ? SVGLayerEnableProps<ExtendContext, PluginParams, LayerParams> :
|
|
47
|
-
ElementType extends 'canvas' ? CanvasLayerEnableProps<ExtendContext, PluginParams, LayerParams> :
|
|
48
|
-
never
|
|
49
|
-
|
|
50
|
-
export interface SVGLayerSetupProps<ExtendContext extends ExtendableContext, PluginParams, LayerParams> {
|
|
51
|
-
context: ChartContext<ExtendContext>
|
|
52
|
-
svgG: SVGGElement
|
|
53
|
-
// canvas: HTMLCanvasElement
|
|
54
|
-
pluginParams$: Observable<PluginParams>
|
|
55
|
-
layerParams$: Observable<LayerParams>
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
export interface CanvasLayerSetupProps<ExtendContext extends ExtendableContext, PluginParams, LayerParams> {
|
|
59
|
-
context: ChartContext<ExtendContext>
|
|
60
|
-
// svgG: SVGGElement
|
|
61
|
-
canvas: HTMLCanvasElement
|
|
62
|
-
pluginParams$: Observable<PluginParams>
|
|
63
|
-
layerParams$: Observable<LayerParams>
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
export type LayerSetupProps<ElementType extends 'svg' | 'canvas', ExtendContext extends ExtendableContext, PluginParams, LayerParams> =
|
|
67
|
-
ElementType extends 'svg' ? SVGLayerSetupProps<ExtendContext, PluginParams, LayerParams> :
|
|
68
|
-
ElementType extends 'canvas' ? CanvasLayerSetupProps<ExtendContext, PluginParams, LayerParams> :
|
|
69
|
-
never
|
|
70
|
-
|
|
71
|
-
export interface DefineLayerConfig<ElementType extends 'svg' | 'canvas', ExtendContext extends ExtendableContext, PluginParams extends Record<string, any>, LayerParams extends Record<string, any>> {
|
|
72
|
-
name: string
|
|
73
|
-
defaultParams: LayerParams
|
|
74
|
-
layerIndex: number
|
|
75
|
-
initShow: boolean
|
|
76
|
-
validator?: (params: DeepPartial<LayerParams>) => ValidatorResult
|
|
77
|
-
setup: (setupProps: LayerSetupProps<ElementType, ExtendContext, PluginParams, LayerParams>) => () => void
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
export interface LayerEntity<ExtendContext extends ExtendableContext, PluginParams, LayerParams> {
|
|
81
|
-
readonly _name: string
|
|
82
|
-
readonly _defaultParams: LayerParams
|
|
83
|
-
readonly _layerIndex: number
|
|
84
|
-
readonly _initShow: boolean
|
|
85
|
-
// _enable(el: { svg: SVGSVGElement; canvas: HTMLCanvasElement }, context: ChartContext<ExtendContext>): void
|
|
86
|
-
_enable(enableProps: LayerEnableProps<'svg' | 'canvas', ExtendContext, PluginParams, LayerParams>): void
|
|
87
|
-
_disable(): void
|
|
88
|
-
// _setParams(params: DeepPartial<LayerParams>): void
|
|
89
|
-
_updateParams(params: DeepPartial<LayerParams>): void
|
|
90
|
-
_forceReplaceParams(params: LayerParams): void
|
|
91
|
-
_getParams: () => LayerParams
|
|
92
|
-
_destroy(): void
|
|
1
|
+
import type { Observable } from 'rxjs'
|
|
2
|
+
import type { DeepPartial, ChartContext, ExtendableContext, ValidatorResult } from './index'
|
|
3
|
+
|
|
4
|
+
// export type LayerParamsBase<LayerName extends string> = {
|
|
5
|
+
// [K in LayerName]: unknown
|
|
6
|
+
// }
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
// export type LayerParams<LayerName extends string, Params = any> = Record<LayerName, Params>
|
|
10
|
+
|
|
11
|
+
// export interface LayerContext<ExtendContext extends ExtendableContext = {}> {
|
|
12
|
+
// svgSelection: d3.Selection<SVGGElement, unknown, HTMLElement, any>
|
|
13
|
+
// canvasSelection: d3.Selection<HTMLCanvasElement, unknown, HTMLElement, any>
|
|
14
|
+
// name: string
|
|
15
|
+
// context: ChartContext<ExtendContext>
|
|
16
|
+
// }
|
|
17
|
+
|
|
18
|
+
// export type LayerContext<ExtendContext, LayerParams extends Record<string, any> = Record<string, any>> = ChartContext<ExtendContext> & {
|
|
19
|
+
// layerParams$: Observable<LayerParams>
|
|
20
|
+
// }
|
|
21
|
+
|
|
22
|
+
export interface LayerInfo {
|
|
23
|
+
pluginId: string
|
|
24
|
+
pluginName: string
|
|
25
|
+
layerName: string
|
|
26
|
+
layerIndex: number
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface SVGLayerEnableProps<ExtendContext extends ExtendableContext, PluginParams, LayerParams> {
|
|
30
|
+
context: ChartContext<ExtendContext>
|
|
31
|
+
svgG: SVGGElement
|
|
32
|
+
// canvas: HTMLCanvasElement
|
|
33
|
+
pluginParams$: Observable<PluginParams>
|
|
34
|
+
initLayerParams: DeepPartial<LayerParams>
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export interface CanvasLayerEnableProps<ExtendContext extends ExtendableContext, PluginParams, LayerParams> {
|
|
38
|
+
context: ChartContext<ExtendContext>
|
|
39
|
+
// svgG: SVGGElement
|
|
40
|
+
canvas: HTMLCanvasElement
|
|
41
|
+
pluginParams$: Observable<PluginParams>
|
|
42
|
+
initLayerParams: DeepPartial<LayerParams>
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export type LayerEnableProps<ElementType extends 'svg' | 'canvas', ExtendContext extends ExtendableContext, PluginParams, LayerParams> =
|
|
46
|
+
ElementType extends 'svg' ? SVGLayerEnableProps<ExtendContext, PluginParams, LayerParams> :
|
|
47
|
+
ElementType extends 'canvas' ? CanvasLayerEnableProps<ExtendContext, PluginParams, LayerParams> :
|
|
48
|
+
never
|
|
49
|
+
|
|
50
|
+
export interface SVGLayerSetupProps<ExtendContext extends ExtendableContext, PluginParams, LayerParams> {
|
|
51
|
+
context: ChartContext<ExtendContext>
|
|
52
|
+
svgG: SVGGElement
|
|
53
|
+
// canvas: HTMLCanvasElement
|
|
54
|
+
pluginParams$: Observable<PluginParams>
|
|
55
|
+
layerParams$: Observable<LayerParams>
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export interface CanvasLayerSetupProps<ExtendContext extends ExtendableContext, PluginParams, LayerParams> {
|
|
59
|
+
context: ChartContext<ExtendContext>
|
|
60
|
+
// svgG: SVGGElement
|
|
61
|
+
canvas: HTMLCanvasElement
|
|
62
|
+
pluginParams$: Observable<PluginParams>
|
|
63
|
+
layerParams$: Observable<LayerParams>
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export type LayerSetupProps<ElementType extends 'svg' | 'canvas', ExtendContext extends ExtendableContext, PluginParams, LayerParams> =
|
|
67
|
+
ElementType extends 'svg' ? SVGLayerSetupProps<ExtendContext, PluginParams, LayerParams> :
|
|
68
|
+
ElementType extends 'canvas' ? CanvasLayerSetupProps<ExtendContext, PluginParams, LayerParams> :
|
|
69
|
+
never
|
|
70
|
+
|
|
71
|
+
export interface DefineLayerConfig<ElementType extends 'svg' | 'canvas', ExtendContext extends ExtendableContext, PluginParams extends Record<string, any>, LayerParams extends Record<string, any>> {
|
|
72
|
+
name: string
|
|
73
|
+
defaultParams: LayerParams
|
|
74
|
+
layerIndex: number
|
|
75
|
+
initShow: boolean
|
|
76
|
+
validator?: (params: DeepPartial<LayerParams>) => ValidatorResult
|
|
77
|
+
setup: (setupProps: LayerSetupProps<ElementType, ExtendContext, PluginParams, LayerParams>) => () => void
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export interface LayerEntity<ExtendContext extends ExtendableContext, PluginParams, LayerParams> {
|
|
81
|
+
readonly _name: string
|
|
82
|
+
readonly _defaultParams: LayerParams
|
|
83
|
+
readonly _layerIndex: number
|
|
84
|
+
readonly _initShow: boolean
|
|
85
|
+
// _enable(el: { svg: SVGSVGElement; canvas: HTMLCanvasElement }, context: ChartContext<ExtendContext>): void
|
|
86
|
+
_enable(enableProps: LayerEnableProps<'svg' | 'canvas', ExtendContext, PluginParams, LayerParams>): void
|
|
87
|
+
_disable(): void
|
|
88
|
+
// _setParams(params: DeepPartial<LayerParams>): void
|
|
89
|
+
_updateParams(params: DeepPartial<LayerParams>): void
|
|
90
|
+
_forceReplaceParams(params: LayerParams): void
|
|
91
|
+
_getParams: () => LayerParams
|
|
92
|
+
_destroy(): void
|
|
93
93
|
}
|