@orbcharts/core 3.0.0-alpha.42 → 3.0.0-alpha.43

Sign up to get free protection for your applications and to get access to all the features.
Files changed (100) hide show
  1. package/LICENSE +200 -200
  2. package/dist/orbcharts-core.es.js +1905 -1896
  3. package/dist/orbcharts-core.umd.js +2 -2
  4. package/dist/src/defaults.d.ts +4 -3
  5. package/dist/src/grid/computeGridData.d.ts +4 -11
  6. package/dist/src/grid/gridObservables.d.ts +15 -18
  7. package/dist/src/multiGrid/multiGridObservables.d.ts +4 -11
  8. package/dist/src/series/seriesObservables.d.ts +26 -1
  9. package/dist/src/types/ComputedData.d.ts +1 -0
  10. package/dist/src/types/ComputedDataGrid.d.ts +0 -3
  11. package/dist/src/types/ComputedDataSeries.d.ts +1 -2
  12. package/dist/src/types/ContextObserverGrid.d.ts +11 -4
  13. package/dist/src/types/ContextObserverMultiGrid.d.ts +8 -3
  14. package/dist/src/types/ContextObserverSeries.d.ts +18 -0
  15. package/dist/src/types/DataFormatter.d.ts +8 -5
  16. package/dist/src/types/DataFormatterGrid.d.ts +13 -16
  17. package/dist/src/types/DataFormatterMultiGrid.d.ts +6 -3
  18. package/dist/src/types/DataFormatterMultiValue.d.ts +3 -0
  19. package/dist/src/types/DataFormatterRelationship.d.ts +3 -0
  20. package/dist/src/types/DataFormatterSeries.d.ts +10 -3
  21. package/dist/src/utils/orbchartsUtils.d.ts +14 -13
  22. package/package.json +41 -41
  23. package/src/AbstractChart.ts +48 -48
  24. package/src/GridChart.ts +20 -20
  25. package/src/MultiGridChart.ts +20 -20
  26. package/src/MultiValueChart.ts +20 -20
  27. package/src/RelationshipChart.ts +20 -20
  28. package/src/SeriesChart.ts +20 -20
  29. package/src/TreeChart.ts +20 -20
  30. package/src/base/createBaseChart.ts +367 -367
  31. package/src/base/createBasePlugin.ts +89 -89
  32. package/src/defaults.ts +220 -248
  33. package/src/defineGridPlugin.ts +3 -3
  34. package/src/defineMultiGridPlugin.ts +3 -3
  35. package/src/defineMultiValuePlugin.ts +3 -3
  36. package/src/defineNoneDataPlugin.ts +4 -4
  37. package/src/defineRelationshipPlugin.ts +3 -3
  38. package/src/defineSeriesPlugin.ts +3 -3
  39. package/src/defineTreePlugin.ts +3 -3
  40. package/src/grid/computeGridData.ts +134 -205
  41. package/src/grid/createGridContextObserver.ts +147 -130
  42. package/src/grid/gridObservables.ts +573 -486
  43. package/src/index.ts +21 -21
  44. package/src/multiGrid/computeMultiGridData.ts +130 -173
  45. package/src/multiGrid/createMultiGridContextObserver.ts +40 -40
  46. package/src/multiGrid/multiGridObservables.ts +350 -285
  47. package/src/multiValue/computeMultiValueData.ts +143 -136
  48. package/src/multiValue/createMultiValueContextObserver.ts +12 -12
  49. package/src/relationship/computeRelationshipData.ts +118 -106
  50. package/src/relationship/createRelationshipContextObserver.ts +12 -12
  51. package/src/series/computeSeriesData.ts +90 -153
  52. package/src/series/createSeriesContextObserver.ts +93 -38
  53. package/src/series/seriesObservables.ts +176 -24
  54. package/src/tree/computeTreeData.ts +131 -128
  55. package/src/tree/createTreeContextObserver.ts +61 -61
  56. package/src/tree/treeObservables.ts +94 -94
  57. package/src/types/Chart.ts +48 -48
  58. package/src/types/ChartParams.ts +51 -51
  59. package/src/types/ComputedData.ts +83 -82
  60. package/src/types/ComputedDataGrid.ts +13 -13
  61. package/src/types/ComputedDataMultiGrid.ts +2 -2
  62. package/src/types/ComputedDataMultiValue.ts +9 -9
  63. package/src/types/ComputedDataRelationship.ts +19 -19
  64. package/src/types/ComputedDataSeries.ts +8 -8
  65. package/src/types/ComputedDataTree.ts +19 -19
  66. package/src/types/ContextObserver.ts +38 -38
  67. package/src/types/ContextObserverGrid.ts +41 -33
  68. package/src/types/ContextObserverMultiGrid.ts +16 -28
  69. package/src/types/ContextObserverMultiValue.ts +4 -4
  70. package/src/types/ContextObserverRelationship.ts +4 -4
  71. package/src/types/ContextObserverSeries.ts +29 -9
  72. package/src/types/ContextObserverTree.ts +11 -11
  73. package/src/types/ContextSubject.ts +18 -18
  74. package/src/types/Data.ts +45 -45
  75. package/src/types/DataFormatter.ts +74 -95
  76. package/src/types/DataFormatterGrid.ts +67 -55
  77. package/src/types/DataFormatterMultiGrid.ts +44 -42
  78. package/src/types/DataFormatterMultiValue.ts +23 -20
  79. package/src/types/DataFormatterRelationship.ts +25 -22
  80. package/src/types/DataFormatterSeries.ts +20 -30
  81. package/src/types/DataFormatterTree.ts +12 -12
  82. package/src/types/DataGrid.ts +11 -11
  83. package/src/types/DataMultiGrid.ts +6 -6
  84. package/src/types/DataMultiValue.ts +12 -12
  85. package/src/types/DataRelationship.ts +27 -27
  86. package/src/types/DataSeries.ts +11 -11
  87. package/src/types/DataTree.ts +20 -20
  88. package/src/types/Event.ts +153 -153
  89. package/src/types/Layout.ts +11 -11
  90. package/src/types/Padding.ts +5 -5
  91. package/src/types/Plugin.ts +60 -60
  92. package/src/types/TransformData.ts +7 -7
  93. package/src/types/index.ts +37 -37
  94. package/src/utils/commonUtils.ts +50 -50
  95. package/src/utils/d3Utils.ts +89 -89
  96. package/src/utils/index.ts +4 -4
  97. package/src/utils/observables.ts +201 -201
  98. package/src/utils/orbchartsUtils.ts +349 -253
  99. package/tsconfig.json +13 -13
  100. 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
