@orbcharts/core 3.0.0-alpha.48 → 3.0.0-alpha.49
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 +3 -2
- package/dist/orbcharts-core.umd.js +1 -1
- package/dist/src/types/Chart.d.ts +10 -12
- 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 +369 -368
- package/src/base/createBasePlugin.ts +95 -95
- package/src/defaults.ts +220 -220
- 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 +134 -134
- package/src/grid/createGridContextObserver.ts +155 -155
- package/src/grid/gridObservables.ts +600 -600
- package/src/index.ts +21 -21
- package/src/multiGrid/computeMultiGridData.ts +130 -130
- package/src/multiGrid/createMultiGridContextObserver.ts +40 -40
- package/src/multiGrid/multiGridObservables.ts +364 -364
- package/src/multiValue/computeMultiValueData.ts +143 -143
- package/src/multiValue/createMultiValueContextObserver.ts +12 -12
- package/src/relationship/computeRelationshipData.ts +118 -118
- package/src/relationship/createRelationshipContextObserver.ts +12 -12
- package/src/series/computeSeriesData.ts +90 -90
- package/src/series/createSeriesContextObserver.ts +93 -93
- package/src/series/seriesObservables.ts +175 -175
- package/src/tree/computeTreeData.ts +131 -131
- package/src/tree/createTreeContextObserver.ts +61 -61
- package/src/tree/treeObservables.ts +94 -94
- package/src/types/Chart.ts +50 -48
- package/src/types/ChartParams.ts +51 -51
- package/src/types/ComputedData.ts +83 -83
- 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 +42 -42
- package/src/types/ContextObserverMultiGrid.ts +15 -15
- package/src/types/ContextObserverMultiValue.ts +4 -4
- package/src/types/ContextObserverRelationship.ts +4 -4
- package/src/types/ContextObserverSeries.ts +29 -29
- package/src/types/ContextObserverTree.ts +11 -11
- package/src/types/ContextSubject.ts +18 -18
- package/src/types/Data.ts +45 -45
- package/src/types/DataFormatter.ts +74 -74
- package/src/types/DataFormatterGrid.ts +67 -67
- package/src/types/DataFormatterMultiGrid.ts +44 -44
- package/src/types/DataFormatterMultiValue.ts +23 -23
- package/src/types/DataFormatterRelationship.ts +25 -25
- package/src/types/DataFormatterSeries.ts +20 -20
- 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 +201 -201
- package/src/utils/orbchartsUtils.ts +349 -349
- package/tsconfig.json +13 -13
- package/vite.config.js +44 -44
@@ -1,95 +1,95 @@
|
|
1
|
-
import { of, takeUntil, map, switchMap, shareReplay, startWith, Subject, BehaviorSubject, 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 EntityWeakMap = new WeakMap() // <selection, pluginEntity> 避免只移除selection而沒回收pluginEntity的memory leak
|
14
|
-
let pluginDestroyFn = () => {}
|
15
|
-
let pluginContext: PluginContext<T, PluginName, PluginParams> | undefined
|
16
|
-
const mergedDefaultParams$ = new BehaviorSubject(defaultParams)
|
17
|
-
const params$: Subject<Partial<typeof defaultParams>> = new BehaviorSubject({})
|
18
|
-
const fullParams$ = mergedDefaultParams$.pipe(
|
19
|
-
switchMap(mergedDefaultParams => {
|
20
|
-
return params$.pipe(
|
21
|
-
takeUntil(destroy$),
|
22
|
-
map(d => mergeOptionsWithDefault(d, mergedDefaultParams)),
|
23
|
-
)
|
24
|
-
}),
|
25
|
-
shareReplay(1)
|
26
|
-
)
|
27
|
-
|
28
|
-
// 建立plugin實例
|
29
|
-
const pluginEntity = {
|
30
|
-
params$,
|
31
|
-
name,
|
32
|
-
defaultParams,
|
33
|
-
init () {
|
34
|
-
if (!pluginContext) {
|
35
|
-
return
|
36
|
-
}
|
37
|
-
// 執行
|
38
|
-
pluginDestroyFn = (initFn(pluginContext) ?? (() => {})) // plugin執行會回傳destroy函式
|
39
|
-
EntityWeakMap.set(pluginContext.selection, pluginContext)
|
40
|
-
},
|
41
|
-
destroy () {
|
42
|
-
pluginDestroyFn()
|
43
|
-
if (pluginContext) {
|
44
|
-
pluginContext.selection.remove()
|
45
|
-
pluginContext = undefined
|
46
|
-
}
|
47
|
-
destroy$.next(undefined)
|
48
|
-
},
|
49
|
-
setPresetParams: (presetParams: Partial<PluginParams>) => {
|
50
|
-
mergedDefaultParams$.next(mergeOptionsWithDefault(presetParams, defaultParams))
|
51
|
-
|
52
|
-
},
|
53
|
-
setContext: (_pluginContext: PluginContext<T, PluginName, PluginParams>) => {
|
54
|
-
pluginContext = _pluginContext
|
55
|
-
pluginContext.observer.fullParams$ = fullParams$
|
56
|
-
}
|
57
|
-
}
|
58
|
-
|
59
|
-
return pluginEntity
|
60
|
-
}
|
61
|
-
|
62
|
-
// 建立plugin類別
|
63
|
-
export const createBasePlugin: CreateBasePlugin = <T extends ChartType>() => {
|
64
|
-
|
65
|
-
// 定義plugin
|
66
|
-
return function definePlugin<PluginName, PluginParams>(name: PluginName, defaultParams: PluginParams) {
|
67
|
-
|
68
|
-
// 定義plugin的初始化function
|
69
|
-
return function definePluginInitFn (initFn: PluginInitFn<T, PluginName, PluginParams>) {
|
70
|
-
|
71
|
-
return class Plugin {
|
72
|
-
params$: Subject<Partial<PluginParams>>
|
73
|
-
name: PluginName
|
74
|
-
defaultParams: PluginParams
|
75
|
-
// presetParams: Partial<PluginParams>
|
76
|
-
init: () => void
|
77
|
-
destroy: () => void
|
78
|
-
setPresetParams: (presetParams: Partial<PluginParams>) => void
|
79
|
-
setContext: (pluginContext: PluginContext<T, PluginName, PluginParams>) => void
|
80
|
-
constructor () {
|
81
|
-
const pluginEntity = createPlugin<T, PluginName, PluginParams>({ name, defaultParams, initFn })
|
82
|
-
|
83
|
-
this.params$ = pluginEntity.params$
|
84
|
-
this.name = pluginEntity.name
|
85
|
-
this.defaultParams = pluginEntity.defaultParams
|
86
|
-
// this.presetParams = pluginEntity.presetParams
|
87
|
-
this.init = pluginEntity.init
|
88
|
-
this.destroy = pluginEntity.destroy
|
89
|
-
this.setPresetParams = pluginEntity.setPresetParams
|
90
|
-
this.setContext = pluginEntity.setContext
|
91
|
-
}
|
92
|
-
}
|
93
|
-
}
|
94
|
-
}
|
95
|
-
}
|
1
|
+
import { of, takeUntil, map, switchMap, shareReplay, startWith, Subject, BehaviorSubject, 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 EntityWeakMap = new WeakMap() // <selection, pluginEntity> 避免只移除selection而沒回收pluginEntity的memory leak
|
14
|
+
let pluginDestroyFn = () => {}
|
15
|
+
let pluginContext: PluginContext<T, PluginName, PluginParams> | undefined
|
16
|
+
const mergedDefaultParams$ = new BehaviorSubject(defaultParams)
|
17
|
+
const params$: Subject<Partial<typeof defaultParams>> = new BehaviorSubject({})
|
18
|
+
const fullParams$ = mergedDefaultParams$.pipe(
|
19
|
+
switchMap(mergedDefaultParams => {
|
20
|
+
return params$.pipe(
|
21
|
+
takeUntil(destroy$),
|
22
|
+
map(d => mergeOptionsWithDefault(d, mergedDefaultParams)),
|
23
|
+
)
|
24
|
+
}),
|
25
|
+
shareReplay(1)
|
26
|
+
)
|
27
|
+
|
28
|
+
// 建立plugin實例
|
29
|
+
const pluginEntity = {
|
30
|
+
params$,
|
31
|
+
name,
|
32
|
+
defaultParams,
|
33
|
+
init () {
|
34
|
+
if (!pluginContext) {
|
35
|
+
return
|
36
|
+
}
|
37
|
+
// 執行
|
38
|
+
pluginDestroyFn = (initFn(pluginContext) ?? (() => {})) // plugin執行會回傳destroy函式
|
39
|
+
EntityWeakMap.set(pluginContext.selection, pluginContext)
|
40
|
+
},
|
41
|
+
destroy () {
|
42
|
+
pluginDestroyFn()
|
43
|
+
if (pluginContext) {
|
44
|
+
pluginContext.selection.remove()
|
45
|
+
pluginContext = undefined
|
46
|
+
}
|
47
|
+
destroy$.next(undefined)
|
48
|
+
},
|
49
|
+
setPresetParams: (presetParams: Partial<PluginParams>) => {
|
50
|
+
mergedDefaultParams$.next(mergeOptionsWithDefault(presetParams, defaultParams))
|
51
|
+
|
52
|
+
},
|
53
|
+
setContext: (_pluginContext: PluginContext<T, PluginName, PluginParams>) => {
|
54
|
+
pluginContext = _pluginContext
|
55
|
+
pluginContext.observer.fullParams$ = fullParams$
|
56
|
+
}
|
57
|
+
}
|
58
|
+
|
59
|
+
return pluginEntity
|
60
|
+
}
|
61
|
+
|
62
|
+
// 建立plugin類別
|
63
|
+
export const createBasePlugin: CreateBasePlugin = <T extends ChartType>() => {
|
64
|
+
|
65
|
+
// 定義plugin
|
66
|
+
return function definePlugin<PluginName, PluginParams>(name: PluginName, defaultParams: PluginParams) {
|
67
|
+
|
68
|
+
// 定義plugin的初始化function
|
69
|
+
return function definePluginInitFn (initFn: PluginInitFn<T, PluginName, PluginParams>) {
|
70
|
+
|
71
|
+
return class Plugin {
|
72
|
+
params$: Subject<Partial<PluginParams>>
|
73
|
+
name: PluginName
|
74
|
+
defaultParams: PluginParams
|
75
|
+
// presetParams: Partial<PluginParams>
|
76
|
+
init: () => void
|
77
|
+
destroy: () => void
|
78
|
+
setPresetParams: (presetParams: Partial<PluginParams>) => void
|
79
|
+
setContext: (pluginContext: PluginContext<T, PluginName, PluginParams>) => void
|
80
|
+
constructor () {
|
81
|
+
const pluginEntity = createPlugin<T, PluginName, PluginParams>({ name, defaultParams, initFn })
|
82
|
+
|
83
|
+
this.params$ = pluginEntity.params$
|
84
|
+
this.name = pluginEntity.name
|
85
|
+
this.defaultParams = pluginEntity.defaultParams
|
86
|
+
// this.presetParams = pluginEntity.presetParams
|
87
|
+
this.init = pluginEntity.init
|
88
|
+
this.destroy = pluginEntity.destroy
|
89
|
+
this.setPresetParams = pluginEntity.setPresetParams
|
90
|
+
this.setContext = pluginEntity.setContext
|
91
|
+
}
|
92
|
+
}
|
93
|
+
}
|
94
|
+
}
|
95
|
+
}
|
package/src/defaults.ts
CHANGED
@@ -1,220 +1,220 @@
|
|
1
|
-
// import type { ChartGlobalDefault } from './types/Chart'
|
2
|
-
// import { ChartRenderOptions } from './types/Chart'
|
3
|
-
import type { ChartType, ChartOptionsPartial } from './types/Chart'
|
4
|
-
import type { DataSeries } from './types/DataSeries'
|
5
|
-
import type { DataGrid, DataGridDatum } from './types/DataGrid'
|
6
|
-
import type { DataMultiGrid } from './types/DataMultiGrid'
|
7
|
-
import type { DataMultiValue } from './types/DataMultiValue'
|
8
|
-
import type { DataTree } from './types/DataTree'
|
9
|
-
import type { DataRelationship } from './types/DataRelationship'
|
10
|
-
import type { DataFormatterBase, DataFormatterValueAxis, DataFormatterGroupAxis, DataFormatterContainer } from './types/DataFormatter'
|
11
|
-
import type { DataFormatterSeries } from './types/DataFormatterSeries'
|
12
|
-
import type { DataFormatterGrid, DataFormatterGridGrid } from './types/DataFormatterGrid'
|
13
|
-
import type { DataFormatterMultiGrid, DataFormatterMultiGridGrid } from './types/DataFormatterMultiGrid'
|
14
|
-
import type { DataFormatterMultiValue } from './types/DataFormatterMultiValue'
|
15
|
-
import type { DataFormatterTree } from './types/DataFormatterTree'
|
16
|
-
import type { DataFormatterRelationship } from './types/DataFormatterRelationship'
|
17
|
-
import type { ChartParams } from './types/ChartParams'
|
18
|
-
import type { Padding } from './types/Padding'
|
19
|
-
|
20
|
-
export const CHART_OPTIONS_DEFAULT: ChartOptionsPartial<any> = {
|
21
|
-
preset: {} // 預設為空
|
22
|
-
}
|
23
|
-
|
24
|
-
// export const GLOBAL_DEFAULT: ChartGlobalDefault = {
|
25
|
-
// colors: ['#67B7DC', '#6794DC', '#6771DC', '#8067DC', '#A367DC', '#C767DC', '#DC67CE', '#DC67AB', '#DC6788', '#DC6967', '#DC8C67', '#DCAF67'],
|
26
|
-
// padding: {
|
27
|
-
// top: 50,
|
28
|
-
// right: 70,
|
29
|
-
// bottom: 50,
|
30
|
-
// left: 70
|
31
|
-
// },
|
32
|
-
// // chartWidth: '100%',
|
33
|
-
// // chartHeight: 500
|
34
|
-
// }
|
35
|
-
|
36
|
-
// export const COLORS_DEFAULT = ['#67B7DC', '#6794DC', '#6771DC', '#8067DC', '#A367DC', '#C767DC', '#DC67CE', '#DC67AB', '#DC6788', '#DC6967', '#DC8C67', '#DCAF67']
|
37
|
-
// ['#ff7ab9', '#66dec8', '#84c8ff', '#30ad1b', '#f8c43e', '#fa5640', '#9d79d7', '#ea4f98']
|
38
|
-
|
39
|
-
export const PADDING_DEFAULT: Padding = {
|
40
|
-
top: 60,
|
41
|
-
right: 60,
|
42
|
-
bottom: 60,
|
43
|
-
left: 60
|
44
|
-
}
|
45
|
-
|
46
|
-
export const CHART_PARAMS_DEFAULT: ChartParams = {
|
47
|
-
padding: PADDING_DEFAULT,
|
48
|
-
highlightTarget: 'datum',
|
49
|
-
highlightDefault: null,
|
50
|
-
colorScheme: 'light',
|
51
|
-
colors: {
|
52
|
-
light: {
|
53
|
-
series: ['#67B7DC', '#6794DC', '#6771DC', '#8067DC', '#A367DC', '#C767DC', '#DC67CE', '#DC67AB', '#DC6788', '#DC6967', '#DC8C67', '#DCAF67'],
|
54
|
-
// primary: '#454545',
|
55
|
-
primary: '#1b1e23',
|
56
|
-
secondary: '#e1e1e1',
|
57
|
-
white: '#ffffff',
|
58
|
-
background: '#ffffff'
|
59
|
-
},
|
60
|
-
dark: {
|
61
|
-
series: ['#67B7DC', '#6794DC', '#6771DC', '#8067DC', '#A367DC', '#C767DC', '#DC67CE', '#DC67AB', '#DC6788', '#DC6967', '#DC8C67', '#DCAF67'],
|
62
|
-
primary: '#f0f0f0',
|
63
|
-
secondary: '#e1e1e1',
|
64
|
-
white: '#ffffff',
|
65
|
-
background: '#000000'
|
66
|
-
}
|
67
|
-
},
|
68
|
-
styles: {
|
69
|
-
// textSize: 14,
|
70
|
-
textSize: '0.875rem',
|
71
|
-
unhighlightedOpacity: 0.3
|
72
|
-
},
|
73
|
-
transitionDuration: 800,
|
74
|
-
transitionEase: 'easeCubic'
|
75
|
-
}
|
76
|
-
|
77
|
-
export const CHART_WIDTH_DEFAULT = 800
|
78
|
-
|
79
|
-
export const CHART_HEIGHT_DEFAULT = 500
|
80
|
-
|
81
|
-
// -- Data --
|
82
|
-
|
83
|
-
export const DATA_SERIES_DEFAULT: DataSeries = []
|
84
|
-
|
85
|
-
export const DATA_GRID_DEFAULT: DataGrid = []
|
86
|
-
|
87
|
-
export const DATA_MULTI_GRID_DEFAULT: DataMultiGrid = []
|
88
|
-
|
89
|
-
export const DATA_MULTI_VALUE_DEFAULT: DataMultiValue = []
|
90
|
-
|
91
|
-
export const DATA_TREE_DEFAULT: DataTree = []
|
92
|
-
|
93
|
-
export const DATA_RELATIONA_DEFAULTL: DataRelationship = {
|
94
|
-
nodes: [],
|
95
|
-
edges: []
|
96
|
-
}
|
97
|
-
|
98
|
-
// -- Data Formatter --
|
99
|
-
|
100
|
-
export const DATA_FORMATTER_VALUE_AXIS_DEFAULT: DataFormatterValueAxis = {
|
101
|
-
position: 'left',
|
102
|
-
scaleDomain: [0, 'auto'],
|
103
|
-
scaleRange: [0, 0.9],
|
104
|
-
label: '',
|
105
|
-
}
|
106
|
-
|
107
|
-
export const DATA_FORMATTER_GROUP_AXIS_DEFAULT: DataFormatterGroupAxis = {
|
108
|
-
position: 'bottom',
|
109
|
-
scaleDomain: [0, 'auto'],
|
110
|
-
scalePadding: 0.5,
|
111
|
-
label: ''
|
112
|
-
}
|
113
|
-
|
114
|
-
export const DATA_FORMATTER_CONTAINER_DEFAULT: DataFormatterContainer = {
|
115
|
-
gap: 120,
|
116
|
-
rowAmount: 1,
|
117
|
-
columnAmount: 1
|
118
|
-
}
|
119
|
-
|
120
|
-
export const DATA_FORMATTER_SERIES_DEFAULT: DataFormatterSeries = {
|
121
|
-
type: 'series',
|
122
|
-
visibleFilter: (datum, context) => true,
|
123
|
-
sort: null,
|
124
|
-
seriesLabels: [],
|
125
|
-
container: {
|
126
|
-
...DATA_FORMATTER_CONTAINER_DEFAULT
|
127
|
-
},
|
128
|
-
separateSeries: false,
|
129
|
-
sumSeries: false
|
130
|
-
// mapSeries: (datum, rowIndex, columnIndex, { data, dataFormatter }) => {
|
131
|
-
// const seriesIndex = rowIndex >= dataFormatter.seriesLabels.length
|
132
|
-
// ? rowIndex % dataFormatter.seriesLabels.length // 如果index大於所設定的seriesLabels的數量則從頭回來算
|
133
|
-
// : rowIndex
|
134
|
-
// return dataFormatter.seriesLabels[seriesIndex]
|
135
|
-
// },
|
136
|
-
// colorsPredicate: (datum, rowIndex, columnIndex, { chartParams }) => {
|
137
|
-
// return rowIndex < chartParams.colors[chartParams.colorScheme].series.length
|
138
|
-
// ? chartParams.colors[chartParams.colorScheme].series[rowIndex]
|
139
|
-
// : chartParams.colors[chartParams.colorScheme].series[
|
140
|
-
// rowIndex % chartParams.colors[chartParams.colorScheme].series.length
|
141
|
-
// ]
|
142
|
-
// },
|
143
|
-
}
|
144
|
-
|
145
|
-
export const DATA_FORMATTER_GRID_GRID_DEFAULT: DataFormatterGridGrid = {
|
146
|
-
seriesDirection: 'row',
|
147
|
-
rowLabels: [],
|
148
|
-
columnLabels: [],
|
149
|
-
valueAxis: { ...DATA_FORMATTER_VALUE_AXIS_DEFAULT },
|
150
|
-
groupAxis: { ...DATA_FORMATTER_GROUP_AXIS_DEFAULT, },
|
151
|
-
separateSeries: false,
|
152
|
-
// slotIndex: 0,
|
153
|
-
// seriesSlotIndexes: null
|
154
|
-
}
|
155
|
-
|
156
|
-
export const DATA_FORMATTER_GRID_DEFAULT: DataFormatterGrid = {
|
157
|
-
type: 'grid',
|
158
|
-
visibleFilter: (datum, context) => true,
|
159
|
-
grid: {
|
160
|
-
...DATA_FORMATTER_GRID_GRID_DEFAULT
|
161
|
-
},
|
162
|
-
container: {
|
163
|
-
...DATA_FORMATTER_CONTAINER_DEFAULT
|
164
|
-
}
|
165
|
-
}
|
166
|
-
|
167
|
-
// export const DATA_FORMATTER_MULTI_GRID_MULTI_GRID_DEFAULT: DataFormatterMultiGridMultiGrid = {
|
168
|
-
// ...DATA_FORMATTER_GRID_DEFAULT,
|
169
|
-
// slotIndex: 0,
|
170
|
-
// seriesSlotIndexes: null
|
171
|
-
// }
|
172
|
-
|
173
|
-
export const DATA_FORMATTER_MULTI_GRID_GRID_DEFAULT: DataFormatterMultiGridGrid = {
|
174
|
-
...DATA_FORMATTER_GRID_GRID_DEFAULT
|
175
|
-
}
|
176
|
-
|
177
|
-
export const DATA_FORMATTER_MULTI_GRID_DEFAULT: DataFormatterMultiGrid = {
|
178
|
-
type: 'multiGrid',
|
179
|
-
visibleFilter: (datum, context) => true,
|
180
|
-
gridList: [
|
181
|
-
{
|
182
|
-
...DATA_FORMATTER_MULTI_GRID_GRID_DEFAULT
|
183
|
-
},
|
184
|
-
],
|
185
|
-
separateGrid: false,
|
186
|
-
container: {
|
187
|
-
...DATA_FORMATTER_CONTAINER_DEFAULT
|
188
|
-
}
|
189
|
-
}
|
190
|
-
|
191
|
-
export const DATA_FORMATTER_MULTI_VALUE_DEFAULT: DataFormatterMultiValue = {
|
192
|
-
type: 'multiValue',
|
193
|
-
visibleFilter: (datum, context) => true,
|
194
|
-
categoryLabels: [],
|
195
|
-
multiValue: [],
|
196
|
-
xAxis: { ...DATA_FORMATTER_VALUE_AXIS_DEFAULT },
|
197
|
-
yAxis: { ...DATA_FORMATTER_VALUE_AXIS_DEFAULT },
|
198
|
-
}
|
199
|
-
|
200
|
-
export const DATA_FORMATTER_TREE_DEFAULT: DataFormatterTree = {
|
201
|
-
type: 'tree',
|
202
|
-
visibleFilter: (datum, context) => true,
|
203
|
-
// labelFormat: (datum: any) => (datum && datum.label) ?? '',
|
204
|
-
categoryLabels: []
|
205
|
-
}
|
206
|
-
|
207
|
-
export const DATA_FORMATTER_RELATIONAL_DEFAULT: DataFormatterRelationship = {
|
208
|
-
type: 'relationship',
|
209
|
-
visibleFilter: (datum, context) => true,
|
210
|
-
categoryLabels: []
|
211
|
-
// node: {
|
212
|
-
// // labelFormat: (node: any) => (node && node.label) ?? '',
|
213
|
-
// descriptionFormat: (node: any) => (node && node.label) ?? ''
|
214
|
-
// },
|
215
|
-
// edge: {
|
216
|
-
// // labelFormat: (edge: any) => (edge && edge.label) ?? '',
|
217
|
-
// descriptionFormat: (edge: any) => (edge && edge.label) ?? ''
|
218
|
-
// },
|
219
|
-
}
|
220
|
-
|
1
|
+
// import type { ChartGlobalDefault } from './types/Chart'
|
2
|
+
// import { ChartRenderOptions } from './types/Chart'
|
3
|
+
import type { ChartType, ChartOptionsPartial } from './types/Chart'
|
4
|
+
import type { DataSeries } from './types/DataSeries'
|
5
|
+
import type { DataGrid, DataGridDatum } from './types/DataGrid'
|
6
|
+
import type { DataMultiGrid } from './types/DataMultiGrid'
|
7
|
+
import type { DataMultiValue } from './types/DataMultiValue'
|
8
|
+
import type { DataTree } from './types/DataTree'
|
9
|
+
import type { DataRelationship } from './types/DataRelationship'
|
10
|
+
import type { DataFormatterBase, DataFormatterValueAxis, DataFormatterGroupAxis, DataFormatterContainer } from './types/DataFormatter'
|
11
|
+
import type { DataFormatterSeries } from './types/DataFormatterSeries'
|
12
|
+
import type { DataFormatterGrid, DataFormatterGridGrid } from './types/DataFormatterGrid'
|
13
|
+
import type { DataFormatterMultiGrid, DataFormatterMultiGridGrid } from './types/DataFormatterMultiGrid'
|
14
|
+
import type { DataFormatterMultiValue } from './types/DataFormatterMultiValue'
|
15
|
+
import type { DataFormatterTree } from './types/DataFormatterTree'
|
16
|
+
import type { DataFormatterRelationship } from './types/DataFormatterRelationship'
|
17
|
+
import type { ChartParams } from './types/ChartParams'
|
18
|
+
import type { Padding } from './types/Padding'
|
19
|
+
|
20
|
+
export const CHART_OPTIONS_DEFAULT: ChartOptionsPartial<any> = {
|
21
|
+
preset: {} // 預設為空
|
22
|
+
}
|
23
|
+
|
24
|
+
// export const GLOBAL_DEFAULT: ChartGlobalDefault = {
|
25
|
+
// colors: ['#67B7DC', '#6794DC', '#6771DC', '#8067DC', '#A367DC', '#C767DC', '#DC67CE', '#DC67AB', '#DC6788', '#DC6967', '#DC8C67', '#DCAF67'],
|
26
|
+
// padding: {
|
27
|
+
// top: 50,
|
28
|
+
// right: 70,
|
29
|
+
// bottom: 50,
|
30
|
+
// left: 70
|
31
|
+
// },
|
32
|
+
// // chartWidth: '100%',
|
33
|
+
// // chartHeight: 500
|
34
|
+
// }
|
35
|
+
|
36
|
+
// export const COLORS_DEFAULT = ['#67B7DC', '#6794DC', '#6771DC', '#8067DC', '#A367DC', '#C767DC', '#DC67CE', '#DC67AB', '#DC6788', '#DC6967', '#DC8C67', '#DCAF67']
|
37
|
+
// ['#ff7ab9', '#66dec8', '#84c8ff', '#30ad1b', '#f8c43e', '#fa5640', '#9d79d7', '#ea4f98']
|
38
|
+
|
39
|
+
export const PADDING_DEFAULT: Padding = {
|
40
|
+
top: 60,
|
41
|
+
right: 60,
|
42
|
+
bottom: 60,
|
43
|
+
left: 60
|
44
|
+
}
|
45
|
+
|
46
|
+
export const CHART_PARAMS_DEFAULT: ChartParams = {
|
47
|
+
padding: PADDING_DEFAULT,
|
48
|
+
highlightTarget: 'datum',
|
49
|
+
highlightDefault: null,
|
50
|
+
colorScheme: 'light',
|
51
|
+
colors: {
|
52
|
+
light: {
|
53
|
+
series: ['#67B7DC', '#6794DC', '#6771DC', '#8067DC', '#A367DC', '#C767DC', '#DC67CE', '#DC67AB', '#DC6788', '#DC6967', '#DC8C67', '#DCAF67'],
|
54
|
+
// primary: '#454545',
|
55
|
+
primary: '#1b1e23',
|
56
|
+
secondary: '#e1e1e1',
|
57
|
+
white: '#ffffff',
|
58
|
+
background: '#ffffff'
|
59
|
+
},
|
60
|
+
dark: {
|
61
|
+
series: ['#67B7DC', '#6794DC', '#6771DC', '#8067DC', '#A367DC', '#C767DC', '#DC67CE', '#DC67AB', '#DC6788', '#DC6967', '#DC8C67', '#DCAF67'],
|
62
|
+
primary: '#f0f0f0',
|
63
|
+
secondary: '#e1e1e1',
|
64
|
+
white: '#ffffff',
|
65
|
+
background: '#000000'
|
66
|
+
}
|
67
|
+
},
|
68
|
+
styles: {
|
69
|
+
// textSize: 14,
|
70
|
+
textSize: '0.875rem',
|
71
|
+
unhighlightedOpacity: 0.3
|
72
|
+
},
|
73
|
+
transitionDuration: 800,
|
74
|
+
transitionEase: 'easeCubic'
|
75
|
+
}
|
76
|
+
|
77
|
+
export const CHART_WIDTH_DEFAULT = 800
|
78
|
+
|
79
|
+
export const CHART_HEIGHT_DEFAULT = 500
|
80
|
+
|
81
|
+
// -- Data --
|
82
|
+
|
83
|
+
export const DATA_SERIES_DEFAULT: DataSeries = []
|
84
|
+
|
85
|
+
export const DATA_GRID_DEFAULT: DataGrid = []
|
86
|
+
|
87
|
+
export const DATA_MULTI_GRID_DEFAULT: DataMultiGrid = []
|
88
|
+
|
89
|
+
export const DATA_MULTI_VALUE_DEFAULT: DataMultiValue = []
|
90
|
+
|
91
|
+
export const DATA_TREE_DEFAULT: DataTree = []
|
92
|
+
|
93
|
+
export const DATA_RELATIONA_DEFAULTL: DataRelationship = {
|
94
|
+
nodes: [],
|
95
|
+
edges: []
|
96
|
+
}
|
97
|
+
|
98
|
+
// -- Data Formatter --
|
99
|
+
|
100
|
+
export const DATA_FORMATTER_VALUE_AXIS_DEFAULT: DataFormatterValueAxis = {
|
101
|
+
position: 'left',
|
102
|
+
scaleDomain: [0, 'auto'],
|
103
|
+
scaleRange: [0, 0.9],
|
104
|
+
label: '',
|
105
|
+
}
|
106
|
+
|
107
|
+
export const DATA_FORMATTER_GROUP_AXIS_DEFAULT: DataFormatterGroupAxis = {
|
108
|
+
position: 'bottom',
|
109
|
+
scaleDomain: [0, 'auto'],
|
110
|
+
scalePadding: 0.5,
|
111
|
+
label: ''
|
112
|
+
}
|
113
|
+
|
114
|
+
export const DATA_FORMATTER_CONTAINER_DEFAULT: DataFormatterContainer = {
|
115
|
+
gap: 120,
|
116
|
+
rowAmount: 1,
|
117
|
+
columnAmount: 1
|
118
|
+
}
|
119
|
+
|
120
|
+
export const DATA_FORMATTER_SERIES_DEFAULT: DataFormatterSeries = {
|
121
|
+
type: 'series',
|
122
|
+
visibleFilter: (datum, context) => true,
|
123
|
+
sort: null,
|
124
|
+
seriesLabels: [],
|
125
|
+
container: {
|
126
|
+
...DATA_FORMATTER_CONTAINER_DEFAULT
|
127
|
+
},
|
128
|
+
separateSeries: false,
|
129
|
+
sumSeries: false
|
130
|
+
// mapSeries: (datum, rowIndex, columnIndex, { data, dataFormatter }) => {
|
131
|
+
// const seriesIndex = rowIndex >= dataFormatter.seriesLabels.length
|
132
|
+
// ? rowIndex % dataFormatter.seriesLabels.length // 如果index大於所設定的seriesLabels的數量則從頭回來算
|
133
|
+
// : rowIndex
|
134
|
+
// return dataFormatter.seriesLabels[seriesIndex]
|
135
|
+
// },
|
136
|
+
// colorsPredicate: (datum, rowIndex, columnIndex, { chartParams }) => {
|
137
|
+
// return rowIndex < chartParams.colors[chartParams.colorScheme].series.length
|
138
|
+
// ? chartParams.colors[chartParams.colorScheme].series[rowIndex]
|
139
|
+
// : chartParams.colors[chartParams.colorScheme].series[
|
140
|
+
// rowIndex % chartParams.colors[chartParams.colorScheme].series.length
|
141
|
+
// ]
|
142
|
+
// },
|
143
|
+
}
|
144
|
+
|
145
|
+
export const DATA_FORMATTER_GRID_GRID_DEFAULT: DataFormatterGridGrid = {
|
146
|
+
seriesDirection: 'row',
|
147
|
+
rowLabels: [],
|
148
|
+
columnLabels: [],
|
149
|
+
valueAxis: { ...DATA_FORMATTER_VALUE_AXIS_DEFAULT },
|
150
|
+
groupAxis: { ...DATA_FORMATTER_GROUP_AXIS_DEFAULT, },
|
151
|
+
separateSeries: false,
|
152
|
+
// slotIndex: 0,
|
153
|
+
// seriesSlotIndexes: null
|
154
|
+
}
|
155
|
+
|
156
|
+
export const DATA_FORMATTER_GRID_DEFAULT: DataFormatterGrid = {
|
157
|
+
type: 'grid',
|
158
|
+
visibleFilter: (datum, context) => true,
|
159
|
+
grid: {
|
160
|
+
...DATA_FORMATTER_GRID_GRID_DEFAULT
|
161
|
+
},
|
162
|
+
container: {
|
163
|
+
...DATA_FORMATTER_CONTAINER_DEFAULT
|
164
|
+
}
|
165
|
+
}
|
166
|
+
|
167
|
+
// export const DATA_FORMATTER_MULTI_GRID_MULTI_GRID_DEFAULT: DataFormatterMultiGridMultiGrid = {
|
168
|
+
// ...DATA_FORMATTER_GRID_DEFAULT,
|
169
|
+
// slotIndex: 0,
|
170
|
+
// seriesSlotIndexes: null
|
171
|
+
// }
|
172
|
+
|
173
|
+
export const DATA_FORMATTER_MULTI_GRID_GRID_DEFAULT: DataFormatterMultiGridGrid = {
|
174
|
+
...DATA_FORMATTER_GRID_GRID_DEFAULT
|
175
|
+
}
|
176
|
+
|
177
|
+
export const DATA_FORMATTER_MULTI_GRID_DEFAULT: DataFormatterMultiGrid = {
|
178
|
+
type: 'multiGrid',
|
179
|
+
visibleFilter: (datum, context) => true,
|
180
|
+
gridList: [
|
181
|
+
{
|
182
|
+
...DATA_FORMATTER_MULTI_GRID_GRID_DEFAULT
|
183
|
+
},
|
184
|
+
],
|
185
|
+
separateGrid: false,
|
186
|
+
container: {
|
187
|
+
...DATA_FORMATTER_CONTAINER_DEFAULT
|
188
|
+
}
|
189
|
+
}
|
190
|
+
|
191
|
+
export const DATA_FORMATTER_MULTI_VALUE_DEFAULT: DataFormatterMultiValue = {
|
192
|
+
type: 'multiValue',
|
193
|
+
visibleFilter: (datum, context) => true,
|
194
|
+
categoryLabels: [],
|
195
|
+
multiValue: [],
|
196
|
+
xAxis: { ...DATA_FORMATTER_VALUE_AXIS_DEFAULT },
|
197
|
+
yAxis: { ...DATA_FORMATTER_VALUE_AXIS_DEFAULT },
|
198
|
+
}
|
199
|
+
|
200
|
+
export const DATA_FORMATTER_TREE_DEFAULT: DataFormatterTree = {
|
201
|
+
type: 'tree',
|
202
|
+
visibleFilter: (datum, context) => true,
|
203
|
+
// labelFormat: (datum: any) => (datum && datum.label) ?? '',
|
204
|
+
categoryLabels: []
|
205
|
+
}
|
206
|
+
|
207
|
+
export const DATA_FORMATTER_RELATIONAL_DEFAULT: DataFormatterRelationship = {
|
208
|
+
type: 'relationship',
|
209
|
+
visibleFilter: (datum, context) => true,
|
210
|
+
categoryLabels: []
|
211
|
+
// node: {
|
212
|
+
// // labelFormat: (node: any) => (node && node.label) ?? '',
|
213
|
+
// descriptionFormat: (node: any) => (node && node.label) ?? ''
|
214
|
+
// },
|
215
|
+
// edge: {
|
216
|
+
// // labelFormat: (edge: any) => (edge && edge.label) ?? '',
|
217
|
+
// descriptionFormat: (edge: any) => (edge && edge.label) ?? ''
|
218
|
+
// },
|
219
|
+
}
|
220
|
+
|
package/src/defineGridPlugin.ts
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
import { createBasePlugin } from './base/createBasePlugin'
|
2
|
-
|
3
|
-
export const defineGridPlugin = createBasePlugin<'grid'>()
|
1
|
+
import { createBasePlugin } from './base/createBasePlugin'
|
2
|
+
|
3
|
+
export const defineGridPlugin = createBasePlugin<'grid'>()
|
@@ -1,3 +1,3 @@
|
|
1
|
-
import { createBasePlugin } from './base/createBasePlugin'
|
2
|
-
|
3
|
-
export const defineMultiGridPlugin = createBasePlugin<'multiGrid'>()
|
1
|
+
import { createBasePlugin } from './base/createBasePlugin'
|
2
|
+
|
3
|
+
export const defineMultiGridPlugin = createBasePlugin<'multiGrid'>()
|
@@ -1,3 +1,3 @@
|
|
1
|
-
import { createBasePlugin } from './base/createBasePlugin'
|
2
|
-
|
3
|
-
export const defineMultiValuePlugin = createBasePlugin<'multiValue'>()
|
1
|
+
import { createBasePlugin } from './base/createBasePlugin'
|
2
|
+
|
3
|
+
export const defineMultiValuePlugin = createBasePlugin<'multiValue'>()
|