@orbcharts/core 3.0.0-alpha.46 → 3.0.0-alpha.48
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/orbcharts-core.es.js +1735 -1679
- package/dist/orbcharts-core.umd.js +2 -2
- package/dist/src/grid/gridObservables.d.ts +5 -1
- package/dist/src/types/ContextObserverGrid.d.ts +2 -0
- package/package.json +1 -1
- package/src/grid/createGridContextObserver.ts +17 -9
- package/src/grid/gridObservables.ts +45 -18
- package/src/multiGrid/multiGridObservables.ts +18 -4
- package/src/types/ContextObserverGrid.ts +2 -1
@@ -7,6 +7,7 @@ export interface ContextObserverGrid<PluginParams> extends ContextObserverBase<'
|
|
7
7
|
textSizePx$: Observable<number>;
|
8
8
|
}
|
9
9
|
export interface ContextObserverGridDetail {
|
10
|
+
isSeriesSeprate$: Observable<boolean>;
|
10
11
|
gridContainerPosition$: Observable<GridContainerPosition[]>;
|
11
12
|
gridAxesTransform$: Observable<TransformData>;
|
12
13
|
gridAxesReverseTransform$: Observable<TransformData>;
|
@@ -23,6 +24,7 @@ export interface ContextObserverGridDetail {
|
|
23
24
|
computedLayoutData$: Observable<ComputedLayoutDataGrid>;
|
24
25
|
visibleComputedData$: Observable<ComputedDataGrid>;
|
25
26
|
visibleComputedLayoutData$: Observable<ComputedLayoutDataGrid>;
|
27
|
+
computedStackedData$: Observable<ComputedDataGrid>;
|
26
28
|
}
|
27
29
|
export type ComputedLayoutDataGrid = ComputedLayoutDatumGrid[][];
|
28
30
|
export interface ComputedLayoutDatumGrid extends ComputedDatumGrid {
|
package/package.json
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import { map, shareReplay } from 'rxjs'
|
1
|
+
import { map, shareReplay, distinctUntilChanged } from 'rxjs'
|
2
2
|
import type { ContextObserverFn } from '../types'
|
3
3
|
import {
|
4
4
|
highlightObservable,
|
@@ -16,7 +16,8 @@ import {
|
|
16
16
|
gridVisibleComputedDataObservable,
|
17
17
|
gridVisibleComputedLayoutDataObservable,
|
18
18
|
// isSeriesSeprateObservable,
|
19
|
-
gridContainerPositionObservable
|
19
|
+
gridContainerPositionObservable,
|
20
|
+
computedStackedDataObservables } from './gridObservables'
|
20
21
|
|
21
22
|
export const createGridContextObserver: ContextObserverFn<'grid'> = ({ subject, observer }) => {
|
22
23
|
|
@@ -24,12 +25,11 @@ export const createGridContextObserver: ContextObserverFn<'grid'> = ({ subject,
|
|
24
25
|
shareReplay(1)
|
25
26
|
)
|
26
27
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
// )
|
28
|
+
const isSeriesSeprate$ = observer.fullDataFormatter$.pipe(
|
29
|
+
map(d => d.grid.separateSeries),
|
30
|
+
distinctUntilChanged(),
|
31
|
+
shareReplay(1)
|
32
|
+
)
|
33
33
|
|
34
34
|
const gridContainerPosition$ = gridContainerPositionObservable({
|
35
35
|
computedData$: observer.computedData$,
|
@@ -121,6 +121,13 @@ export const createGridContextObserver: ContextObserverFn<'grid'> = ({ subject,
|
|
121
121
|
shareReplay(1)
|
122
122
|
)
|
123
123
|
|
124
|
+
const computedStackedData$ = computedStackedDataObservables({
|
125
|
+
computedData$: observer.computedData$,
|
126
|
+
isSeriesSeprate$: isSeriesSeprate$
|
127
|
+
}).pipe(
|
128
|
+
shareReplay(1)
|
129
|
+
)
|
130
|
+
|
124
131
|
|
125
132
|
return {
|
126
133
|
fullParams$: observer.fullParams$,
|
@@ -129,7 +136,7 @@ export const createGridContextObserver: ContextObserverFn<'grid'> = ({ subject,
|
|
129
136
|
computedData$: observer.computedData$,
|
130
137
|
layout$: observer.layout$,
|
131
138
|
textSizePx$,
|
132
|
-
|
139
|
+
isSeriesSeprate$,
|
133
140
|
gridContainerPosition$,
|
134
141
|
gridAxesTransform$,
|
135
142
|
gridAxesReverseTransform$,
|
@@ -143,5 +150,6 @@ export const createGridContextObserver: ContextObserverFn<'grid'> = ({ subject,
|
|
143
150
|
computedLayoutData$,
|
144
151
|
visibleComputedData$,
|
145
152
|
visibleComputedLayoutData$,
|
153
|
+
computedStackedData$,
|
146
154
|
}
|
147
155
|
}
|
@@ -1,6 +1,7 @@
|
|
1
1
|
import {
|
2
2
|
combineLatest,
|
3
3
|
distinctUntilChanged,
|
4
|
+
iif,
|
4
5
|
filter,
|
5
6
|
map,
|
6
7
|
merge,
|
@@ -15,6 +16,7 @@ import type {
|
|
15
16
|
ChartParams,
|
16
17
|
ComputedDataTypeMap,
|
17
18
|
ComputedDatumTypeMap,
|
19
|
+
ComputedDataGrid,
|
18
20
|
ContextObserverFn,
|
19
21
|
DataTypeMap,
|
20
22
|
DataGridDatum,
|
@@ -504,23 +506,6 @@ export const gridVisibleComputedLayoutDataObservable = ({ computedLayoutData$ }:
|
|
504
506
|
)
|
505
507
|
}
|
506
508
|
|
507
|
-
// export const isSeriesSeprateObservable = ({ computedData$, fullDataFormatter$ }: {
|
508
|
-
// computedData$: Observable<ComputedDataTypeMap<'grid'>>
|
509
|
-
// fullDataFormatter$: Observable<DataFormatterTypeMap<'grid'>>
|
510
|
-
// }) => {
|
511
|
-
// return combineLatest({
|
512
|
-
// computedData: computedData$,
|
513
|
-
// fullDataFormatter: fullDataFormatter$
|
514
|
-
// }).pipe(
|
515
|
-
// map(data => {
|
516
|
-
// return data.fullDataFormatter.grid.seriesSlotIndexes && data.fullDataFormatter.grid.seriesSlotIndexes.length === data.computedData.length
|
517
|
-
// ? true
|
518
|
-
// : false
|
519
|
-
// }),
|
520
|
-
// distinctUntilChanged()
|
521
|
-
// )
|
522
|
-
// }
|
523
|
-
|
524
509
|
// 所有container位置(對應series)
|
525
510
|
export const gridContainerPositionObservable = ({ computedData$, fullDataFormatter$, layout$ }: {
|
526
511
|
computedData$: Observable<ComputedDataTypeMap<'grid'>>
|
@@ -553,7 +538,8 @@ export const gridContainerPositionObservable = ({ computedData$, fullDataFormatt
|
|
553
538
|
// })
|
554
539
|
} else {
|
555
540
|
// -- 無拆分 --
|
556
|
-
|
541
|
+
const gridContainerPositionArr = calcGridContainerLayout(data.layout, data.fullDataFormatter.container, 1)
|
542
|
+
return data.computedData.map((d, i) => gridContainerPositionArr[0]) // 每個series相同位置
|
557
543
|
// const columnIndex = 0
|
558
544
|
// const rowIndex = 0
|
559
545
|
// return data.computedData.map((seriesData, seriesIndex) => {
|
@@ -571,4 +557,45 @@ export const gridContainerPositionObservable = ({ computedData$, fullDataFormatt
|
|
571
557
|
)
|
572
558
|
|
573
559
|
return gridContainerPosition$
|
560
|
+
}
|
561
|
+
|
562
|
+
// 將原本的value全部替換成加總後的value
|
563
|
+
export const computedStackedDataObservables = ({ isSeriesSeprate$, computedData$ }: {
|
564
|
+
isSeriesSeprate$: Observable<boolean>
|
565
|
+
computedData$: Observable<ComputedDataGrid>
|
566
|
+
}): Observable<ComputedDataGrid> => {
|
567
|
+
const stackedData$: Observable<ComputedDataGrid> = computedData$.pipe(
|
568
|
+
map(data => {
|
569
|
+
// 將同一group的value加總起來
|
570
|
+
const stackedValue = new Array(data[0] ? data[0].length : 0)
|
571
|
+
.fill(null)
|
572
|
+
.map((_, i) => {
|
573
|
+
return data.reduce((prev, current) => {
|
574
|
+
if (current && current[i]) {
|
575
|
+
const currentValue = current[i].value == null || current[i].visible == false
|
576
|
+
? 0
|
577
|
+
: current[i].value!
|
578
|
+
return prev + currentValue
|
579
|
+
}
|
580
|
+
return prev
|
581
|
+
}, 0)
|
582
|
+
})
|
583
|
+
// 將原本的value全部替換成加總後的value
|
584
|
+
const computedData = data.map((series, seriesIndex) => {
|
585
|
+
return series.map((d, i) => {
|
586
|
+
return {
|
587
|
+
...d,
|
588
|
+
value: stackedValue[i],
|
589
|
+
}
|
590
|
+
})
|
591
|
+
})
|
592
|
+
return computedData
|
593
|
+
}),
|
594
|
+
)
|
595
|
+
|
596
|
+
return isSeriesSeprate$.pipe(
|
597
|
+
switchMap(isSeriesSeprate => {
|
598
|
+
return iif(() => isSeriesSeprate, computedData$, stackedData$)
|
599
|
+
})
|
600
|
+
)
|
574
601
|
}
|
@@ -41,7 +41,7 @@ import {
|
|
41
41
|
gridVisibleComputedDataObservable,
|
42
42
|
gridVisibleComputedLayoutDataObservable,
|
43
43
|
// isSeriesSeprateObservable,
|
44
|
-
|
44
|
+
computedStackedDataObservables } from '../grid/gridObservables'
|
45
45
|
import { DATA_FORMATTER_MULTI_GRID_GRID_DEFAULT } from '../defaults'
|
46
46
|
import { calcGridContainerLayout } from '../utils/orbchartsUtils'
|
47
47
|
|
@@ -131,6 +131,12 @@ export const multiGridEachDetailObservable = ({ fullDataFormatter$, computedData
|
|
131
131
|
// shareReplay(1)
|
132
132
|
// )
|
133
133
|
|
134
|
+
const isSeriesSeprate$ = gridDataFormatter$.pipe(
|
135
|
+
map(d => d.grid.separateSeries),
|
136
|
+
distinctUntilChanged(),
|
137
|
+
shareReplay(1)
|
138
|
+
)
|
139
|
+
|
134
140
|
const gridContainerPosition$ = of(data.multiGridContainer[gridIndex]).pipe(
|
135
141
|
takeUntil(destroy$),
|
136
142
|
shareReplay(1)
|
@@ -217,7 +223,7 @@ export const multiGridEachDetailObservable = ({ fullDataFormatter$, computedData
|
|
217
223
|
takeUntil(destroy$),
|
218
224
|
shareReplay(1)
|
219
225
|
)
|
220
|
-
|
226
|
+
|
221
227
|
const computedLayoutData$ = gridComputedLayoutDataObservable({
|
222
228
|
computedData$: gridComputedData$,
|
223
229
|
fullDataFormatter$: gridDataFormatter$,
|
@@ -234,7 +240,15 @@ export const multiGridEachDetailObservable = ({ fullDataFormatter$, computedData
|
|
234
240
|
shareReplay(1)
|
235
241
|
)
|
236
242
|
|
237
|
-
|
243
|
+
const computedStackedData$ = computedStackedDataObservables({
|
244
|
+
computedData$: gridComputedData$,
|
245
|
+
isSeriesSeprate$: isSeriesSeprate$
|
246
|
+
}).pipe(
|
247
|
+
shareReplay(1)
|
248
|
+
)
|
249
|
+
|
250
|
+
return {
|
251
|
+
isSeriesSeprate$,
|
238
252
|
gridContainerPosition$,
|
239
253
|
gridAxesTransform$,
|
240
254
|
gridAxesReverseTransform$,
|
@@ -250,7 +264,7 @@ export const multiGridEachDetailObservable = ({ fullDataFormatter$, computedData
|
|
250
264
|
computedLayoutData$,
|
251
265
|
visibleComputedData$,
|
252
266
|
visibleComputedLayoutData$,
|
253
|
-
|
267
|
+
computedStackedData$
|
254
268
|
}
|
255
269
|
})
|
256
270
|
})
|
@@ -9,6 +9,7 @@ ContextObserverBase<'grid', PluginParams>, ContextObserverGridDetail {
|
|
9
9
|
}
|
10
10
|
|
11
11
|
export interface ContextObserverGridDetail {
|
12
|
+
isSeriesSeprate$: Observable<boolean>
|
12
13
|
gridContainerPosition$: Observable<GridContainerPosition[]>
|
13
14
|
gridAxesTransform$: Observable<TransformData>
|
14
15
|
gridAxesReverseTransform$: Observable<TransformData>
|
@@ -22,7 +23,7 @@ export interface ContextObserverGridDetail {
|
|
22
23
|
computedLayoutData$: Observable<ComputedLayoutDataGrid>
|
23
24
|
visibleComputedData$: Observable<ComputedDataGrid>
|
24
25
|
visibleComputedLayoutData$: Observable<ComputedLayoutDataGrid>
|
25
|
-
|
26
|
+
computedStackedData$: Observable<ComputedDataGrid>
|
26
27
|
}
|
27
28
|
|
28
29
|
export type ComputedLayoutDataGrid = ComputedLayoutDatumGrid[][]
|