@orbcharts/core 3.0.0-alpha.60 → 3.0.0-alpha.62

Sign up to get free protection for your applications and to get access to all the features.
Files changed (215) hide show
  1. package/LICENSE +200 -200
  2. package/dist/lib/core-types.d.ts +1 -0
  3. package/dist/orbcharts-core.es.js +3056 -2609
  4. package/dist/orbcharts-core.umd.js +6 -2
  5. package/dist/src/AbstractChart.d.ts +5 -3
  6. package/dist/src/GridChart.d.ts +1 -1
  7. package/dist/src/MultiGridChart.d.ts +1 -1
  8. package/dist/src/MultiValueChart.d.ts +1 -1
  9. package/dist/src/RelationshipChart.d.ts +1 -1
  10. package/dist/src/SeriesChart.d.ts +1 -1
  11. package/dist/src/TreeChart.d.ts +1 -1
  12. package/dist/src/base/createBaseChart.d.ts +1 -1
  13. package/dist/src/base/createBasePlugin.d.ts +1 -1
  14. package/dist/src/base/validators/chartOptionsValidator.d.ts +3 -0
  15. package/dist/src/base/validators/chartParamsValidator.d.ts +3 -0
  16. package/dist/src/base/validators/elementValidator.d.ts +3 -0
  17. package/dist/src/base/validators/pluginsValidator.d.ts +3 -0
  18. package/dist/src/defaults.d.ts +1 -16
  19. package/dist/src/defineGridPlugin.d.ts +1 -1
  20. package/dist/src/defineMultiGridPlugin.d.ts +1 -1
  21. package/dist/src/defineMultiValuePlugin.d.ts +1 -1
  22. package/dist/src/defineNoneDataPlugin.d.ts +1 -1
  23. package/dist/src/defineRelationshipPlugin.d.ts +1 -1
  24. package/dist/src/defineSeriesPlugin.d.ts +1 -1
  25. package/dist/src/defineTreePlugin.d.ts +1 -1
  26. package/dist/src/grid/computedDataFn.d.ts +4 -0
  27. package/dist/src/grid/contextObserverCallback.d.ts +3 -0
  28. package/dist/src/grid/dataFormatterValidator.d.ts +3 -0
  29. package/dist/src/grid/dataValidator.d.ts +3 -0
  30. package/dist/src/index.d.ts +1 -1
  31. package/dist/src/multiGrid/computedDataFn.d.ts +3 -0
  32. package/dist/src/multiGrid/contextObserverCallback.d.ts +3 -0
  33. package/dist/src/multiGrid/dataFormatterValidator.d.ts +3 -0
  34. package/dist/src/multiGrid/dataValidator.d.ts +3 -0
  35. package/dist/src/multiValue/computedDataFn.d.ts +3 -0
  36. package/dist/src/multiValue/contextObserverCallback.d.ts +3 -0
  37. package/dist/src/multiValue/dataFormatterValidator.d.ts +3 -0
  38. package/dist/src/multiValue/dataValidator.d.ts +3 -0
  39. package/dist/src/relationship/computedDataFn.d.ts +3 -0
  40. package/dist/src/relationship/contextObserverCallback.d.ts +3 -0
  41. package/dist/src/relationship/dataFormatterValidator.d.ts +3 -0
  42. package/dist/src/relationship/dataValidator.d.ts +3 -0
  43. package/dist/src/series/computedDataFn.d.ts +3 -0
  44. package/dist/src/series/contextObserverCallback.d.ts +3 -0
  45. package/dist/src/series/dataFormatterValidator.d.ts +3 -0
  46. package/dist/src/series/dataValidator.d.ts +3 -0
  47. package/dist/src/tree/computedDataFn.d.ts +3 -0
  48. package/dist/src/tree/contextObserverCallback.d.ts +3 -0
  49. package/dist/src/tree/dataFormatterValidator.d.ts +3 -0
  50. package/dist/src/tree/dataValidator.d.ts +3 -0
  51. package/dist/src/utils/commonUtils.d.ts +1 -0
  52. package/dist/src/utils/errorMessage.d.ts +14 -0
  53. package/dist/src/{grid → utils}/gridObservables.d.ts +2 -2
  54. package/dist/src/utils/index.d.ts +7 -3
  55. package/dist/src/{multiGrid → utils}/multiGridObservables.d.ts +1 -1
  56. package/dist/src/utils/observables.d.ts +2 -1
  57. package/dist/src/utils/orbchartsUtils.d.ts +1 -12
  58. package/dist/src/{series → utils}/seriesObservables.d.ts +3 -3
  59. package/dist/src/{tree → utils}/treeObservables.d.ts +1 -1
  60. package/dist/src/utils/validator.d.ts +3 -0
  61. package/lib/core-types.ts +7 -0
  62. package/package.json +42 -41
  63. package/src/AbstractChart.ts +57 -48
  64. package/src/GridChart.ts +24 -20
  65. package/src/MultiGridChart.ts +24 -20
  66. package/src/MultiValueChart.ts +24 -20
  67. package/src/RelationshipChart.ts +24 -20
  68. package/src/SeriesChart.ts +24 -20
  69. package/src/TreeChart.ts +24 -20
  70. package/src/base/createBaseChart.ts +500 -386
  71. package/src/base/createBasePlugin.ts +152 -95
  72. package/src/base/validators/chartOptionsValidator.ts +24 -0
  73. package/src/base/validators/chartParamsValidator.ts +134 -0
  74. package/src/base/validators/elementValidator.ts +14 -0
  75. package/src/base/validators/pluginsValidator.ts +15 -0
  76. package/src/defaults.ts +232 -226
  77. package/src/defineGridPlugin.ts +3 -3
  78. package/src/defineMultiGridPlugin.ts +3 -3
  79. package/src/defineMultiValuePlugin.ts +3 -3
  80. package/src/defineNoneDataPlugin.ts +4 -4
  81. package/src/defineRelationshipPlugin.ts +3 -3
  82. package/src/defineSeriesPlugin.ts +3 -3
  83. package/src/defineTreePlugin.ts +3 -3
  84. package/src/grid/{computeGridData.ts → computedDataFn.ts} +129 -134
  85. package/src/grid/{createGridContextObserver.ts → contextObserverCallback.ts} +155 -155
  86. package/src/grid/dataFormatterValidator.ts +9 -0
  87. package/src/grid/dataValidator.ts +9 -0
  88. package/src/index.ts +20 -21
  89. package/src/multiGrid/{computeMultiGridData.ts → computedDataFn.ts} +123 -130
  90. package/src/multiGrid/{createMultiGridContextObserver.ts → contextObserverCallback.ts} +41 -41
  91. package/src/multiGrid/dataFormatterValidator.ts +9 -0
  92. package/src/multiGrid/dataValidator.ts +9 -0
  93. package/src/multiValue/{computeMultiValueData.ts → computedDataFn.ts} +176 -179
  94. package/src/multiValue/{createMultiValueContextObserver.ts → contextObserverCallback.ts} +12 -12
  95. package/src/multiValue/dataFormatterValidator.ts +9 -0
  96. package/src/multiValue/dataValidator.ts +9 -0
  97. package/src/relationship/{computeRelationshipData.ts → computedDataFn.ts} +125 -118
  98. package/src/relationship/{createRelationshipContextObserver.ts → contextObserverCallback.ts} +12 -12
  99. package/src/relationship/dataFormatterValidator.ts +9 -0
  100. package/src/relationship/dataValidator.ts +9 -0
  101. package/src/series/{computeSeriesData.ts → computedDataFn.ts} +88 -90
  102. package/src/series/{createSeriesContextObserver.ts → contextObserverCallback.ts} +100 -93
  103. package/src/series/dataFormatterValidator.ts +9 -0
  104. package/src/series/dataValidator.ts +9 -0
  105. package/src/tree/{computeTreeData.ts → computedDataFn.ts} +130 -132
  106. package/src/tree/{createTreeContextObserver.ts → contextObserverCallback.ts} +61 -61
  107. package/src/tree/dataFormatterValidator.ts +9 -0
  108. package/src/tree/dataValidator.ts +9 -0
  109. package/src/utils/commonUtils.ts +54 -50
  110. package/src/utils/d3Utils.ts +108 -108
  111. package/src/utils/errorMessage.ts +43 -0
  112. package/src/{grid → utils}/gridObservables.ts +611 -614
  113. package/src/utils/index.ts +10 -4
  114. package/src/{multiGrid → utils}/multiGridObservables.ts +366 -365
  115. package/src/utils/observables.ts +218 -202
  116. package/src/utils/orbchartsUtils.ts +352 -349
  117. package/src/{series → utils}/seriesObservables.ts +175 -175
  118. package/src/{tree → utils}/treeObservables.ts +94 -94
  119. package/src/utils/validator.ts +126 -0
  120. package/tsconfig.base.json +13 -13
  121. package/tsconfig.json +2 -2
  122. package/vite-env.d.ts +7 -0
  123. package/vite.config.js +22 -22
  124. package/dist/src/grid/computeGridData.d.ts +0 -6
  125. package/dist/src/grid/createGridContextObserver.d.ts +0 -3
  126. package/dist/src/multiGrid/computeMultiGridData.d.ts +0 -3
  127. package/dist/src/multiGrid/createMultiGridContextObserver.d.ts +0 -3
  128. package/dist/src/multiValue/computeMultiValueData.d.ts +0 -3
  129. package/dist/src/multiValue/createMultiValueContextObserver.d.ts +0 -3
  130. package/dist/src/relationship/computeRelationshipData.d.ts +0 -3
  131. package/dist/src/relationship/createRelationshipContextObserver.d.ts +0 -3
  132. package/dist/src/series/computeSeriesData.d.ts +0 -3
  133. package/dist/src/series/createSeriesContextObserver.d.ts +0 -3
  134. package/dist/src/tree/computeTreeData.d.ts +0 -3
  135. package/dist/src/tree/createTreeContextObserver.d.ts +0 -3
  136. package/dist/src/types/Axis.d.ts +0 -1
  137. package/dist/src/types/Chart.d.ts +0 -45
  138. package/dist/src/types/ChartParams.d.ts +0 -36
  139. package/dist/src/types/ComputedData.d.ts +0 -42
  140. package/dist/src/types/ComputedDataGrid.d.ts +0 -5
  141. package/dist/src/types/ComputedDataMultiGrid.d.ts +0 -3
  142. package/dist/src/types/ComputedDataMultiValue.d.ts +0 -6
  143. package/dist/src/types/ComputedDataRelationship.d.ts +0 -18
  144. package/dist/src/types/ComputedDataSeries.d.ts +0 -5
  145. package/dist/src/types/ComputedDataTree.d.ts +0 -7
  146. package/dist/src/types/ContextObserver.d.ts +0 -28
  147. package/dist/src/types/ContextObserverGrid.d.ts +0 -41
  148. package/dist/src/types/ContextObserverMultiGrid.d.ts +0 -15
  149. package/dist/src/types/ContextObserverMultiValue.d.ts +0 -4
  150. package/dist/src/types/ContextObserverRelationship.d.ts +0 -4
  151. package/dist/src/types/ContextObserverSeries.d.ts +0 -27
  152. package/dist/src/types/ContextObserverTree.d.ts +0 -11
  153. package/dist/src/types/ContextSubject.d.ts +0 -15
  154. package/dist/src/types/Data.d.ts +0 -19
  155. package/dist/src/types/DataFormatter.d.ts +0 -41
  156. package/dist/src/types/DataFormatterGrid.d.ts +0 -34
  157. package/dist/src/types/DataFormatterMultiGrid.d.ts +0 -20
  158. package/dist/src/types/DataFormatterMultiValue.d.ts +0 -18
  159. package/dist/src/types/DataFormatterRelationship.d.ts +0 -10
  160. package/dist/src/types/DataFormatterSeries.d.ts +0 -19
  161. package/dist/src/types/DataFormatterTree.d.ts +0 -7
  162. package/dist/src/types/DataGrid.d.ts +0 -6
  163. package/dist/src/types/DataMultiGrid.d.ts +0 -6
  164. package/dist/src/types/DataMultiValue.d.ts +0 -7
  165. package/dist/src/types/DataRelationship.d.ts +0 -21
  166. package/dist/src/types/DataSeries.d.ts +0 -6
  167. package/dist/src/types/DataTree.d.ts +0 -15
  168. package/dist/src/types/Event.d.ts +0 -56
  169. package/dist/src/types/Layout.d.ts +0 -8
  170. package/dist/src/types/Padding.d.ts +0 -6
  171. package/dist/src/types/Plugin.d.ts +0 -37
  172. package/dist/src/types/TransformData.d.ts +0 -8
  173. package/dist/src/types/index.d.ts +0 -37
  174. package/src/types/Axis.ts +0 -1
  175. package/src/types/Chart.ts +0 -54
  176. package/src/types/ChartParams.ts +0 -51
  177. package/src/types/ComputedData.ts +0 -84
  178. package/src/types/ComputedDataGrid.ts +0 -14
  179. package/src/types/ComputedDataMultiGrid.ts +0 -3
  180. package/src/types/ComputedDataMultiValue.ts +0 -9
  181. package/src/types/ComputedDataRelationship.ts +0 -20
  182. package/src/types/ComputedDataSeries.ts +0 -8
  183. package/src/types/ComputedDataTree.ts +0 -20
  184. package/src/types/ContextObserver.ts +0 -38
  185. package/src/types/ContextObserverGrid.ts +0 -43
  186. package/src/types/ContextObserverMultiGrid.ts +0 -17
  187. package/src/types/ContextObserverMultiValue.ts +0 -5
  188. package/src/types/ContextObserverRelationship.ts +0 -5
  189. package/src/types/ContextObserverSeries.ts +0 -29
  190. package/src/types/ContextObserverTree.ts +0 -11
  191. package/src/types/ContextSubject.ts +0 -18
  192. package/src/types/Data.ts +0 -45
  193. package/src/types/DataFormatter.ts +0 -74
  194. package/src/types/DataFormatterGrid.ts +0 -68
  195. package/src/types/DataFormatterMultiGrid.ts +0 -45
  196. package/src/types/DataFormatterMultiValue.ts +0 -24
  197. package/src/types/DataFormatterRelationship.ts +0 -26
  198. package/src/types/DataFormatterSeries.ts +0 -20
  199. package/src/types/DataFormatterTree.ts +0 -12
  200. package/src/types/DataGrid.ts +0 -11
  201. package/src/types/DataMultiGrid.ts +0 -7
  202. package/src/types/DataMultiValue.ts +0 -12
  203. package/src/types/DataRelationship.ts +0 -28
  204. package/src/types/DataSeries.ts +0 -11
  205. package/src/types/DataTree.ts +0 -20
  206. package/src/types/Event.ts +0 -153
  207. package/src/types/Layout.ts +0 -12
  208. package/src/types/Padding.ts +0 -6
  209. package/src/types/Plugin.ts +0 -60
  210. package/src/types/TransformData.ts +0 -8
  211. package/src/types/index.ts +0 -37
  212. /package/dist/src/{multiValue → utils}/multiValueObservables.d.ts +0 -0
  213. /package/dist/src/{relationship → utils}/relationshipObservables.d.ts +0 -0
  214. /package/src/{multiValue → utils}/multiValueObservables.ts +0 -0
  215. /package/src/{relationship → utils}/relationshipObservables.ts +0 -0
