@orbcharts/plugins-basic 3.0.0-alpha.49 → 3.0.0-alpha.50

Sign up to get free protection for your applications and to get access to all the features.
Files changed (32) hide show
  1. package/dist/orbcharts-plugins-basic.es.js +6001 -5928
  2. package/dist/orbcharts-plugins-basic.umd.js +8 -8
  3. package/dist/src/multiGrid/defaults.d.ts +2 -1
  4. package/dist/src/multiGrid/index.d.ts +2 -0
  5. package/dist/src/multiGrid/multiGridObservables.d.ts +1 -1
  6. package/dist/src/multiGrid/plugins/MultiValueStackAxis.d.ts +1 -0
  7. package/dist/src/multiGrid/plugins/OverlappingValueStackAxes.d.ts +1 -0
  8. package/dist/src/multiGrid/types.d.ts +3 -0
  9. package/package.json +2 -2
  10. package/src/grid/defaults.ts +3 -1
  11. package/src/grid/gridObservables.ts +1 -0
  12. package/src/grid/plugins/BarStack.ts +1 -8
  13. package/src/grid/plugins/Bars.ts +1 -8
  14. package/src/grid/plugins/BarsTriangle.ts +1 -9
  15. package/src/grid/plugins/GroupAxis.ts +1 -8
  16. package/src/grid/plugins/ValueAxis.ts +1 -8
  17. package/src/grid/plugins/ValueStackAxis.ts +4 -45
  18. package/src/multiGrid/defaults.ts +5 -0
  19. package/src/multiGrid/index.ts +3 -1
  20. package/src/multiGrid/multiGridObservables.ts +3 -2
  21. package/src/multiGrid/plugins/MultiBarStack.ts +3 -3
  22. package/src/multiGrid/plugins/MultiBars.ts +3 -3
  23. package/src/multiGrid/plugins/MultiBarsTriangle.ts +3 -3
  24. package/src/multiGrid/plugins/MultiDots.ts +3 -3
  25. package/src/multiGrid/plugins/MultiGroupAxis.ts +3 -3
  26. package/src/multiGrid/plugins/MultiLineAreas.ts +3 -3
  27. package/src/multiGrid/plugins/MultiLines.ts +3 -3
  28. package/src/multiGrid/plugins/MultiValueAxis.ts +3 -3
  29. package/src/multiGrid/plugins/MultiValueStackAxis.ts +69 -0
  30. package/src/multiGrid/plugins/OverlappingValueAxes.ts +5 -12
  31. package/src/multiGrid/plugins/OverlappingValueStackAxes.ts +167 -0
  32. package/src/multiGrid/types.ts +4 -0
@@ -1,8 +1,9 @@
1
- import { MultiGridLegendParams, MultiBarsParams, MultiBarStackParams, MultiBarsTriangleParams, MultiLinesParams, MultiLineAreasParams, MultiDotsParams, MultiGroupAxisParams, MultiValueAxisParams, OverlappingValueAxesParams } from './types';
1
+ import { MultiGridLegendParams, MultiBarsParams, MultiBarStackParams, MultiBarsTriangleParams, MultiLinesParams, MultiLineAreasParams, MultiDotsParams, MultiGroupAxisParams, MultiValueAxisParams, MultiValueStackAxisParams, OverlappingValueAxesParams } from './types';
2
2
 
3
3
  export declare const DEFAULT_MULTI_GRID_LEGEND_PARAMS: MultiGridLegendParams;
4
4
  export declare const DEFAULT_MULTI_GROUP_AXIS_PARAMS: MultiGroupAxisParams;
5
5
  export declare const DEFAULT_MULTI_VALUE_AXIS_PARAMS: MultiValueAxisParams;
6
+ export declare const DEFAULT_MULTI_VALUE_STACK_AXIS_PARAMS: MultiValueStackAxisParams;
6
7
  export declare const DEFAULT_MULTI_BARS_PARAMS: MultiBarsParams;
7
8
  export declare const DEFAULT_MULTI_BAR_STACK_PARAMS: MultiBarStackParams;
8
9
  export declare const DEFAULT_MULTI_BARS_TRIANGLE_PARAMS: MultiBarsTriangleParams;
@@ -9,4 +9,6 @@ export { MultiLineAreas } from './plugins/MultiLineAreas';
9
9
  export { MultiDots } from './plugins/MultiDots';
10
10
  export { MultiGroupAxis } from './plugins/MultiGroupAxis';
