@orbcharts/core 3.0.0-alpha.48 → 3.0.0-alpha.50

Sign up to get free protection for your applications and to get access to all the features.
Files changed (83) hide show
  1. package/LICENSE +200 -200
  2. package/dist/orbcharts-core.es.js +4 -4
  3. package/dist/orbcharts-core.umd.js +2 -2
  4. package/dist/src/types/Chart.d.ts +10 -12
  5. package/package.json +41 -41
  6. package/src/AbstractChart.ts +48 -48
  7. package/src/GridChart.ts +20 -20
  8. package/src/MultiGridChart.ts +20 -20
  9. package/src/MultiValueChart.ts +20 -20
  10. package/src/RelationshipChart.ts +20 -20
  11. package/src/SeriesChart.ts +20 -20
  12. package/src/TreeChart.ts +20 -20
  13. package/src/base/createBaseChart.ts +369 -368
  14. package/src/base/createBasePlugin.ts +95 -95
  15. package/src/defaults.ts +220 -220
  16. package/src/defineGridPlugin.ts +3 -3
  17. package/src/defineMultiGridPlugin.ts +3 -3
  18. package/src/defineMultiValuePlugin.ts +3 -3
  19. package/src/defineNoneDataPlugin.ts +4 -4
  20. package/src/defineRelationshipPlugin.ts +3 -3
  21. package/src/defineSeriesPlugin.ts +3 -3
  22. package/src/defineTreePlugin.ts +3 -3
  23. package/src/grid/computeGridData.ts +134 -134
  24. package/src/grid/createGridContextObserver.ts +155 -155
  25. package/src/grid/gridObservables.ts +600 -600
  26. package/src/index.ts +21 -21
  27. package/src/multiGrid/computeMultiGridData.ts +130 -130
  28. package/src/multiGrid/createMultiGridContextObserver.ts +40 -40
  29. package/src/multiGrid/multiGridObservables.ts +364 -364
  30. package/src/multiValue/computeMultiValueData.ts +143 -143
  31. package/src/multiValue/createMultiValueContextObserver.ts +12 -12
  32. package/src/relationship/computeRelationshipData.ts +118 -118
  33. package/src/relationship/createRelationshipContextObserver.ts +12 -12
  34. package/src/series/computeSeriesData.ts +90 -90
  35. package/src/series/createSeriesContextObserver.ts +93 -93
  36. package/src/series/seriesObservables.ts +175 -175
  37. package/src/tree/computeTreeData.ts +131 -131
  38. package/src/tree/createTreeContextObserver.ts +61 -61
  39. package/src/tree/treeObservables.ts +94 -94
  40. package/src/types/Chart.ts +50 -48
  41. package/src/types/ChartParams.ts +51 -51
  42. package/src/types/ComputedData.ts +83 -83
  43. package/src/types/ComputedDataGrid.ts +13 -13
  44. package/src/types/ComputedDataMultiGrid.ts +2 -2
  45. package/src/types/ComputedDataMultiValue.ts +9 -9
  46. package/src/types/ComputedDataRelationship.ts +19 -19
  47. package/src/types/ComputedDataSeries.ts +7 -7
  48. package/src/types/ComputedDataTree.ts +19 -19
  49. package/src/types/ContextObserver.ts +38 -38
  50. package/src/types/ContextObserverGrid.ts +42 -42
  51. package/src/types/ContextObserverMultiGrid.ts +15 -15
  52. package/src/types/ContextObserverMultiValue.ts +4 -4
  53. package/src/types/ContextObserverRelationship.ts +4 -4
  54. package/src/types/ContextObserverSeries.ts +29 -29
  55. package/src/types/ContextObserverTree.ts +11 -11
  56. package/src/types/ContextSubject.ts +18 -18
  57. package/src/types/Data.ts +45 -45
  58. package/src/types/DataFormatter.ts +74 -74
  59. package/src/types/DataFormatterGrid.ts +67 -67
  60. package/src/types/DataFormatterMultiGrid.ts +44 -44
  61. package/src/types/DataFormatterMultiValue.ts +23 -23
  62. package/src/types/DataFormatterRelationship.ts +25 -25
  63. package/src/types/DataFormatterSeries.ts +20 -20
  64. package/src/types/DataFormatterTree.ts +12 -12
  65. package/src/types/DataGrid.ts +11 -11
  66. package/src/types/DataMultiGrid.ts +6 -6
  67. package/src/types/DataMultiValue.ts +12 -12
  68. package/src/types/DataRelationship.ts +27 -27
  69. package/src/types/DataSeries.ts +11 -11
  70. package/src/types/DataTree.ts +20 -20
  71. package/src/types/Event.ts +153 -153
  72. package/src/types/Layout.ts +11 -11
  73. package/src/types/Padding.ts +5 -5
  74. package/src/types/Plugin.ts +60 -60
  75. package/src/types/TransformData.ts +7 -7
  76. package/src/types/index.ts +37 -37
  77. package/src/utils/commonUtils.ts +50 -50
  78. package/src/utils/d3Utils.ts +89 -89
  79. package/src/utils/index.ts +4 -4
  80. package/src/utils/observables.ts +201 -201
  81. package/src/utils/orbchartsUtils.ts +349 -349
  82. package/tsconfig.json +13 -13
  83. 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
+
@@ -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'>()