package/src/defaults.ts CHANGED
@@ -1,226 +1,232 @@
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: ['auto', '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, 'max'],
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
- DATA_FORMATTER_SERIES_DEFAULT.visibleFilter.toString = () => `(datum, context) => true`
145
-
146
- export const DATA_FORMATTER_GRID_GRID_DEFAULT: DataFormatterGridGrid = {
147
- seriesDirection: 'row',
148
- rowLabels: [],
149
- columnLabels: [],
150
- valueAxis: { ...DATA_FORMATTER_VALUE_AXIS_DEFAULT },
151
- groupAxis: { ...DATA_FORMATTER_GROUP_AXIS_DEFAULT, },
152
- separateSeries: false,
153
- // slotIndex: 0,
154
- // seriesSlotIndexes: null
155
- }
156
-
157
- export const DATA_FORMATTER_GRID_DEFAULT: DataFormatterGrid = {
158
- type: 'grid',
159
- visibleFilter: (datum, context) => true,
160
- grid: {
161
- ...DATA_FORMATTER_GRID_GRID_DEFAULT
162
- },
163
- container: {
164
- ...DATA_FORMATTER_CONTAINER_DEFAULT
165
- }
166
- }
167
- DATA_FORMATTER_GRID_DEFAULT.visibleFilter.toString = () => `(datum, context) => true`
168
-
169
- // export const DATA_FORMATTER_MULTI_GRID_MULTI_GRID_DEFAULT: DataFormatterMultiGridMultiGrid = {
170
- // ...DATA_FORMATTER_GRID_DEFAULT,
171
- // slotIndex: 0,
172
- // seriesSlotIndexes: null
173
- // }
174
-
175
- export const DATA_FORMATTER_MULTI_GRID_GRID_DEFAULT: DataFormatterMultiGridGrid = {
176
- ...DATA_FORMATTER_GRID_GRID_DEFAULT
177
- }
178
-
179
- export const DATA_FORMATTER_MULTI_GRID_DEFAULT: DataFormatterMultiGrid = {
180
- type: 'multiGrid',
181
- visibleFilter: (datum, context) => true,
182
- gridList: [
183
- {
184
- ...DATA_FORMATTER_MULTI_GRID_GRID_DEFAULT
185
- },
186
- ],
187
- separateGrid: false,
188
- container: {
189
- ...DATA_FORMATTER_CONTAINER_DEFAULT
190
- }
191
- }
192
- DATA_FORMATTER_MULTI_GRID_DEFAULT.visibleFilter.toString = () => `(datum, context) => true`
193
-
194
- export const DATA_FORMATTER_MULTI_VALUE_DEFAULT: DataFormatterMultiValue = {
195
- type: 'multiValue',
196
- visibleFilter: (datum, context) => true,
197
- categoryLabels: [],
198
- multiValue: [],
199
- xAxis: { ...DATA_FORMATTER_VALUE_AXIS_DEFAULT },
200
- yAxis: { ...DATA_FORMATTER_VALUE_AXIS_DEFAULT },
201
- }
202
- DATA_FORMATTER_MULTI_VALUE_DEFAULT.visibleFilter.toString = () => `(datum, context) => true`
203
-
204
- export const DATA_FORMATTER_TREE_DEFAULT: DataFormatterTree = {
205
- type: 'tree',
206
- visibleFilter: (datum, context) => true,
207
- // labelFormat: (datum: any) => (datum && datum.label) ?? '',
208
- categoryLabels: []
209
- }
210
- DATA_FORMATTER_TREE_DEFAULT.visibleFilter.toString = () => `(datum, context) => true`
211
-
212
- export const DATA_FORMATTER_RELATIONAL_DEFAULT: DataFormatterRelationship = {
213
- type: 'relationship',
214
- visibleFilter: (datum, context) => true,
215
- categoryLabels: []
216
- // node: {
217
- // // labelFormat: (node: any) => (node && node.label) ?? '',
218
- // descriptionFormat: (node: any) => (node && node.label) ?? ''
219
- // },
220
- // edge: {
221
- // // labelFormat: (edge: any) => (edge && edge.label) ?? '',
222
- // descriptionFormat: (edge: any) => (edge && edge.label) ?? ''
223
- // },
224
- }
225
- DATA_FORMATTER_RELATIONAL_DEFAULT.visibleFilter.toString = () => `(datum, context) => true`
226
-
1
+ import type {
2
+ ChartOptionsPartial,
3
+ DataSeries,
4
+ DataGrid,
5
+ DataMultiGrid,
6
+ DataMultiValue,
7
+ DataTree,
8
+ DataRelationship,
9
+ DataFormatterValueAxis,
10
+ DataFormatterGroupAxis,
11
+ DataFormatterContainer,
12
+ DataFormatterSeries,
13
+ DataFormatterGrid,
14
+ DataFormatterGridGrid,
15
+ DataFormatterMultiGrid,
16
+ DataFormatterMultiGridGrid,
17
+ DataFormatterMultiValue,
18
+ DataFormatterTree,
19
+ DataFormatterRelationship,
20
+ ChartParams,
21
+ Padding
22
+ } from '../lib/core-types'
23
+
24
+ export const CHART_OPTIONS_DEFAULT: ChartOptionsPartial<any> = {
25
+ // preset: {} // 預設為空
26
+ width: 'auto',
27
+ height: 'auto'
28
+ }
29
+
30
+ // export const GLOBAL_DEFAULT: ChartGlobalDefault = {
31
+ // colors: ['#67B7DC', '#6794DC', '#6771DC', '#8067DC', '#A367DC', '#C767DC', '#DC67CE', '#DC67AB', '#DC6788', '#DC6967', '#DC8C67', '#DCAF67'],
32
+ // padding: {
33
+ // top: 50,
34
+ // right: 70,
35
+ // bottom: 50,
36
+ // left: 70
37
+ // },
38
+ // // chartWidth: '100%',
39
+ // // chartHeight: 500
40
+ // }
41
+
42
+ // export const COLORS_DEFAULT = ['#67B7DC', '#6794DC', '#6771DC', '#8067DC', '#A367DC', '#C767DC', '#DC67CE', '#DC67AB', '#DC6788', '#DC6967', '#DC8C67', '#DCAF67']
43
+ // ['#ff7ab9', '#66dec8', '#84c8ff', '#30ad1b', '#f8c43e', '#fa5640', '#9d79d7', '#ea4f98']
44
+
45
+ export const PADDING_DEFAULT: Padding = {
46
+ top: 60,
47
+ right: 60,
48
+ bottom: 60,
49
+ left: 60
50
+ }
51
+
52
+ export const CHART_PARAMS_DEFAULT: ChartParams = {
53
+ padding: PADDING_DEFAULT,
54
+ highlightTarget: 'datum',
55
+ highlightDefault: null,
56
+ colorScheme: 'light',
57
+ colors: {
58
+ light: {
59
+ series: ['#67B7DC', '#6794DC', '#6771DC', '#8067DC', '#A367DC', '#C767DC', '#DC67CE', '#DC67AB', '#DC6788', '#DC6967', '#DC8C67', '#DCAF67'],
60
+ // primary: '#454545',
61
+ primary: '#1b1e23',
62
+ secondary: '#e1e1e1',
63
+ white: '#ffffff',
64
+ background: '#ffffff'
65
+ },
66
+ dark: {
67
+ series: ['#67B7DC', '#6794DC', '#6771DC', '#8067DC', '#A367DC', '#C767DC', '#DC67CE', '#DC67AB', '#DC6788', '#DC6967', '#DC8C67', '#DCAF67'],
68
+ primary: '#f0f0f0',
69
+ secondary: '#e1e1e1',
70
+ white: '#ffffff',
71
+ background: '#000000'
72
+ }
73
+ },
74
+ styles: {
75
+ // textSize: 14,
76
+ textSize: '0.875rem',
77
+ unhighlightedOpacity: 0.3
78
+ },
79
+ transitionDuration: 800,
80
+ transitionEase: 'easeCubic'
81
+ }
82
+
83
+ export const CHART_WIDTH_DEFAULT = 800
84
+
85
+ export const CHART_HEIGHT_DEFAULT = 500
86
+
87
+ // -- Data --
88
+
89
+ export const DATA_SERIES_DEFAULT: DataSeries = []
90
+
91
+ export const DATA_GRID_DEFAULT: DataGrid = []
92
+
93
+ export const DATA_MULTI_GRID_DEFAULT: DataMultiGrid = []
94
+
95
+ export const DATA_MULTI_VALUE_DEFAULT: DataMultiValue = []
96
+
97
+ export const DATA_TREE_DEFAULT: DataTree = []
98
+
99
+ export const DATA_RELATIONA_DEFAULTL: DataRelationship = {
100
+ nodes: [],
101
+ edges: []
102
+ }
103
+
104
+ // -- Data Formatter --
105
+
106
+ export const DATA_FORMATTER_VALUE_AXIS_DEFAULT: DataFormatterValueAxis = {
107
+ position: 'left',
108
+ scaleDomain: ['auto', 'auto'],
109
+ scaleRange: [0, 0.9],
110
+ label: '',
111
+ }
112
+
113
+ export const DATA_FORMATTER_GROUP_AXIS_DEFAULT: DataFormatterGroupAxis = {
114
+ position: 'bottom',
115
+ scaleDomain: [0, 'max'],
116
+ scalePadding: 0.5,
117
+ label: ''
118
+ }
119
+
120
+ export const DATA_FORMATTER_CONTAINER_DEFAULT: DataFormatterContainer = {
121
+ gap: 120,
122
+ rowAmount: 1,
123
+ columnAmount: 1
124
+ }
125
+
126
+ export const DATA_FORMATTER_SERIES_DEFAULT: DataFormatterSeries = {
127
+ type: 'series',
128
+ visibleFilter: (datum, context) => true,
129
+ sort: null,
130
+ seriesLabels: [],
131
+ container: {
132
+ ...DATA_FORMATTER_CONTAINER_DEFAULT
133
+ },
134
+ separateSeries: false,
135
+ sumSeries: false
136
+ // mapSeries: (datum, rowIndex, columnIndex, { data, dataFormatter }) => {
137
+ // const seriesIndex = rowIndex >= dataFormatter.seriesLabels.length
138
+ // ? rowIndex % dataFormatter.seriesLabels.length // 如果index大於所設定的seriesLabels的數量則從頭回來算
139
+ // : rowIndex
140
+ // return dataFormatter.seriesLabels[seriesIndex]
141
+ // },
142
+ // colorsPredicate: (datum, rowIndex, columnIndex, { chartParams }) => {
143
+ // return rowIndex < chartParams.colors[chartParams.colorScheme].series.length
144
+ // ? chartParams.colors[chartParams.colorScheme].series[rowIndex]
145
+ // : chartParams.colors[chartParams.colorScheme].series[
146
+ // rowIndex % chartParams.colors[chartParams.colorScheme].series.length
147
+ // ]
148
+ // },
149
+ }
150
+ DATA_FORMATTER_SERIES_DEFAULT.visibleFilter.toString = () => `(datum, context) => true`
151
+
152
+ export const DATA_FORMATTER_GRID_GRID_DEFAULT: DataFormatterGridGrid = {
153
+ seriesDirection: 'row',
154
+ rowLabels: [],
155
+ columnLabels: [],
156
+ valueAxis: { ...DATA_FORMATTER_VALUE_AXIS_DEFAULT },
157
+ groupAxis: { ...DATA_FORMATTER_GROUP_AXIS_DEFAULT, },
158
+ separateSeries: false,
159
+ // slotIndex: 0,
160
+ // seriesSlotIndexes: null
161
+ }
162
+
163
+ export const DATA_FORMATTER_GRID_DEFAULT: DataFormatterGrid = {
164
+ type: 'grid',
165
+ visibleFilter: (datum, context) => true,
166
+ grid: {
167
+ ...DATA_FORMATTER_GRID_GRID_DEFAULT
168
+ },
169
+ container: {
170
+ ...DATA_FORMATTER_CONTAINER_DEFAULT
171
+ }
172
+ }
173
+ DATA_FORMATTER_GRID_DEFAULT.visibleFilter.toString = () => `(datum, context) => true`
174
+
175
+ // export const DATA_FORMATTER_MULTI_GRID_MULTI_GRID_DEFAULT: DataFormatterMultiGridMultiGrid = {
176
+ // ...DATA_FORMATTER_GRID_DEFAULT,
177
+ // slotIndex: 0,
178
+ // seriesSlotIndexes: null
179
+ // }
180
+
181
+ export const DATA_FORMATTER_MULTI_GRID_GRID_DEFAULT: DataFormatterMultiGridGrid = {
182
+ ...DATA_FORMATTER_GRID_GRID_DEFAULT
183
+ }
184
+
185
+ export const DATA_FORMATTER_MULTI_GRID_DEFAULT: DataFormatterMultiGrid = {
186
+ type: 'multiGrid',
187
+ visibleFilter: (datum, context) => true,
188
+ gridList: [
189
+ {
190
+ ...DATA_FORMATTER_MULTI_GRID_GRID_DEFAULT
191
+ },
192
+ ],
193
+ separateGrid: false,
194
+ container: {
195
+ ...DATA_FORMATTER_CONTAINER_DEFAULT
196
+ }
197
+ }
198
+ DATA_FORMATTER_MULTI_GRID_DEFAULT.visibleFilter.toString = () => `(datum, context) => true`
199
+
200
+ export const DATA_FORMATTER_MULTI_VALUE_DEFAULT: DataFormatterMultiValue = {
201
+ type: 'multiValue',
202
+ visibleFilter: (datum, context) => true,
203
+ categoryLabels: [],
204
+ multiValue: [],
205
+ xAxis: { ...DATA_FORMATTER_VALUE_AXIS_DEFAULT },
206
+ yAxis: { ...DATA_FORMATTER_VALUE_AXIS_DEFAULT },
207
+ }
208
+ DATA_FORMATTER_MULTI_VALUE_DEFAULT.visibleFilter.toString = () => `(datum, context) => true`
209
+
210
+ export const DATA_FORMATTER_TREE_DEFAULT: DataFormatterTree = {
211
+ type: 'tree',
212
+ visibleFilter: (datum, context) => true,
213
+ // labelFormat: (datum: any) => (datum && datum.label) ?? '',
214
+ categoryLabels: []
215
+ }
216
+ DATA_FORMATTER_TREE_DEFAULT.visibleFilter.toString = () => `(datum, context) => true`
217
+
218
+ export const DATA_FORMATTER_RELATIONAL_DEFAULT: DataFormatterRelationship = {
219
+ type: 'relationship',
220
+ visibleFilter: (datum, context) => true,
221
+ categoryLabels: []
222
+ // node: {
223
+ // // labelFormat: (node: any) => (node && node.label) ?? '',
224
+ // descriptionFormat: (node: any) => (node && node.label) ?? ''
225
+ // },
226
+ // edge: {
227
+ // // labelFormat: (edge: any) => (edge && edge.label) ?? '',
228
+ // descriptionFormat: (edge: any) => (edge && edge.label) ?? ''
229
+ // },
230
+ }
231
+ DATA_FORMATTER_RELATIONAL_DEFAULT.visibleFilter.toString = () => `(datum, context) => true`
232
+
@@ -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')
@@ -1,4 +1,4 @@
1
- import { createBasePlugin } from './base/createBasePlugin'
2
- import { ChartType } from './types/Chart'
3
-
4
- export const defineNoneDataPlugin = createBasePlugin<any>() // noneDataPlugin 可以使用在任何的 chartType
1
+ import { createBasePlugin } from './base/createBasePlugin'
2
+
3
+ // chartType型別使用 'any' 是為了讓 plugin entity 能夠被加入到所有類別的 chart.plugins$ 中
4
+ export const defineNoneDataPlugin = createBasePlugin<any>('noneData')
@@ -1,3 +1,3 @@
1
- import { createBasePlugin } from './base/createBasePlugin'
2
-
3
- export const defineRelationshipPlugin = createBasePlugin<'relationship'>()
1
+ import { createBasePlugin } from './base/createBasePlugin'
2
+
3
+ export const defineRelationshipPlugin = createBasePlugin('relationship')
@@ -1,3 +1,3 @@
1
- import { createBasePlugin } from './base/createBasePlugin'
2
-
3
- export const defineSeriesPlugin = createBasePlugin<'series'>()
1
+ import { createBasePlugin } from './base/createBasePlugin'
2
+
3
+ export const defineSeriesPlugin = createBasePlugin('series')
@@ -1,3 +1,3 @@
1
- import { createBasePlugin } from './base/createBasePlugin'
2
-
3
- export const defineTreePlugin = createBasePlugin<'tree'>()
1
+ import { createBasePlugin } from './base/createBasePlugin'
2
+
3
+ export const defineTreePlugin = createBasePlugin('tree')