11
11
  export { MultiValueAxis } from './plugins/MultiValueAxis';
12
+ export { MultiValueStackAxis } from './plugins/MultiValueStackAxis';
12
13
  export { OverlappingValueAxes } from './plugins/OverlappingValueAxes';
14
+ export { OverlappingValueStackAxes } from './plugins/OverlappingValueStackAxes';
@@ -4,5 +4,5 @@ import { ContextObserverMultiGrid, ContextObserverMultiGridDetail } from '@orbch
4
4
  interface MultiGridPluginParams {
5
5
  gridIndexes: number[];
6
6
  }
7
- export declare const multiGridPluginObservables: (observer: ContextObserverMultiGrid<MultiGridPluginParams>) => Observable<ContextObserverMultiGridDetail[]>;
7
+ export declare const multiGridPluginDetailObservables: (observer: ContextObserverMultiGrid<MultiGridPluginParams>) => Observable<ContextObserverMultiGridDetail[]>;
8
8
  export {};
@@ -0,0 +1 @@
1
+ export declare const MultiValueStackAxis: import('@orbcharts/core').PluginConstructor<"multiGrid", string, import('..').MultiValueAxisParams>;
@@ -0,0 +1 @@
1
+ export declare const OverlappingValueStackAxes: import('@orbcharts/core').PluginConstructor<"multiGrid", string, import('..').OverlappingValueAxesParams>;
@@ -31,6 +31,9 @@ export interface MultiGroupAxisParams extends BaseGroupAxisParams {
31
31
  export interface MultiValueAxisParams extends BaseValueAxisParams {
32
32
  gridIndexes: number[];
33
33
  }
34
+ export interface MultiValueStackAxisParams extends BaseValueAxisParams {
35
+ gridIndexes: number[];
36
+ }
34
37
  export interface MultiBarsParams extends BaseBarsParams {
35
38
  gridIndexes: number[];
36
39
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@orbcharts/plugins-basic",
3
- "version": "3.0.0-alpha.49",
3
+ "version": "3.0.0-alpha.50",
4
4
  "description": "plugins for OrbCharts",
5
5
  "author": "Blue Planet Inc.",
6
6
  "license": "Apache-2.0",
@@ -35,7 +35,7 @@
35
35
  "vite-plugin-dts": "^3.7.3"
36
36
  },
37
37
  "dependencies": {
38
- "@orbcharts/core": "^3.0.0-alpha.47",
38
+ "@orbcharts/core": "^3.0.0-alpha.48",
39
39
  "d3": "^7.8.5",
40
40
  "rxjs": "^7.8.1"
41
41
  }
@@ -99,7 +99,9 @@ export const DEFAULT_VALUE_AXIS_PARAMS: ValueAxisParams = {
99
99
  tickTextColorType: 'primary'
100
100
  }
101
101
 
102
- export const DEFAULT_VALUE_STACK_AXIS_PARAMS: ValueStackAxisParams = DEFAULT_VALUE_AXIS_PARAMS
102
+ export const DEFAULT_VALUE_STACK_AXIS_PARAMS: ValueStackAxisParams = {
103
+ ...DEFAULT_VALUE_AXIS_PARAMS
104
+ }
103
105
 
104
106
  export const DEFAULT_SCALING_AREA_PARAMS: ScalingAreaParams = {
105
107
 
@@ -245,3 +245,4 @@ export const gridGroupPositionFnObservable = ({ fullDataFormatter$, gridAxesSize
245
245
  })
246
246
  })
247
247
  }