+ }
package/src/defaults.ts CHANGED
@@ -1,248 +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 } 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 HIGHLIGHT_DEFAULT: HighlightDefault = {
47
- // // trigger: 'datum',
48
- // id: null,
49
- // label: null
50
- // }
51
-
52
- export const CHART_PARAMS_DEFAULT: ChartParams = {
53
- padding: PADDING_DEFAULT,
54
- highlightTarget: 'datum',
55
- // highlightDefault: HIGHLIGHT_DEFAULT,
56
- highlightDefault: null,
57
- colorScheme: 'light',
58
- colors: {
59
- light: {
60
- series: ['#67B7DC', '#6794DC', '#6771DC', '#8067DC', '#A367DC', '#C767DC', '#DC67CE', '#DC67AB', '#DC6788', '#DC6967', '#DC8C67', '#DCAF67'],
61
- // primary: '#454545',
62
- primary: '#1b1e23',
63
- secondary: '#e1e1e1',
64
- white: '#ffffff',
65
- background: '#ffffff'
66
- },
67
- dark: {
68
- series: ['#67B7DC', '#6794DC', '#6771DC', '#8067DC', '#A367DC', '#C767DC', '#DC67CE', '#DC67AB', '#DC6788', '#DC6967', '#DC8C67', '#DCAF67'],
69
- primary: '#f0f0f0',
70
- secondary: '#e1e1e1',
71
- white: '#ffffff',
72
- background: '#000000'
73
- }
74
- },
75
- styles: {
76
- // textSize: 14,
77
- textSize: '0.875rem',
78
- unhighlightedOpacity: 0.3
79
- },
80
- transitionDuration: 800,
81
- transitionEase: 'easeCubic'
82
- }
83
-
84
- export const CHART_WIDTH_DEFAULT = 800
85
-
86
- export const CHART_HEIGHT_DEFAULT = 500
87
-
88
- // -- Data --
89
-
90
- export const DATA_SERIES_DEFAULT: DataSeries = []
91
-
92
- export const DATA_GRID_DEFAULT: DataGrid = []
93
-
94
- export const DATA_MULTI_GRID_DEFAULT: DataMultiGrid = []
95
-
96
- export const DATA_MULTI_VALUE_DEFAULT: DataMultiValue = []
97
-
98
- export const DATA_TREE_DEFAULT: DataTree = []
99
-
100
- export const DATA_RELATIONA_DEFAULTL: DataRelationship = {
101
- nodes: [],
102
- edges: []
103
- }
104
-
105
- // -- Data Formatter --
106
-
107
- // 基本欄位
108
- // export const DATA_FORMATTER: DataFormatterBase<ChartType> = {
109
- // // ...GLOBAL_DEFAULT,
110
- // type: ('' as any), // 後面需複蓋掉否則會有問題
111
- // }
112
- // 有value
113
- // export const DATA_FORMATTER_WITH_VALUE: DataFormatterValue = {
114
- // valueFormat: ',.0f'
115
- // }
116
- // 有axis
117
- // export const DATA_FORMATTER_WITH_AXIS: DataFormatterAxis = {
118
- // // domainMinValue: 0,
119
- // // domainMaxValue: undefined,
120
- // // domainMinRange: undefined,
121
- // // domainMaxRange: 0.9
122
- // valueDomain: [0, 'auto'],
123
- // valueRange: [0, 0.9]
124
- // }
125
-
126
- export const DATA_FORMATTER_VALUE_AXIS: DataFormatterValueAxis = {
127
- position: 'left',
128
- scaleDomain: [0, 'auto'],
129
- scaleRange: [0, 0.9],
130
- label: '',
131
- }
132
-
133
- export const DATA_FORMATTER_GROUP_AXIS: DataFormatterGroupAxis = {
134
- position: 'bottom',
135
- scaleDomain: [0, 'auto'],
136
- scalePadding: 0.5,
137
- label: ''
138
- }
139
-
140
- export const DATA_FORMATTER_SERIES_DEFAULT: DataFormatterSeries = {
141
- // ...DATA_FORMATTER_WITH_VALUE,
142
- type: 'series',
143
- visibleFilter: (datum, rowIndex, columnIndex, context) => true,
144
- // unitLabel: '',
145
- seriesLabels: [],
146
- // mapSeries: (datum, rowIndex, columnIndex, { data, dataFormatter }) => {
147
- // const seriesIndex = rowIndex >= dataFormatter.seriesLabels.length
148
- // ? rowIndex % dataFormatter.seriesLabels.length // 如果index大於所設定的seriesLabels的數量則從頭回來算
149
- // : rowIndex
150
- // return dataFormatter.seriesLabels[seriesIndex]
151
- // },
152
- // colorsPredicate: (datum, rowIndex, columnIndex, { chartParams }) => {
153
- // return rowIndex < chartParams.colors[chartParams.colorScheme].series.length
154
- // ? chartParams.colors[chartParams.colorScheme].series[rowIndex]
155
- // : chartParams.colors[chartParams.colorScheme].series[
156
- // rowIndex % chartParams.colors[chartParams.colorScheme].series.length
157
- // ]
158
- // },
159
- sort: null,
160
- }
161
-
162
- export const DATA_FORMATTER_GRID_GRID_DEFAULT: DataFormatterGridGrid = {
163
- visibleFilter: (datum, rowIndex, columnIndex, context) => true,
164
- gridData: {
165
- seriesDirection: 'row',
166
- rowLabels: [],
167
- columnLabels: [],
168
- },
169
- valueAxis: { ...DATA_FORMATTER_VALUE_AXIS },
170
- groupAxis: { ...DATA_FORMATTER_GROUP_AXIS, },
171
- slotIndex: 0,
172
- seriesSlotIndexes: null
173
- }
174
-
175
- export const DATA_FORMATTER_GRID_DEFAULT: DataFormatterGrid = {
176
- // ...DATA_FORMATTER_WITH_VALUE,
177
- type: 'grid',
178
- grid: {
179
- ...DATA_FORMATTER_GRID_GRID_DEFAULT
180
- },
181
- container: {
182
- gap: 120,
183
- rowAmount: 1,
184
- columnAmount: 1
185
- }
186
- // visibleGroupRange: null,
187
- // colorsPredicate: (datum, rowIndex, columnIndex, { chartParams, dataFormatter }) => {
188
- // const seriesIndex = dataFormatter.grid.seriesDirection === 'row' ? rowIndex : columnIndex
189
- // return chartParams.colors[chartParams.colorScheme].series[seriesIndex]
190
- // },
191
- }
192
-
193
- // export const DATA_FORMATTER_MULTI_GRID_MULTI_GRID_DEFAULT: DataFormatterMultiGridMultiGrid = {
194
- // ...DATA_FORMATTER_GRID_DEFAULT,
195
- // slotIndex: 0,
196
- // seriesSlotIndexes: null
197
- // }
198
-
199
- export const DATA_FORMATTER_MULTI_GRID_GRID_DEFAULT: DataFormatterMultiGridGrid = {
200
- ...DATA_FORMATTER_GRID_GRID_DEFAULT
201
- }
202
-
203
- export const DATA_FORMATTER_MULTI_GRID_DEFAULT: DataFormatterMultiGrid = {
204
- type: 'multiGrid',
205
- // visibleFilter: (datum, rowIndex, columnIndex, context) => true,
206
- gridList: [
207
- {
208
- ...DATA_FORMATTER_MULTI_GRID_GRID_DEFAULT
209
- },
210
- ],
211
- container: {
212
- gap: 120,
213
- rowAmount: 1,
214
- columnAmount: 1
215
- }
216
- }
217
-
218
- export const DATA_FORMATTER_MULTI_VALUE_DEFAULT: DataFormatterMultiValue = {
219
- type: 'multiValue',
220
- visibleFilter: (datum, rowIndex, columnIndex, context) => true,
221
- // labelFormat: (datum: any) => (datum && datum.label) ?? '',
222
- multiValue: [],
223
- xAxis: { ...DATA_FORMATTER_VALUE_AXIS },
224
- yAxis: { ...DATA_FORMATTER_VALUE_AXIS },
225
- }
226
-
227
- export const DATA_FORMATTER_TREE_DEFAULT: DataFormatterTree = {
228
- type: 'tree',
229
- visibleFilter: (datum, rowIndex, columnIndex, context) => true,
230
- // labelFormat: (datum: any) => (datum && datum.label) ?? '',
231
- categoryLabels: []
232
- }
233
-
234
- export const DATA_FORMATTER_RELATIONAL_DEFAULT: DataFormatterRelationship = {
235
- type: 'relationship',
236
- visibleFilter: (datum, rowIndex, columnIndex, context) => true,
237
- // node: {
238
- // // labelFormat: (node: any) => (node && node.label) ?? '',
239
- // descriptionFormat: (node: any) => (node && node.label) ?? ''
240
- // },
241
- // edge: {
242
- // // labelFormat: (edge: any) => (edge && edge.label) ?? '',
243
- // descriptionFormat: (edge: any) => (edge && edge.label) ?? ''
244
- // },
245
- }
246
-
247
- // -- Render Data --
248
-
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
+