@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.
- package/LICENSE +200 -200
- package/dist/lib/core-types.d.ts +1 -0
- package/dist/orbcharts-core.es.js +3056 -2609
- package/dist/orbcharts-core.umd.js +6 -2
- package/dist/src/AbstractChart.d.ts +5 -3
- package/dist/src/GridChart.d.ts +1 -1
- package/dist/src/MultiGridChart.d.ts +1 -1
- package/dist/src/MultiValueChart.d.ts +1 -1
- package/dist/src/RelationshipChart.d.ts +1 -1
- package/dist/src/SeriesChart.d.ts +1 -1
- package/dist/src/TreeChart.d.ts +1 -1
- package/dist/src/base/createBaseChart.d.ts +1 -1
- package/dist/src/base/createBasePlugin.d.ts +1 -1
- package/dist/src/base/validators/chartOptionsValidator.d.ts +3 -0
- package/dist/src/base/validators/chartParamsValidator.d.ts +3 -0
- package/dist/src/base/validators/elementValidator.d.ts +3 -0
- package/dist/src/base/validators/pluginsValidator.d.ts +3 -0
- package/dist/src/defaults.d.ts +1 -16
- package/dist/src/defineGridPlugin.d.ts +1 -1
- package/dist/src/defineMultiGridPlugin.d.ts +1 -1
- package/dist/src/defineMultiValuePlugin.d.ts +1 -1
- package/dist/src/defineNoneDataPlugin.d.ts +1 -1
- package/dist/src/defineRelationshipPlugin.d.ts +1 -1
- package/dist/src/defineSeriesPlugin.d.ts +1 -1
- package/dist/src/defineTreePlugin.d.ts +1 -1
- package/dist/src/grid/computedDataFn.d.ts +4 -0
- package/dist/src/grid/contextObserverCallback.d.ts +3 -0
- package/dist/src/grid/dataFormatterValidator.d.ts +3 -0
- package/dist/src/grid/dataValidator.d.ts +3 -0
- package/dist/src/index.d.ts +1 -1
- package/dist/src/multiGrid/computedDataFn.d.ts +3 -0
- package/dist/src/multiGrid/contextObserverCallback.d.ts +3 -0
- package/dist/src/multiGrid/dataFormatterValidator.d.ts +3 -0
- package/dist/src/multiGrid/dataValidator.d.ts +3 -0
- package/dist/src/multiValue/computedDataFn.d.ts +3 -0
- package/dist/src/multiValue/contextObserverCallback.d.ts +3 -0
- package/dist/src/multiValue/dataFormatterValidator.d.ts +3 -0
- package/dist/src/multiValue/dataValidator.d.ts +3 -0
- package/dist/src/relationship/computedDataFn.d.ts +3 -0
- package/dist/src/relationship/contextObserverCallback.d.ts +3 -0
- package/dist/src/relationship/dataFormatterValidator.d.ts +3 -0
- package/dist/src/relationship/dataValidator.d.ts +3 -0
- package/dist/src/series/computedDataFn.d.ts +3 -0
- package/dist/src/series/contextObserverCallback.d.ts +3 -0
- package/dist/src/series/dataFormatterValidator.d.ts +3 -0
- package/dist/src/series/dataValidator.d.ts +3 -0
- package/dist/src/tree/computedDataFn.d.ts +3 -0
- package/dist/src/tree/contextObserverCallback.d.ts +3 -0
- package/dist/src/tree/dataFormatterValidator.d.ts +3 -0
- package/dist/src/tree/dataValidator.d.ts +3 -0
- package/dist/src/utils/commonUtils.d.ts +1 -0
- package/dist/src/utils/errorMessage.d.ts +14 -0
- package/dist/src/{grid → utils}/gridObservables.d.ts +2 -2
- package/dist/src/utils/index.d.ts +7 -3
- package/dist/src/{multiGrid → utils}/multiGridObservables.d.ts +1 -1
- package/dist/src/utils/observables.d.ts +2 -1
- package/dist/src/utils/orbchartsUtils.d.ts +1 -12
- package/dist/src/{series → utils}/seriesObservables.d.ts +3 -3
- package/dist/src/{tree → utils}/treeObservables.d.ts +1 -1
- package/dist/src/utils/validator.d.ts +3 -0
- package/lib/core-types.ts +7 -0
- package/package.json +42 -41
- package/src/AbstractChart.ts +57 -48
- package/src/GridChart.ts +24 -20
- package/src/MultiGridChart.ts +24 -20
- package/src/MultiValueChart.ts +24 -20
- package/src/RelationshipChart.ts +24 -20
- package/src/SeriesChart.ts +24 -20
- package/src/TreeChart.ts +24 -20
- package/src/base/createBaseChart.ts +500 -386
- package/src/base/createBasePlugin.ts +152 -95
- package/src/base/validators/chartOptionsValidator.ts +24 -0
- package/src/base/validators/chartParamsValidator.ts +134 -0
- package/src/base/validators/elementValidator.ts +14 -0
- package/src/base/validators/pluginsValidator.ts +15 -0
- package/src/defaults.ts +232 -226
- 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 → computedDataFn.ts} +129 -134
- package/src/grid/{createGridContextObserver.ts → contextObserverCallback.ts} +155 -155
- package/src/grid/dataFormatterValidator.ts +9 -0
- package/src/grid/dataValidator.ts +9 -0
- package/src/index.ts +20 -21
- package/src/multiGrid/{computeMultiGridData.ts → computedDataFn.ts} +123 -130
- package/src/multiGrid/{createMultiGridContextObserver.ts → contextObserverCallback.ts} +41 -41
- package/src/multiGrid/dataFormatterValidator.ts +9 -0
- package/src/multiGrid/dataValidator.ts +9 -0
- package/src/multiValue/{computeMultiValueData.ts → computedDataFn.ts} +176 -179
- package/src/multiValue/{createMultiValueContextObserver.ts → contextObserverCallback.ts} +12 -12
- package/src/multiValue/dataFormatterValidator.ts +9 -0
- package/src/multiValue/dataValidator.ts +9 -0
- package/src/relationship/{computeRelationshipData.ts → computedDataFn.ts} +125 -118
- package/src/relationship/{createRelationshipContextObserver.ts → contextObserverCallback.ts} +12 -12
- package/src/relationship/dataFormatterValidator.ts +9 -0
- package/src/relationship/dataValidator.ts +9 -0
- package/src/series/{computeSeriesData.ts → computedDataFn.ts} +88 -90
- package/src/series/{createSeriesContextObserver.ts → contextObserverCallback.ts} +100 -93
- package/src/series/dataFormatterValidator.ts +9 -0
- package/src/series/dataValidator.ts +9 -0
- package/src/tree/{computeTreeData.ts → computedDataFn.ts} +130 -132
- package/src/tree/{createTreeContextObserver.ts → contextObserverCallback.ts} +61 -61
- package/src/tree/dataFormatterValidator.ts +9 -0
- package/src/tree/dataValidator.ts +9 -0
- package/src/utils/commonUtils.ts +54 -50
- package/src/utils/d3Utils.ts +108 -108
- package/src/utils/errorMessage.ts +43 -0
- package/src/{grid → utils}/gridObservables.ts +611 -614
- package/src/utils/index.ts +10 -4
- package/src/{multiGrid → utils}/multiGridObservables.ts +366 -365
- package/src/utils/observables.ts +218 -202
- package/src/utils/orbchartsUtils.ts +352 -349
- package/src/{series → utils}/seriesObservables.ts +175 -175
- package/src/{tree → utils}/treeObservables.ts +94 -94
- package/src/utils/validator.ts +126 -0
- package/tsconfig.base.json +13 -13
- package/tsconfig.json +2 -2
- package/vite-env.d.ts +7 -0
- package/vite.config.js +22 -22
- package/dist/src/grid/computeGridData.d.ts +0 -6
- package/dist/src/grid/createGridContextObserver.d.ts +0 -3
- package/dist/src/multiGrid/computeMultiGridData.d.ts +0 -3
- package/dist/src/multiGrid/createMultiGridContextObserver.d.ts +0 -3
- package/dist/src/multiValue/computeMultiValueData.d.ts +0 -3
- package/dist/src/multiValue/createMultiValueContextObserver.d.ts +0 -3
- package/dist/src/relationship/computeRelationshipData.d.ts +0 -3
- package/dist/src/relationship/createRelationshipContextObserver.d.ts +0 -3
- package/dist/src/series/computeSeriesData.d.ts +0 -3
- package/dist/src/series/createSeriesContextObserver.d.ts +0 -3
- package/dist/src/tree/computeTreeData.d.ts +0 -3
- package/dist/src/tree/createTreeContextObserver.d.ts +0 -3
- package/dist/src/types/Axis.d.ts +0 -1
- package/dist/src/types/Chart.d.ts +0 -45
- package/dist/src/types/ChartParams.d.ts +0 -36
- package/dist/src/types/ComputedData.d.ts +0 -42
- package/dist/src/types/ComputedDataGrid.d.ts +0 -5
- package/dist/src/types/ComputedDataMultiGrid.d.ts +0 -3
- package/dist/src/types/ComputedDataMultiValue.d.ts +0 -6
- package/dist/src/types/ComputedDataRelationship.d.ts +0 -18
- package/dist/src/types/ComputedDataSeries.d.ts +0 -5
- package/dist/src/types/ComputedDataTree.d.ts +0 -7
- package/dist/src/types/ContextObserver.d.ts +0 -28
- package/dist/src/types/ContextObserverGrid.d.ts +0 -41
- package/dist/src/types/ContextObserverMultiGrid.d.ts +0 -15
- package/dist/src/types/ContextObserverMultiValue.d.ts +0 -4
- package/dist/src/types/ContextObserverRelationship.d.ts +0 -4
- package/dist/src/types/ContextObserverSeries.d.ts +0 -27
- package/dist/src/types/ContextObserverTree.d.ts +0 -11
- package/dist/src/types/ContextSubject.d.ts +0 -15
- package/dist/src/types/Data.d.ts +0 -19
- package/dist/src/types/DataFormatter.d.ts +0 -41
- package/dist/src/types/DataFormatterGrid.d.ts +0 -34
- package/dist/src/types/DataFormatterMultiGrid.d.ts +0 -20
- package/dist/src/types/DataFormatterMultiValue.d.ts +0 -18
- package/dist/src/types/DataFormatterRelationship.d.ts +0 -10
- package/dist/src/types/DataFormatterSeries.d.ts +0 -19
- package/dist/src/types/DataFormatterTree.d.ts +0 -7
- package/dist/src/types/DataGrid.d.ts +0 -6
- package/dist/src/types/DataMultiGrid.d.ts +0 -6
- package/dist/src/types/DataMultiValue.d.ts +0 -7
- package/dist/src/types/DataRelationship.d.ts +0 -21
- package/dist/src/types/DataSeries.d.ts +0 -6
- package/dist/src/types/DataTree.d.ts +0 -15
- package/dist/src/types/Event.d.ts +0 -56
- package/dist/src/types/Layout.d.ts +0 -8
- package/dist/src/types/Padding.d.ts +0 -6
- package/dist/src/types/Plugin.d.ts +0 -37
- package/dist/src/types/TransformData.d.ts +0 -8
- package/dist/src/types/index.d.ts +0 -37
- package/src/types/Axis.ts +0 -1
- package/src/types/Chart.ts +0 -54
- package/src/types/ChartParams.ts +0 -51
- package/src/types/ComputedData.ts +0 -84
- package/src/types/ComputedDataGrid.ts +0 -14
- package/src/types/ComputedDataMultiGrid.ts +0 -3
- package/src/types/ComputedDataMultiValue.ts +0 -9
- package/src/types/ComputedDataRelationship.ts +0 -20
- package/src/types/ComputedDataSeries.ts +0 -8
- package/src/types/ComputedDataTree.ts +0 -20
- package/src/types/ContextObserver.ts +0 -38
- package/src/types/ContextObserverGrid.ts +0 -43
- package/src/types/ContextObserverMultiGrid.ts +0 -17
- package/src/types/ContextObserverMultiValue.ts +0 -5
- package/src/types/ContextObserverRelationship.ts +0 -5
- package/src/types/ContextObserverSeries.ts +0 -29
- package/src/types/ContextObserverTree.ts +0 -11
- package/src/types/ContextSubject.ts +0 -18
- package/src/types/Data.ts +0 -45
- package/src/types/DataFormatter.ts +0 -74
- package/src/types/DataFormatterGrid.ts +0 -68
- package/src/types/DataFormatterMultiGrid.ts +0 -45
- package/src/types/DataFormatterMultiValue.ts +0 -24
- package/src/types/DataFormatterRelationship.ts +0 -26
- package/src/types/DataFormatterSeries.ts +0 -20
- package/src/types/DataFormatterTree.ts +0 -12
- package/src/types/DataGrid.ts +0 -11
- package/src/types/DataMultiGrid.ts +0 -7
- package/src/types/DataMultiValue.ts +0 -12
- package/src/types/DataRelationship.ts +0 -28
- package/src/types/DataSeries.ts +0 -11
- package/src/types/DataTree.ts +0 -20
- package/src/types/Event.ts +0 -153
- package/src/types/Layout.ts +0 -12
- package/src/types/Padding.ts +0 -6
- package/src/types/Plugin.ts +0 -60
- package/src/types/TransformData.ts +0 -8
- package/src/types/index.ts +0 -37
- /package/dist/src/{multiValue → utils}/multiValueObservables.d.ts +0 -0
- /package/dist/src/{relationship → utils}/relationshipObservables.d.ts +0 -0
- /package/src/{multiValue → utils}/multiValueObservables.ts +0 -0
- /package/src/{relationship → utils}/relationshipObservables.ts +0 -0
@@ -1,366 +1,367 @@
|
|
1
|
-
import {
|
2
|
-
combineLatest,
|
3
|
-
distinctUntilChanged,
|
4
|
-
filter,
|
5
|
-
of,
|
6
|
-
map,
|
7
|
-
merge,
|
8
|
-
takeUntil,
|
9
|
-
shareReplay,
|
10
|
-
switchMap,
|
11
|
-
Subject,
|
12
|
-
Observable,
|
13
|
-
combineLatestAll} from 'rxjs'
|
14
|
-
import type {
|
15
|
-
AxisPosition,
|
16
|
-
ChartType,
|
17
|
-
ChartParams,
|
18
|
-
ComputedDataTypeMap,
|
19
|
-
ComputedDataGrid,
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
import {
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
//
|
87
|
-
//
|
88
|
-
//
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
const
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
//
|
120
|
-
//
|
121
|
-
//
|
122
|
-
//
|
123
|
-
//
|
124
|
-
//
|
125
|
-
|
126
|
-
|
127
|
-
//
|
128
|
-
//
|
129
|
-
//
|
130
|
-
//
|
131
|
-
//
|
132
|
-
//
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
//
|
193
|
-
//
|
194
|
-
//
|
195
|
-
//
|
196
|
-
//
|
197
|
-
//
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
const
|
292
|
-
|
293
|
-
const
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
const
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
//
|
324
|
-
|
325
|
-
|
326
|
-
//
|
327
|
-
//
|
328
|
-
//
|
329
|
-
// const
|
330
|
-
// const
|
331
|
-
// const
|
332
|
-
//
|
333
|
-
//
|
334
|
-
//
|
335
|
-
//
|
336
|
-
//
|
337
|
-
//
|
338
|
-
//
|
339
|
-
//
|
340
|
-
//
|
341
|
-
//
|
342
|
-
//
|
343
|
-
//
|
344
|
-
//
|
345
|
-
// const
|
346
|
-
// const
|
347
|
-
//
|
348
|
-
//
|
349
|
-
//
|
350
|
-
//
|
351
|
-
//
|
352
|
-
//
|
353
|
-
//
|
354
|
-
//
|
355
|
-
//
|
356
|
-
//
|
357
|
-
//
|
358
|
-
//
|
359
|
-
//
|
360
|
-
//
|
361
|
-
//
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
1
|
+
import {
|
2
|
+
combineLatest,
|
3
|
+
distinctUntilChanged,
|
4
|
+
filter,
|
5
|
+
of,
|
6
|
+
map,
|
7
|
+
merge,
|
8
|
+
takeUntil,
|
9
|
+
shareReplay,
|
10
|
+
switchMap,
|
11
|
+
Subject,
|
12
|
+
Observable,
|
13
|
+
combineLatestAll} from 'rxjs'
|
14
|
+
import type {
|
15
|
+
AxisPosition,
|
16
|
+
ChartType,
|
17
|
+
ChartParams,
|
18
|
+
ComputedDataTypeMap,
|
19
|
+
ComputedDataGrid,
|
20
|
+
ContextObserverMultiGridDetail,
|
21
|
+
DataTypeMap,
|
22
|
+
DataFormatterTypeMap,
|
23
|
+
DataFormatterGrid,
|
24
|
+
DataFormatterMultiGridContainer,
|
25
|
+
EventMultiGrid,
|
26
|
+
GridContainerPosition,
|
27
|
+
HighlightTarget,
|
28
|
+
Layout,
|
29
|
+
TransformData } from '../../lib/core-types'
|
30
|
+
import {
|
31
|
+
highlightObservable,
|
32
|
+
seriesDataMapObservable,
|
33
|
+
groupDataMapObservable } from './observables'
|
34
|
+
import {
|
35
|
+
gridAxesTransformObservable,
|
36
|
+
gridGraphicTransformObservable,
|
37
|
+
gridGraphicReverseScaleObservable,
|
38
|
+
gridAxesReverseTransformObservable,
|
39
|
+
gridAxesSizeObservable,
|
40
|
+
gridSeriesLabelsObservable,
|
41
|
+
gridComputedLayoutDataObservable,
|
42
|
+
gridVisibleComputedDataObservable,
|
43
|
+
gridVisibleComputedLayoutDataObservable,
|
44
|
+
// isSeriesSeprateObservable,
|
45
|
+
computedStackedDataObservables } from './gridObservables'
|
46
|
+
import { DATA_FORMATTER_MULTI_GRID_GRID_DEFAULT } from '../defaults'
|
47
|
+
import { calcGridContainerLayout } from './orbchartsUtils'
|
48
|
+
|
49
|
+
// 每一個grid計算出來的所有Observable
|
50
|
+
export const multiGridEachDetailObservable = ({ fullDataFormatter$, computedData$, layout$, fullChartParams$, event$ }: {
|
51
|
+
fullDataFormatter$: Observable<DataFormatterTypeMap<'multiGrid'>>
|
52
|
+
computedData$: Observable<ComputedDataTypeMap<'multiGrid'>>
|
53
|
+
layout$: Observable<Layout>
|
54
|
+
fullChartParams$: Observable<ChartParams>
|
55
|
+
event$: Subject<EventMultiGrid>
|
56
|
+
}): Observable<ContextObserverMultiGridDetail[]> => {
|
57
|
+
|
58
|
+
const destroy$ = new Subject()
|
59
|
+
|
60
|
+
// highlight全部grid
|
61
|
+
const allGridHighlight$ = highlightObservable({
|
62
|
+
datumList$: computedData$.pipe(
|
63
|
+
map(d => d.flat().flat()),
|
64
|
+
shareReplay(1)
|
65
|
+
),
|
66
|
+
fullChartParams$: fullChartParams$,
|
67
|
+
event$: event$
|
68
|
+
}).pipe(
|
69
|
+
shareReplay(1)
|
70
|
+
)
|
71
|
+
|
72
|
+
const multiGridContainer$ = multiGridContainerObservable({
|
73
|
+
computedData$: computedData$,
|
74
|
+
fullDataFormatter$: fullDataFormatter$,
|
75
|
+
layout$: layout$,
|
76
|
+
}).pipe(
|
77
|
+
shareReplay(1)
|
78
|
+
)
|
79
|
+
|
80
|
+
return combineLatest({
|
81
|
+
fullDataFormatter: fullDataFormatter$,
|
82
|
+
computedData: computedData$,
|
83
|
+
multiGridContainer: multiGridContainer$
|
84
|
+
}).pipe(
|
85
|
+
switchMap(async (d) => d),
|
86
|
+
// distinctUntilChanged((a, b) => {
|
87
|
+
// // 只有當computedData的長度改變時,才重新計算
|
88
|
+
// return a.computedData.length === b.computedData.length
|
89
|
+
// }),
|
90
|
+
map(data => {
|
91
|
+
// 每次重新計算時,清除之前的訂閱
|
92
|
+
destroy$.next(undefined)
|
93
|
+
|
94
|
+
const defaultGrid = data.fullDataFormatter.gridList[0] ?? DATA_FORMATTER_MULTI_GRID_GRID_DEFAULT
|
95
|
+
|
96
|
+
return data.computedData.map((gridComputedData, gridIndex) => {
|
97
|
+
|
98
|
+
// -- 取得該grid的data和dataFormatter
|
99
|
+
const grid = data.fullDataFormatter.gridList[gridIndex] ?? defaultGrid
|
100
|
+
const gridDataFormatter: DataFormatterGrid = {
|
101
|
+
type: 'grid',
|
102
|
+
visibleFilter: data.fullDataFormatter.visibleFilter as any,
|
103
|
+
grid: {
|
104
|
+
...grid
|
105
|
+
},
|
106
|
+
container: {
|
107
|
+
...data.fullDataFormatter.container
|
108
|
+
}
|
109
|
+
}
|
110
|
+
const gridDataFormatter$ = of(gridDataFormatter).pipe(
|
111
|
+
takeUntil(destroy$),
|
112
|
+
shareReplay(1)
|
113
|
+
)
|
114
|
+
const gridComputedData$ = of(gridComputedData).pipe(
|
115
|
+
takeUntil(destroy$),
|
116
|
+
shareReplay(1)
|
117
|
+
)
|
118
|
+
|
119
|
+
// const isSeriesSeprate$ = isSeriesSeprateObservable({
|
120
|
+
// computedData$: gridComputedData$,
|
121
|
+
// fullDataFormatter$: gridDataFormatter$,
|
122
|
+
// }).pipe(
|
123
|
+
// takeUntil(destroy$),
|
124
|
+
// shareReplay(1)
|
125
|
+
// )
|
126
|
+
|
127
|
+
// const gridContainerPosition$ = gridContainerPositionObservable({
|
128
|
+
// computedData$: gridComputedData$,
|
129
|
+
// fullDataFormatter$: gridDataFormatter$,
|
130
|
+
// layout$
|
131
|
+
// }).pipe(
|
132
|
+
// shareReplay(1)
|
133
|
+
// )
|
134
|
+
|
135
|
+
const isSeriesSeprate$ = gridDataFormatter$.pipe(
|
136
|
+
map(d => d.grid.separateSeries),
|
137
|
+
distinctUntilChanged(),
|
138
|
+
shareReplay(1)
|
139
|
+
)
|
140
|
+
|
141
|
+
const gridContainerPosition$ = of(data.multiGridContainer[gridIndex]).pipe(
|
142
|
+
takeUntil(destroy$),
|
143
|
+
shareReplay(1)
|
144
|
+
)
|
145
|
+
|
146
|
+
const gridAxesTransform$ = gridAxesTransformObservable({
|
147
|
+
fullDataFormatter$: gridDataFormatter$,
|
148
|
+
layout$: layout$
|
149
|
+
}).pipe(
|
150
|
+
takeUntil(destroy$),
|
151
|
+
shareReplay(1)
|
152
|
+
)
|
153
|
+
|
154
|
+
|
155
|
+
const gridAxesReverseTransform$ = gridAxesReverseTransformObservable({
|
156
|
+
gridAxesTransform$
|
157
|
+
}).pipe(
|
158
|
+
takeUntil(destroy$),
|
159
|
+
shareReplay(1)
|
160
|
+
)
|
161
|
+
|
162
|
+
const gridGraphicTransform$ = gridGraphicTransformObservable({
|
163
|
+
computedData$: gridComputedData$,
|
164
|
+
fullDataFormatter$: gridDataFormatter$,
|
165
|
+
layout$: layout$
|
166
|
+
}).pipe(
|
167
|
+
takeUntil(destroy$),
|
168
|
+
shareReplay(1)
|
169
|
+
)
|
170
|
+
|
171
|
+
const gridGraphicReverseScale$ = gridGraphicReverseScaleObservable({
|
172
|
+
gridContainerPosition$: gridContainerPosition$,
|
173
|
+
gridAxesTransform$: gridAxesTransform$,
|
174
|
+
gridGraphicTransform$: gridGraphicTransform$,
|
175
|
+
})
|
176
|
+
|
177
|
+
const gridAxesSize$ = gridAxesSizeObservable({
|
178
|
+
fullDataFormatter$: gridDataFormatter$,
|
179
|
+
layout$: layout$
|
180
|
+
}).pipe(
|
181
|
+
takeUntil(destroy$),
|
182
|
+
shareReplay(1)
|
183
|
+
)
|
184
|
+
|
185
|
+
const datumList$ = gridComputedData$.pipe(
|
186
|
+
map(d => d.flat())
|
187
|
+
).pipe(
|
188
|
+
takeUntil(destroy$),
|
189
|
+
shareReplay(1)
|
190
|
+
)
|
191
|
+
|
192
|
+
// const gridHighlight$ = highlightObservable({
|
193
|
+
// datumList$,
|
194
|
+
// fullChartParams$: fullChartParams$,
|
195
|
+
// event$: event$
|
196
|
+
// }).pipe(
|
197
|
+
// shareReplay(1)
|
198
|
+
// )
|
199
|
+
|
200
|
+
const seriesLabels$ = gridSeriesLabelsObservable({
|
201
|
+
computedData$: gridComputedData$,
|
202
|
+
}).pipe(
|
203
|
+
takeUntil(destroy$),
|
204
|
+
shareReplay(1)
|
205
|
+
)
|
206
|
+
|
207
|
+
const SeriesDataMap$ = seriesDataMapObservable({
|
208
|
+
datumList$: datumList$
|
209
|
+
}).pipe(
|
210
|
+
takeUntil(destroy$),
|
211
|
+
shareReplay(1)
|
212
|
+
)
|
213
|
+
|
214
|
+
const GroupDataMap$ = groupDataMapObservable({
|
215
|
+
datumList$: datumList$
|
216
|
+
}).pipe(
|
217
|
+
takeUntil(destroy$),
|
218
|
+
shareReplay(1)
|
219
|
+
)
|
220
|
+
|
221
|
+
const visibleComputedData$ = gridVisibleComputedDataObservable({
|
222
|
+
computedData$: gridComputedData$,
|
223
|
+
}).pipe(
|
224
|
+
takeUntil(destroy$),
|
225
|
+
shareReplay(1)
|
226
|
+
)
|
227
|
+
|
228
|
+
const computedLayoutData$ = gridComputedLayoutDataObservable({
|
229
|
+
computedData$: gridComputedData$,
|
230
|
+
fullDataFormatter$: gridDataFormatter$,
|
231
|
+
layout$: layout$,
|
232
|
+
}).pipe(
|
233
|
+
takeUntil(destroy$),
|
234
|
+
shareReplay(1)
|
235
|
+
)
|
236
|
+
|
237
|
+
const visibleComputedLayoutData$ = gridVisibleComputedLayoutDataObservable({
|
238
|
+
computedLayoutData$: computedLayoutData$,
|
239
|
+
}).pipe(
|
240
|
+
takeUntil(destroy$),
|
241
|
+
shareReplay(1)
|
242
|
+
)
|
243
|
+
|
244
|
+
const computedStackedData$ = computedStackedDataObservables({
|
245
|
+
computedData$: gridComputedData$,
|
246
|
+
isSeriesSeprate$: isSeriesSeprate$
|
247
|
+
}).pipe(
|
248
|
+
shareReplay(1)
|
249
|
+
)
|
250
|
+
|
251
|
+
return {
|
252
|
+
isSeriesSeprate$,
|
253
|
+
gridContainerPosition$,
|
254
|
+
gridAxesTransform$,
|
255
|
+
gridAxesReverseTransform$,
|
256
|
+
gridGraphicTransform$,
|
257
|
+
gridGraphicReverseScale$,
|
258
|
+
gridAxesSize$,
|
259
|
+
gridHighlight$: allGridHighlight$,
|
260
|
+
seriesLabels$,
|
261
|
+
SeriesDataMap$,
|
262
|
+
GroupDataMap$,
|
263
|
+
dataFormatter$: gridDataFormatter$,
|
264
|
+
computedData$: gridComputedData$,
|
265
|
+
computedLayoutData$,
|
266
|
+
visibleComputedData$,
|
267
|
+
visibleComputedLayoutData$,
|
268
|
+
computedStackedData$
|
269
|
+
}
|
270
|
+
})
|
271
|
+
})
|
272
|
+
)
|
273
|
+
}
|
274
|
+
|
275
|
+
|
276
|
+
// 所有container位置(對應series)
|
277
|
+
export const multiGridContainerObservable = ({ computedData$, fullDataFormatter$, layout$ }: {
|
278
|
+
computedData$: Observable<ComputedDataTypeMap<'multiGrid'>>
|
279
|
+
fullDataFormatter$: Observable<DataFormatterTypeMap<'multiGrid'>>
|
280
|
+
layout$: Observable<Layout>
|
281
|
+
}): Observable<GridContainerPosition[][]> => {
|
282
|
+
|
283
|
+
return combineLatest({
|
284
|
+
computedData: computedData$,
|
285
|
+
fullDataFormatter: fullDataFormatter$,
|
286
|
+
layout: layout$,
|
287
|
+
}).pipe(
|
288
|
+
switchMap(async (d) => d),
|
289
|
+
map(data => {
|
290
|
+
|
291
|
+
const defaultGrid = data.fullDataFormatter.gridList[0] ?? DATA_FORMATTER_MULTI_GRID_GRID_DEFAULT
|
292
|
+
const slotAmount = data.computedData.reduce((acc, gridData, gridIndex) => {
|
293
|
+
const grid = data.fullDataFormatter.gridList[gridIndex] ?? defaultGrid
|
294
|
+
const gridSlotAmount = grid.separateSeries
|
295
|
+
? gridData.length
|
296
|
+
: data.fullDataFormatter.separateGrid
|
297
|
+
? 1
|
298
|
+
: 0 // 如果grid和series都不分開,則slotAmount不增加(在相同的slot)
|
299
|
+
return acc + gridSlotAmount
|
300
|
+
}, 0) || 1
|
301
|
+
|
302
|
+
const gridContainerLayout = calcGridContainerLayout(data.layout, data.fullDataFormatter.container, slotAmount)
|
303
|
+
|
304
|
+
let accGridSlotIndex = 0
|
305
|
+
const gridContainerPositionArr = data.computedData.map((gridData, gridIndex) => {
|
306
|
+
const grid = data.fullDataFormatter.gridList[gridIndex] ?? defaultGrid
|
307
|
+
const seriesContainerArr = gridData.map((seriesData, seriesIndex) => {
|
308
|
+
const container = gridContainerLayout[accGridSlotIndex]
|
309
|
+
if (grid.separateSeries) {
|
310
|
+
accGridSlotIndex += 1
|
311
|
+
}
|
312
|
+
return container
|
313
|
+
})
|
314
|
+
if (!grid.separateSeries && data.fullDataFormatter.separateGrid) {
|
315
|
+
accGridSlotIndex += 1
|
316
|
+
}
|
317
|
+
return seriesContainerArr
|
318
|
+
})
|
319
|
+
// console.log('gridContainerPositionArr', gridContainerPositionArr)
|
320
|
+
|
321
|
+
// let accGridSlotIndex = 0
|
322
|
+
|
323
|
+
// const gridContainerPositionArr = data.computedData.map((gridData, gridIndex) => {
|
324
|
+
// const grid = data.fullDataFormatter.gridList[gridIndex] ?? defaultGrid
|
325
|
+
|
326
|
+
// if (grid.separateSeries) {
|
327
|
+
// // -- 依seriesSlotIndexes計算 --
|
328
|
+
// const seriesContainerArr = gridData.map((seriesData, seriesIndex) => {
|
329
|
+
// const currentSlotIndex = accGridSlotIndex + seriesIndex
|
330
|
+
// const columnIndex = currentSlotIndex % data.fullDataFormatter.container.columnAmount
|
331
|
+
// const rowIndex = Math.floor(currentSlotIndex / data.fullDataFormatter.container.columnAmount)
|
332
|
+
// const { translate, scale } = calcGridContainerPosition(data.layout, data.fullDataFormatter.container, rowIndex, columnIndex)
|
333
|
+
// return {
|
334
|
+
// slotIndex: currentSlotIndex,
|
335
|
+
// rowIndex,
|
336
|
+
// columnIndex,
|
337
|
+
// translate,
|
338
|
+
// scale,
|
339
|
+
// }
|
340
|
+
// })
|
341
|
+
// accGridSlotIndex += seriesContainerArr.length
|
342
|
+
// return seriesContainerArr
|
343
|
+
// } else {
|
344
|
+
// // -- 依grid的slotIndex計算 --
|
345
|
+
// const columnIndex = accGridSlotIndex % data.fullDataFormatter.container.columnAmount
|
346
|
+
// const rowIndex = Math.floor(accGridSlotIndex / data.fullDataFormatter.container.columnAmount)
|
347
|
+
// const seriesContainerArr = gridData.map((seriesData, seriesIndex) => {
|
348
|
+
// const { translate, scale } = calcGridContainerPosition(data.layout, data.fullDataFormatter.container, rowIndex, columnIndex)
|
349
|
+
// return {
|
350
|
+
// slotIndex: accGridSlotIndex,
|
351
|
+
// rowIndex,
|
352
|
+
// columnIndex,
|
353
|
+
// translate,
|
354
|
+
// scale,
|
355
|
+
// }
|
356
|
+
// })
|
357
|
+
// if (data.fullDataFormatter.separateGrid) {
|
358
|
+
// accGridSlotIndex += 1
|
359
|
+
// }
|
360
|
+
// return seriesContainerArr
|
361
|
+
// }
|
362
|
+
// })
|
363
|
+
|
364
|
+
return gridContainerPositionArr
|
365
|
+
}),
|
366
|
+
)
|
366
367
|
}
|