248
+
@@ -15,13 +15,6 @@ const pluginName = 'BarStack'
15
15
  export const BarStack = defineGridPlugin(pluginName, DEFAULT_BAR_STACK_PARAMS)(({ selection, name, subject, observer }) => {
16
16
  const destroy$ = new Subject()
17
17
 
18
- const isSeriesSeprate$ = observer.fullDataFormatter$.pipe(
19
- takeUntil(destroy$),
20
- map(d => d.grid.separateSeries),
21
- distinctUntilChanged(),
22
- shareReplay(1)
23
- )
24
-
25
18
  const unsubscribeBaseBars = createBaseBarStack(pluginName, {
26
19
  selection,
27
20
  computedData$: observer.computedData$,
@@ -40,7 +33,7 @@ export const BarStack = defineGridPlugin(pluginName, DEFAULT_BAR_STACK_PARAMS)((
40
33
  gridAxesSize$: observer.gridAxesSize$,
41
34
  gridHighlight$: observer.gridHighlight$,
42
35
  gridContainerPosition$: observer.gridContainerPosition$,
43
- isSeriesSeprate$,
36
+ isSeriesSeprate$: observer.isSeriesSeprate$,
44
37
  event$: subject.event$,
45
38
  })
46
39
 
@@ -16,13 +16,6 @@ const pluginName = 'Bars'
16
16
  export const Bars = defineGridPlugin(pluginName, DEFAULT_BARS_PARAMS)(({ selection, name, subject, observer }) => {
17
17
  const destroy$ = new Subject()
18
18
 
19
- const isSeriesSeprate$ = observer.fullDataFormatter$.pipe(
20
- takeUntil(destroy$),
21
- map(d => d.grid.separateSeries),
22
- distinctUntilChanged(),
23
- shareReplay(1)
24
- )
25
-
26
19
  const unsubscribeBaseBars = createBaseBars(pluginName, {
27
20
  selection,
28
21
  computedData$: observer.computedData$,
@@ -40,7 +33,7 @@ export const Bars = defineGridPlugin(pluginName, DEFAULT_BARS_PARAMS)(({ selecti
40
33
  gridAxesSize$: observer.gridAxesSize$,
41
34
  gridHighlight$: observer.gridHighlight$,
42
35
  gridContainerPosition$: observer.gridContainerPosition$,
43
- isSeriesSeprate$: isSeriesSeprate$,
36
+ isSeriesSeprate$: observer.isSeriesSeprate$,
44
37
  event$: subject.event$,
45
38
  })
46
39
 
@@ -15,14 +15,6 @@ const pluginName = 'BarsTriangle'
15
15
  export const BarsTriangle = defineGridPlugin(pluginName, DEFAULT_BARS_TRIANGLE_PARAMS)(({ selection, name, subject, observer }) => {
16
16
  const destroy$ = new Subject()
17
17
 
18
-
19
- const isSeriesSeprate$ = observer.fullDataFormatter$.pipe(
20
- takeUntil(destroy$),
21
- map(d => d.grid.separateSeries),
22
- distinctUntilChanged(),
23
- shareReplay(1)
24
- )
25
-
26
18
  const unsubscribeBaseBars = createBaseBarsTriangle(pluginName, {
27
19
  selection,
28
20
  computedData$: observer.computedData$,
@@ -40,7 +32,7 @@ export const BarsTriangle = defineGridPlugin(pluginName, DEFAULT_BARS_TRIANGLE_P
40
32
  gridAxesSize$: observer.gridAxesSize$,
41
33
  gridHighlight$: observer.gridHighlight$,
42
34
  gridContainerPosition$: observer.gridContainerPosition$,
43
- isSeriesSeprate$,
35
+ isSeriesSeprate$: observer.isSeriesSeprate$,
44
36
  event$: subject.event$,
45
37
  })
46
38
 
@@ -16,13 +16,6 @@ export const GroupAxis = defineGridPlugin(pluginName, DEFAULT_GROUP_AXIS_PARAMS)
16
16
 
17
17
  const destroy$ = new Subject()
18
18
 
19
- const isSeriesSeprate$ = observer.fullDataFormatter$.pipe(
20
- takeUntil(destroy$),
21
- map(d => d.grid.separateSeries),
22
- distinctUntilChanged(),
23
- shareReplay(1)
24
- )
25
-
26
19
  const unsubscribeBaseGroupAxis = createBaseGroupAxis(pluginName, {
27
20
  selection,
28
21
  computedData$: observer.computedData$,
@@ -33,7 +26,7 @@ export const GroupAxis = defineGridPlugin(pluginName, DEFAULT_GROUP_AXIS_PARAMS)
33
26
  gridAxesReverseTransform$: observer.gridAxesReverseTransform$,
34
27
  gridAxesSize$: observer.gridAxesSize$,
35
28
  gridContainerPosition$: observer.gridContainerPosition$,
36
- isSeriesSeprate$,
29
+ isSeriesSeprate$: observer.isSeriesSeprate$,
37
30
  })
38
31
 
39
32
  return () => {
@@ -17,13 +17,6 @@ export const ValueAxis = defineGridPlugin(pluginName, DEFAULT_VALUE_AXIS_PARAMS)
17
17
 
18
18
  const destroy$ = new Subject()
19
19
 
20
- const isSeriesSeprate$ = observer.fullDataFormatter$.pipe(
21
- takeUntil(destroy$),
22
- map(d => d.grid.separateSeries),
23
- distinctUntilChanged(),
24
- shareReplay(1)
25
- )
26
-
27
20
  const unsubscribeBaseValueAxis = createBaseValueAxis(pluginName, {
28
21
  selection,
29
22
  computedData$: observer.computedData$,
@@ -34,7 +27,7 @@ export const ValueAxis = defineGridPlugin(pluginName, DEFAULT_VALUE_AXIS_PARAMS)
34
27
  gridAxesReverseTransform$: observer.gridAxesReverseTransform$,
35
28
  gridAxesSize$: observer.gridAxesSize$,
36
29
  gridContainerPosition$: observer.gridContainerPosition$,
37
- isSeriesSeprate$,
30
+ isSeriesSeprate$: observer.isSeriesSeprate$,
38
31
  })
39
32
 
40
33
  return () => {
@@ -5,11 +5,12 @@ import {
5
5
  shareReplay,
6
6
  switchMap,
7
7
  iif,
8
+ Observable,
8
9
  Subject } from 'rxjs'
10
+ import type { ComputedDataGrid } from '@orbcharts/core'
9
11
  import {
10
12
  defineGridPlugin } from '@orbcharts/core'
11
13
  import { DEFAULT_VALUE_STACK_AXIS_PARAMS } from '../defaults'
12
-
13
14
  import { createBaseValueAxis } from '../../base/BaseValueAxis'
14
15
 
15
16
  const pluginName = 'ValueStackAxis'
@@ -18,51 +19,9 @@ export const ValueStackAxis = defineGridPlugin(pluginName, DEFAULT_VALUE_STACK_A
18
19
 
19
20
  const destroy$ = new Subject()
20
21
 
21
- // 將原本的value全部替換成加總後的value
22
- const stackedData$ = observer.computedData$.pipe(
23
- takeUntil(destroy$),
24
- map(data => {
25
- // 將同一group的value加總起來
26
- const stackedValue = new Array(data[0] ? data[0].length : 0)
27
- .fill(null)
28
- .map((_, i) => {
29
- return data.reduce((prev, current) => {
30
- if (current && current[i]) {
31
- const currentValue = current[i].value == null || current[i].visible == false
32
- ? 0
33
- : current[i].value!
34
- return prev + currentValue
35
- }
36
- return prev
37
- }, 0)
38
- })
39
- // 將原本的value全部替換成加總後的value
40
- const computedData = data.map((series, seriesIndex) => {
41
- return series.map((d, i) => {
42
- return {
43
- ...d,
44
- value: stackedValue[i],
45
- }
46
- })
47
- })
48
- return computedData
49
- }),
50
- )
51
-
52
- const isSeriesSeprate$ = observer.fullDataFormatter$.pipe(
53
- takeUntil(destroy$),
54
- map(d => d.grid.separateSeries),
55
- distinctUntilChanged(),
56
- shareReplay(1)
57
- )
58
-
59
22
  const unsubscribeBaseValueAxis = createBaseValueAxis(pluginName, {
60
23
  selection,
61
- computedData$: isSeriesSeprate$.pipe(
62
- switchMap(isSeriesSeprate => {
63
- return iif(() => isSeriesSeprate, observer.computedData$, stackedData$)
64
- })
65
- ),
24
+ computedData$: observer.computedStackedData$, // 計算疊加value的資料
66
25
  fullParams$: observer.fullParams$,
67
26
  fullDataFormatter$: observer.fullDataFormatter$,
68
27
  fullChartParams$: observer.fullChartParams$,
@@ -70,7 +29,7 @@ export const ValueStackAxis = defineGridPlugin(pluginName, DEFAULT_VALUE_STACK_A
70
29
  gridAxesReverseTransform$: observer.gridAxesReverseTransform$,
71
30
  gridAxesSize$: observer.gridAxesSize$,
72
31
  gridContainerPosition$: observer.gridContainerPosition$,
73
- isSeriesSeprate$,
32
+ isSeriesSeprate$: observer.isSeriesSeprate$,
74
33
  })
75
34
 
76
35
  return () => {
@@ -8,6 +8,7 @@ import type {
8
8
  MultiDotsParams,
9
9
  MultiGroupAxisParams,
10
10
  MultiValueAxisParams,
11
+ MultiValueStackAxisParams,
11
12
  OverlappingValueAxesParams
12
13
  } from './types'
13
14
 
@@ -66,6 +67,10 @@ export const DEFAULT_MULTI_VALUE_AXIS_PARAMS: MultiValueAxisParams = {
66
67
  gridIndexes: [0]
67
68
  }
68
69
 
70
+ export const DEFAULT_MULTI_VALUE_STACK_AXIS_PARAMS: MultiValueStackAxisParams = {
71
+ ...DEFAULT_MULTI_VALUE_AXIS_PARAMS
72
+ }
73
+
69
74
  export const DEFAULT_MULTI_BARS_PARAMS: MultiBarsParams = {
70
75
  barWidth: 0,
71
76
  barPadding: 1,
@@ -9,4 +9,6 @@ export { MultiLineAreas } from './plugins/MultiLineAreas'
9
9
  export { MultiDots } from './plugins/MultiDots'
10
10
  export { MultiGroupAxis } from './plugins/MultiGroupAxis'
11
11
  export { MultiValueAxis } from './plugins/MultiValueAxis'
12
- export { OverlappingValueAxes } from './plugins/OverlappingValueAxes'
12
+ export { MultiValueStackAxis } from './plugins/MultiValueStackAxis'
13
+ export { OverlappingValueAxes } from './plugins/OverlappingValueAxes'
14
+ export { OverlappingValueStackAxes } from './plugins/OverlappingValueStackAxes'
@@ -23,7 +23,7 @@ interface MultiGridPluginParams {
23
23
  }
24
24
 
25
25
  // 對應grid資料的plugin所需Observable(必須有gridIndexes)
26
- export const multiGridPluginObservables = (observer: ContextObserverMultiGrid<MultiGridPluginParams>): Observable<ContextObserverMultiGridDetail[]> => {
26
+ export const multiGridPluginDetailObservables = (observer: ContextObserverMultiGrid<MultiGridPluginParams>): Observable<ContextObserverMultiGridDetail[]> => {
27
27
  const gridIndexes$ = observer.fullParams$.pipe(
28
28
  map(fullParams => fullParams.gridIndexes),
29
29
  distinctUntilChanged(),
@@ -40,4 +40,5 @@ export const multiGridPluginObservables = (observer: ContextObserverMultiGrid<Mu
40
40
  })
41
41
  })
42
42
  )
43
- }
43
+ }
44
+
@@ -10,7 +10,7 @@ import {
10
10
  defineMultiGridPlugin } from '@orbcharts/core'
11
11
  import { DEFAULT_MULTI_BAR_STACK_PARAMS } from '../defaults'
12
12
  import { createBaseBarStack } from '../../base/BaseBarStack'
13
- import { multiGridPluginObservables } from '../multiGridObservables'
13
+ import { multiGridPluginDetailObservables } from '../multiGridObservables'
14
14
  import { getClassName, getUniID } from '../../utils/orbchartsUtils'
15
15
 
16
16
  const pluginName = 'MultiBarStack'
@@ -22,9 +22,9 @@ export const MultiBarStack = defineMultiGridPlugin(pluginName, DEFAULT_MULTI_BAR
22
22
 
23
23
  const unsubscribeFnArr: (() => void)[] = []
24
24
 
25
- const multiGridPlugin$ = multiGridPluginObservables(observer)
25
+ const multiGridPluginDetail$ = multiGridPluginDetailObservables(observer)
26
26
 
27
- multiGridPlugin$
27
+ multiGridPluginDetail$
28
28
  .pipe(
29
29
  takeUntil(destroy$)
30
30
  )
@@ -10,7 +10,7 @@ import {
10
10
  defineMultiGridPlugin } from '@orbcharts/core'
11
11
  import { DEFAULT_MULTI_BARS_PARAMS } from '../defaults'
12
12
  import { createBaseBars } from '../../base/BaseBars'
13
- import { multiGridPluginObservables } from '../multiGridObservables'
13
+ import { multiGridPluginDetailObservables } from '../multiGridObservables'
14
14
  import { getClassName, getUniID } from '../../utils/orbchartsUtils'
15
15
 
16
16
  const pluginName = 'MultiBars'
@@ -22,9 +22,9 @@ export const MultiBars = defineMultiGridPlugin(pluginName, DEFAULT_MULTI_BARS_PA
22
22
 
23
23
  const unsubscribeFnArr: (() => void)[] = []
24
24
 
25
- const multiGridPlugin$ = multiGridPluginObservables(observer)
25
+ const multiGridPluginDetail$ = multiGridPluginDetailObservables(observer)
26
26
 
27
- multiGridPlugin$
27
+ multiGridPluginDetail$
28
28
  .pipe(
29
29
  takeUntil(destroy$)
30
30
  )
@@ -10,7 +10,7 @@ import {
10
10
  defineMultiGridPlugin } from '@orbcharts/core'
11
11
  import { DEFAULT_MULTI_BARS_TRIANGLE_PARAMS } from '../defaults'
12
12
  import { createBaseBarsTriangle } from '../../base/BaseBarsTriangle'
13
- import { multiGridPluginObservables } from '../multiGridObservables'
13
+ import { multiGridPluginDetailObservables } from '../multiGridObservables'
14
14
  import { getClassName, getUniID } from '../../utils/orbchartsUtils'
15
15
 
16
16
  const pluginName = 'MultiBarsTriangle'
@@ -22,9 +22,9 @@ export const MultiBarsTriangle = defineMultiGridPlugin(pluginName, DEFAULT_MULTI
22
22
 
23
23
  const unsubscribeFnArr: (() => void)[] = []
24
24
 
25
- const multiGridPlugin$ = multiGridPluginObservables(observer)
25
+ const multiGridPluginDetail$ = multiGridPluginDetailObservables(observer)
26
26
 
27
- multiGridPlugin$
27
+ multiGridPluginDetail$
28
28
  .pipe(
29
29
  takeUntil(destroy$)
30
30
  )
@@ -6,7 +6,7 @@ import {
6
6
  defineMultiGridPlugin } from '@orbcharts/core'
7
7
  import { DEFAULT_MULTI_DOTS_PARAMS } from '../defaults'
8
8
  import { createBaseDots } from '../../base/BaseDots'
9
- import { multiGridPluginObservables } from '../multiGridObservables'
9
+ import { multiGridPluginDetailObservables } from '../multiGridObservables'
10
10
  import { getClassName, getUniID } from '../../utils/orbchartsUtils'
11
11
 
12
12
  const pluginName = 'MultiDots'
@@ -18,9 +18,9 @@ export const MultiDots = defineMultiGridPlugin(pluginName, DEFAULT_MULTI_DOTS_PA
18
18
 
19
19
  const unsubscribeFnArr: (() => void)[] = []
20
20
 
21
- const multiGridPlugin$ = multiGridPluginObservables(observer)
21
+ const multiGridPluginDetail$ = multiGridPluginDetailObservables(observer)
22
22
 
23
- multiGridPlugin$
23
+ multiGridPluginDetail$
24
24
  .pipe(
25
25
  takeUntil(destroy$)
26
26
  )
@@ -10,7 +10,7 @@ import {
10
10
  defineMultiGridPlugin } from '@orbcharts/core'
11
11
  import { DEFAULT_MULTI_GROUP_AXIS_PARAMS } from '../defaults'
12
12
  import { createBaseGroupAxis } from '../../base/BaseGroupAxis'
13
- import { multiGridPluginObservables } from '../multiGridObservables'
13
+ import { multiGridPluginDetailObservables } from '../multiGridObservables'
14
14
  import { getClassName, getUniID } from '../../utils/orbchartsUtils'
15
15
 
16
16
  const pluginName = 'MultiGroupAxis'
@@ -22,9 +22,9 @@ export const MultiGroupAxis = defineMultiGridPlugin(pluginName, DEFAULT_MULTI_GR
22
22
 
23
23
  const unsubscribeFnArr: (() => void)[] = []
24
24
 
25
- const multiGridPlugin$ = multiGridPluginObservables(observer)
25
+ const multiGridPluginDetail$ = multiGridPluginDetailObservables(observer)
26
26
 
27
- multiGridPlugin$
27
+ multiGridPluginDetail$
28
28
  .pipe(
29
29
  takeUntil(destroy$)
30
30
  )
@@ -7,7 +7,7 @@ import {
7
7
 
8
8
  import { DEFAULT_MULTI_LINE_AREAS_PARAMS } from '../defaults'
9
9
  import { createBaseLineAreas } from '../../base/BaseLineAreas'
10
- import { multiGridPluginObservables } from '../multiGridObservables'
10
+ import { multiGridPluginDetailObservables } from '../multiGridObservables'
11
11
  import { getClassName, getUniID } from '../../utils/orbchartsUtils'
12
12
 
13
13
  const pluginName = 'MultiLineAreas'
@@ -19,9 +19,9 @@ export const MultiLineAreas = defineMultiGridPlugin(pluginName, DEFAULT_MULTI_LI
19
19
 
20
20
  const unsubscribeFnArr: (() => void)[] = []
21
21
 
22
- const multiGridPlugin$ = multiGridPluginObservables(observer)
22
+ const multiGridPluginDetail$ = multiGridPluginDetailObservables(observer)
23
23
 
24
- multiGridPlugin$
24
+ multiGridPluginDetail$
25
25
  .pipe(
26
26
  takeUntil(destroy$)
27
27
  )
@@ -7,7 +7,7 @@ import {
7
7
 
8
8
  import { DEFAULT_MULTI_LINES_PARAMS } from '../defaults'
9
9
  import { createBaseLines } from '../../base/BaseLines'
10
- import { multiGridPluginObservables } from '../multiGridObservables'
10
+ import { multiGridPluginDetailObservables } from '../multiGridObservables'
11
11
  import { getClassName, getUniID } from '../../utils/orbchartsUtils'
12
12
 
13
13
  const pluginName = 'MultiLines'
@@ -19,9 +19,9 @@ export const MultiLines = defineMultiGridPlugin(pluginName, DEFAULT_MULTI_LINES_
19
19
 
20
20
  const unsubscribeFnArr: (() => void)[] = []
21
21
 
22
- const multiGridPlugin$ = multiGridPluginObservables(observer)
22
+ const multiGridPluginDetail$ = multiGridPluginDetailObservables(observer)
23
23
 
24
- multiGridPlugin$
24
+ multiGridPluginDetail$
25
25
  .pipe(
26
26
  takeUntil(destroy$)
27
27
  )
@@ -10,7 +10,7 @@ import {
10
10
  defineMultiGridPlugin } from '@orbcharts/core'
11
11
  import { DEFAULT_MULTI_VALUE_AXIS_PARAMS } from '../defaults'
12
12
  import { createBaseValueAxis } from '../../base/BaseValueAxis'
13
- import { multiGridPluginObservables } from '../multiGridObservables'
13
+ import { multiGridPluginDetailObservables } from '../multiGridObservables'
14
14
  import { getClassName, getUniID } from '../../utils/orbchartsUtils'
15
15
 
16
16
  const pluginName = 'MultiValueAxis'
@@ -22,9 +22,9 @@ export const MultiValueAxis = defineMultiGridPlugin(pluginName, DEFAULT_MULTI_VA
22
22
 
23
23
  const unsubscribeFnArr: (() => void)[] = []
24
24
 
25
- const multiGridPlugin$ = multiGridPluginObservables(observer)
25
+ const multiGridPluginDetail$ = multiGridPluginDetailObservables(observer)
26
26
 
27
- multiGridPlugin$
27
+ multiGridPluginDetail$
28
28
  .pipe(
29
29
  takeUntil(destroy$)
30
30
  )
@@ -0,0 +1,69 @@
1
+ import * as d3 from 'd3'
2
+ import {
3
+ Subject,
4
+ map,
5
+ distinctUntilChanged,
6
+ shareReplay,
7
+ takeUntil
8
+ } from 'rxjs'
9
+ import {
10
+ defineMultiGridPlugin } from '@orbcharts/core'
11
+ import { DEFAULT_MULTI_VALUE_AXIS_PARAMS } from '../defaults'
12
+ import { createBaseValueAxis } from '../../base/BaseValueAxis'
13
+ import { multiGridPluginDetailObservables } from '../multiGridObservables'
14
+ import { getClassName, getUniID } from '../../utils/orbchartsUtils'
15
+
16
+ const pluginName = 'MultiValueStackAxis'
17
+
18
+ const gridClassName = getClassName(pluginName, 'grid')
19
+
20
+ export const MultiValueStackAxis = defineMultiGridPlugin(pluginName, DEFAULT_MULTI_VALUE_AXIS_PARAMS)(({ selection, name, subject, observer }) => {
21
+ const destroy$ = new Subject()
22
+
23
+ const unsubscribeFnArr: (() => void)[] = []
24
+
25
+ const multiGridPluginDetail$ = multiGridPluginDetailObservables(observer)
26
+
27
+ multiGridPluginDetail$
28
+ .pipe(
29
+ takeUntil(destroy$)
30
+ )
31
+ .subscribe(data => {
32
+ // 每次重新計算時,清除之前的訂閱
33
+ unsubscribeFnArr.forEach(fn => fn())
34
+
35
+ selection.selectAll(`g.${gridClassName}`)
36
+ .data(data)
37
+ .join('g')
38
+ .attr('class', gridClassName)
39
+ .each((d, i, g) => {
40
+
41
+ const gridSelection = d3.select(g[i])
42
+
43
+ const isSeriesSeprate$ = d.dataFormatter$.pipe(
44
+ takeUntil(destroy$),
45
+ map(d => d.grid.separateSeries),
46
+ distinctUntilChanged(),
47
+ shareReplay(1)
48
+ )
49
+
50
+ unsubscribeFnArr[i] = createBaseValueAxis(pluginName, {
51
+ selection: gridSelection,
52
+ computedData$: d.computedStackedData$, // 計算疊加value的資料
53
+ fullParams$: observer.fullParams$,
54
+ fullDataFormatter$: d.dataFormatter$,
55
+ fullChartParams$: observer.fullChartParams$,
56
+ gridAxesTransform$: d.gridAxesTransform$,
57
+ gridAxesReverseTransform$: d.gridAxesReverseTransform$,
58
+ gridAxesSize$: d.gridAxesSize$,
59
+ gridContainerPosition$: d.gridContainerPosition$,
60
+ isSeriesSeprate$,
61
+ })
62
+ })
63
+ })
64
+
65
+ return () => {
66
+ destroy$.next(undefined)
67
+ unsubscribeFnArr.forEach(fn => fn())
68
+ }
69
+ })
@@ -15,7 +15,7 @@ import {
15
15
  defineMultiGridPlugin } from '@orbcharts/core'
16
16
  import { DEFAULT_OVERLAPPING_VALUE_AXES_PARAMS } from '../defaults'
17
17
  import { createBaseValueAxis } from '../../base/BaseValueAxis'
18
- import { multiGridPluginObservables } from '../multiGridObservables'
18
+ import { multiGridPluginDetailObservables } from '../multiGridObservables'
19
19
  import { getClassName, getUniID } from '../../utils/orbchartsUtils'
20
20
  import { gridAxesTransformObservable, gridAxesReverseTransformObservable, gridContainerPositionObservable } from '@orbcharts/core/src/grid/gridObservables'
21
21
 
@@ -78,7 +78,7 @@ export const OverlappingValueAxes = defineMultiGridPlugin(pluginName, DEFAULT_OV
78
78
  })
79
79
  )
80
80
 
81
- const multiGridPlugin$ = of(observer).pipe(
81
+ const multiGridPluginDetail$ = of(observer).pipe(
82
82
  takeUntil(destroy$),
83
83
  map(observer => {
84
84
  // 將observer的gridIndexes限制在2個
@@ -94,7 +94,7 @@ export const OverlappingValueAxes = defineMultiGridPlugin(pluginName, DEFAULT_OV
94
94
  )
95
95
  }
96
96
  }),
97
- switchMap(observer => multiGridPluginObservables(observer)),
97
+ switchMap(observer => multiGridPluginDetailObservables(observer)),
98
98
  map(data => {
99
99
  return data.map((observables, index) => {
100
100
  if (index === 0) {
@@ -123,7 +123,7 @@ export const OverlappingValueAxes = defineMultiGridPlugin(pluginName, DEFAULT_OV
123
123
  })
124
124
  )
125
125
 
126
- multiGridPlugin$
126
+ multiGridPluginDetail$
127
127
  .pipe(
128
128
  takeUntil(destroy$)
129
129
  )
@@ -142,13 +142,6 @@ export const OverlappingValueAxes = defineMultiGridPlugin(pluginName, DEFAULT_OV
142
142
 
143
143
  const gridSelection = d3.select(g[i])
144
144
 
145
- const isSeriesSeprate$ = d.dataFormatter$.pipe(
146
- takeUntil(destroy$),
147
- map(d => d.grid.separateSeries),
148
- distinctUntilChanged(),
149
- shareReplay(1)
150
- )
151
-
152
145
  unsubscribeFnArr[i] = createBaseValueAxis(pluginName, {
153
146
  selection: gridSelection,
154
147
  computedData$: d.computedData$,
@@ -161,7 +154,7 @@ export const OverlappingValueAxes = defineMultiGridPlugin(pluginName, DEFAULT_OV
161
154
  gridAxesReverseTransform$: d.gridAxesReverseTransform$,
162
155
  gridAxesSize$: d.gridAxesSize$,
163
156
  gridContainerPosition$: d.gridContainerPosition$,
164
- isSeriesSeprate$,
157
+ isSeriesSeprate$: d.isSeriesSeprate$,
165
158
  })
166
159
  })
167
160
  })