@orbcharts/core 3.0.0-alpha.40 → 3.0.0-alpha.42
Sign up to get free protection for your applications and to get access to all the features.
- package/LICENSE +200 -200
- package/dist/orbcharts-core.es.js +1152 -1124
- package/dist/orbcharts-core.umd.js +2 -2
- package/dist/src/types/ChartParams.d.ts +1 -1
- package/dist/src/types/ContextObserverGrid.d.ts +1 -0
- package/dist/src/types/ContextObserverMultiGrid.d.ts +1 -0
- package/dist/src/types/ContextObserverSeries.d.ts +1 -0
- package/dist/src/types/ContextObserverTree.d.ts +1 -0
- package/dist/src/utils/observables.d.ts +1 -0
- package/package.json +41 -41
- package/src/AbstractChart.ts +48 -48
- package/src/GridChart.ts +20 -20
- package/src/MultiGridChart.ts +20 -20
- package/src/MultiValueChart.ts +20 -20
- package/src/RelationshipChart.ts +20 -20
- package/src/SeriesChart.ts +20 -20
- package/src/TreeChart.ts +20 -20
- package/src/base/createBaseChart.ts +367 -367
- package/src/base/createBasePlugin.ts +89 -89
- package/src/defaults.ts +248 -247
- 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/computeGridData.ts +205 -205
- package/src/grid/createGridContextObserver.ts +130 -124
- package/src/grid/gridObservables.ts +486 -486
- package/src/index.ts +21 -21
- package/src/multiGrid/computeMultiGridData.ts +173 -173
- package/src/multiGrid/createMultiGridContextObserver.ts +40 -34
- package/src/multiGrid/multiGridObservables.ts +285 -285
- package/src/multiValue/computeMultiValueData.ts +136 -136
- package/src/multiValue/createMultiValueContextObserver.ts +12 -12
- package/src/relationship/computeRelationshipData.ts +106 -106
- package/src/relationship/createRelationshipContextObserver.ts +12 -12
- package/src/series/computeSeriesData.ts +153 -153
- package/src/series/createSeriesContextObserver.ts +38 -33
- package/src/series/seriesObservables.ts +23 -23
- package/src/tree/computeTreeData.ts +128 -128
- package/src/tree/createTreeContextObserver.ts +61 -56
- package/src/tree/treeObservables.ts +94 -94
- package/src/types/Chart.ts +48 -48
- package/src/types/ChartParams.ts +51 -51
- package/src/types/ComputedData.ts +82 -82
- package/src/types/ComputedDataGrid.ts +13 -13
- package/src/types/ComputedDataMultiGrid.ts +2 -2
- package/src/types/ComputedDataMultiValue.ts +9 -9
- package/src/types/ComputedDataRelationship.ts +19 -19
- package/src/types/ComputedDataSeries.ts +7 -7
- package/src/types/ComputedDataTree.ts +19 -19
- package/src/types/ContextObserver.ts +38 -38
- package/src/types/ContextObserverGrid.ts +33 -33
- package/src/types/ContextObserverMultiGrid.ts +28 -27
- package/src/types/ContextObserverMultiValue.ts +4 -4
- package/src/types/ContextObserverRelationship.ts +4 -4
- package/src/types/ContextObserverSeries.ts +8 -7
- package/src/types/ContextObserverTree.ts +11 -10
- package/src/types/ContextSubject.ts +18 -18
- package/src/types/Data.ts +45 -45
- package/src/types/DataFormatter.ts +95 -95
- package/src/types/DataFormatterGrid.ts +55 -55
- package/src/types/DataFormatterMultiGrid.ts +42 -42
- package/src/types/DataFormatterMultiValue.ts +20 -20
- package/src/types/DataFormatterRelationship.ts +22 -22
- package/src/types/DataFormatterSeries.ts +29 -29
- package/src/types/DataFormatterTree.ts +12 -12
- package/src/types/DataGrid.ts +11 -11
- package/src/types/DataMultiGrid.ts +6 -6
- package/src/types/DataMultiValue.ts +12 -12
- package/src/types/DataRelationship.ts +27 -27
- package/src/types/DataSeries.ts +11 -11
- package/src/types/DataTree.ts +20 -20
- package/src/types/Event.ts +153 -153
- package/src/types/Layout.ts +11 -11
- package/src/types/Padding.ts +5 -5
- package/src/types/Plugin.ts +60 -60
- package/src/types/TransformData.ts +7 -7
- package/src/types/index.ts +37 -37
- package/src/utils/commonUtils.ts +50 -50
- package/src/utils/d3Utils.ts +89 -89
- package/src/utils/index.ts +4 -4
- package/src/utils/observables.ts +202 -181
- package/src/utils/orbchartsUtils.ts +253 -253
- package/tsconfig.json +13 -13
- package/vite.config.js +44 -44
@@ -1,89 +1,89 @@
|
|
1
|
-
import { takeUntil, map, shareReplay, startWith, Subject, Observable } from 'rxjs'
|
2
|
-
import type { ChartType, CreateBasePlugin, PluginInitFn, PluginContext } from '../types'
|
3
|
-
import { mergeOptionsWithDefault } from '../utils'
|
4
|
-
|
5
|
-
// 建立plugin實例
|
6
|
-
function createPlugin <T extends ChartType, PluginName, PluginParams>({ name, defaultParams, initFn }: {
|
7
|
-
name: PluginName
|
8
|
-
defaultParams: PluginParams
|
9
|
-
initFn: PluginInitFn<T, PluginName, PluginParams>
|
10
|
-
}) {
|
11
|
-
|
12
|
-
const destroy$ = new Subject()
|
13
|
-
const params$: Subject<Partial<typeof defaultParams>> = new Subject()
|
14
|
-
const StoreMap = new WeakMap() // 避免memory leak
|
15
|
-
let pluginDestroyFn = () => {}
|
16
|
-
let pluginContext: PluginContext<T, PluginName, PluginParams> | undefined
|
17
|
-
let mergedDefaultParams: PluginParams = defaultParams
|
18
|
-
|
19
|
-
// 建立plugin實例
|
20
|
-
return {
|
21
|
-
params$,
|
22
|
-
name,
|
23
|
-
defaultParams,
|
24
|
-
init () {
|
25
|
-
if (!pluginContext) {
|
26
|
-
return
|
27
|
-
}
|
28
|
-
// 執行
|
29
|
-
pluginDestroyFn = (initFn(pluginContext) ?? (() => {})) // plugin執行會回傳destroy函式
|
30
|
-
StoreMap.set(pluginContext.selection, pluginContext)
|
31
|
-
},
|
32
|
-
destroy () {
|
33
|
-
pluginDestroyFn()
|
34
|
-
if (pluginContext) {
|
35
|
-
pluginContext.selection.remove()
|
36
|
-
pluginContext = undefined
|
37
|
-
}
|
38
|
-
destroy$.next(undefined)
|
39
|
-
},
|
40
|
-
setPresetParams: (presetParams: Partial<PluginParams>) => {
|
41
|
-
mergedDefaultParams = mergeOptionsWithDefault(presetParams, defaultParams)
|
42
|
-
},
|
43
|
-
setContext: (_pluginContext: PluginContext<T, PluginName, PluginParams>) => {
|
44
|
-
pluginContext = _pluginContext
|
45
|
-
pluginContext.observer.fullParams$ = params$
|
46
|
-
.pipe(
|
47
|
-
takeUntil(destroy$),
|
48
|
-
startWith({}),
|
49
|
-
map(d => mergeOptionsWithDefault(d, mergedDefaultParams)),
|
50
|
-
shareReplay(1),
|
51
|
-
)
|
52
|
-
}
|
53
|
-
}
|
54
|
-
}
|
55
|
-
|
56
|
-
// 建立plugin類別
|
57
|
-
export const createBasePlugin: CreateBasePlugin = <T extends ChartType>() => {
|
58
|
-
|
59
|
-
// 定義plugin
|
60
|
-
return function definePlugin<PluginName, PluginParams>(name: PluginName, defaultParams: PluginParams) {
|
61
|
-
|
62
|
-
// 定義plugin的初始化function
|
63
|
-
return function definePluginInitFn (initFn: PluginInitFn<T, PluginName, PluginParams>) {
|
64
|
-
|
65
|
-
return class Plugin {
|
66
|
-
params$: Subject<Partial<PluginParams>>
|
67
|
-
name: PluginName
|
68
|
-
defaultParams: PluginParams
|
69
|
-
// presetParams: Partial<PluginParams>
|
70
|
-
init: () => void
|
71
|
-
destroy: () => void
|
72
|
-
setPresetParams: (presetParams: Partial<PluginParams>) => void
|
73
|
-
setContext: (pluginContext: PluginContext<T, PluginName, PluginParams>) => void
|
74
|
-
constructor () {
|
75
|
-
const pluginEntity = createPlugin<T, PluginName, PluginParams>({ name, defaultParams, initFn })
|
76
|
-
|
77
|
-
this.params$ = pluginEntity.params$
|
78
|
-
this.name = pluginEntity.name
|
79
|
-
this.defaultParams = pluginEntity.defaultParams
|
80
|
-
// this.presetParams = pluginEntity.presetParams
|
81
|
-
this.init = pluginEntity.init
|
82
|
-
this.destroy = pluginEntity.destroy
|
83
|
-
this.setPresetParams = pluginEntity.setPresetParams
|
84
|
-
this.setContext = pluginEntity.setContext
|
85
|
-
}
|
86
|
-
}
|
87
|
-
}
|
88
|
-
}
|
89
|
-
}
|
1
|
+
import { takeUntil, map, shareReplay, startWith, Subject, Observable } from 'rxjs'
|
2
|
+
import type { ChartType, CreateBasePlugin, PluginInitFn, PluginContext } from '../types'
|
3
|
+
import { mergeOptionsWithDefault } from '../utils'
|
4
|
+
|
5
|
+
// 建立plugin實例
|
6
|
+
function createPlugin <T extends ChartType, PluginName, PluginParams>({ name, defaultParams, initFn }: {
|
7
|
+
name: PluginName
|
8
|
+
defaultParams: PluginParams
|
9
|
+
initFn: PluginInitFn<T, PluginName, PluginParams>
|
10
|
+
}) {
|
11
|
+
|
12
|
+
const destroy$ = new Subject()
|
13
|
+
const params$: Subject<Partial<typeof defaultParams>> = new Subject()
|
14
|
+
const StoreMap = new WeakMap() // 避免memory leak
|
15
|
+
let pluginDestroyFn = () => {}
|
16
|
+
let pluginContext: PluginContext<T, PluginName, PluginParams> | undefined
|
17
|
+
let mergedDefaultParams: PluginParams = defaultParams
|
18
|
+
|
19
|
+
// 建立plugin實例
|
20
|
+
return {
|
21
|
+
params$,
|
22
|
+
name,
|
23
|
+
defaultParams,
|
24
|
+
init () {
|
25
|
+
if (!pluginContext) {
|
26
|
+
return
|
27
|
+
}
|
28
|
+
// 執行
|
29
|
+
pluginDestroyFn = (initFn(pluginContext) ?? (() => {})) // plugin執行會回傳destroy函式
|
30
|
+
StoreMap.set(pluginContext.selection, pluginContext)
|
31
|
+
},
|
32
|
+
destroy () {
|
33
|
+
pluginDestroyFn()
|
34
|
+
if (pluginContext) {
|
35
|
+
pluginContext.selection.remove()
|
36
|
+
pluginContext = undefined
|
37
|
+
}
|
38
|
+
destroy$.next(undefined)
|
39
|
+
},
|
40
|
+
setPresetParams: (presetParams: Partial<PluginParams>) => {
|
41
|
+
mergedDefaultParams = mergeOptionsWithDefault(presetParams, defaultParams)
|
42
|
+
},
|
43
|
+
setContext: (_pluginContext: PluginContext<T, PluginName, PluginParams>) => {
|
44
|
+
pluginContext = _pluginContext
|
45
|
+
pluginContext.observer.fullParams$ = params$
|
46
|
+
.pipe(
|
47
|
+
takeUntil(destroy$),
|
48
|
+
startWith({}),
|
49
|
+
map(d => mergeOptionsWithDefault(d, mergedDefaultParams)),
|
50
|
+
shareReplay(1),
|
51
|
+
)
|
52
|
+
}
|
53
|
+
}
|
54
|
+
}
|
55
|
+
|
56
|
+
// 建立plugin類別
|
57
|
+
export const createBasePlugin: CreateBasePlugin = <T extends ChartType>() => {
|
58
|
+
|
59
|
+
// 定義plugin
|
60
|
+
return function definePlugin<PluginName, PluginParams>(name: PluginName, defaultParams: PluginParams) {
|
61
|
+
|
62
|
+
// 定義plugin的初始化function
|
63
|
+
return function definePluginInitFn (initFn: PluginInitFn<T, PluginName, PluginParams>) {
|
64
|
+
|
65
|
+
return class Plugin {
|
66
|
+
params$: Subject<Partial<PluginParams>>
|
67
|
+
name: PluginName
|
68
|
+
defaultParams: PluginParams
|
69
|
+
// presetParams: Partial<PluginParams>
|
70
|
+
init: () => void
|
71
|
+
destroy: () => void
|
72
|
+
setPresetParams: (presetParams: Partial<PluginParams>) => void
|
73
|
+
setContext: (pluginContext: PluginContext<T, PluginName, PluginParams>) => void
|
74
|
+
constructor () {
|
75
|
+
const pluginEntity = createPlugin<T, PluginName, PluginParams>({ name, defaultParams, initFn })
|
76
|
+
|
77
|
+
this.params$ = pluginEntity.params$
|
78
|
+
this.name = pluginEntity.name
|
79
|
+
this.defaultParams = pluginEntity.defaultParams
|
80
|
+
// this.presetParams = pluginEntity.presetParams
|
81
|
+
this.init = pluginEntity.init
|
82
|
+
this.destroy = pluginEntity.destroy
|
83
|
+
this.setPresetParams = pluginEntity.setPresetParams
|
84
|
+
this.setContext = pluginEntity.setContext
|
85
|
+
}
|
86
|
+
}
|
87
|
+
}
|
88
|
+
}
|
89
|
+
}
|