@orbcharts/plugins-basic 3.0.0-alpha.42 → 3.0.0-alpha.43
Sign up to get free protection for your applications and to get access to all the features.
- package/LICENSE +200 -200
- package/dist/orbcharts-plugins-basic.es.js +5477 -5426
- package/dist/orbcharts-plugins-basic.umd.js +8 -8
- package/dist/src/base/BaseBarStack.d.ts +1 -1
- package/dist/src/base/BaseBars.d.ts +1 -1
- package/dist/src/base/BaseBarsTriangle.d.ts +1 -1
- package/dist/src/base/BaseDots.d.ts +1 -1
- package/dist/src/base/BaseLineAreas.d.ts +1 -1
- package/dist/src/base/BaseLines.d.ts +1 -1
- package/dist/src/multiGrid/defaults.d.ts +2 -1
- package/dist/src/multiGrid/index.d.ts +1 -0
- package/dist/src/multiGrid/plugins/MultiLineAreas.d.ts +1 -0
- package/dist/src/multiGrid/types.d.ts +4 -4
- package/package.json +42 -42
- package/src/base/BaseBarStack.ts +881 -879
- package/src/base/BaseBars.ts +750 -748
- package/src/base/BaseBarsTriangle.ts +659 -657
- package/src/base/BaseDots.ts +639 -637
- package/src/base/BaseGroupAxis.ts +496 -496
- package/src/base/BaseLegend.ts +636 -636
- package/src/base/BaseLineAreas.ts +621 -624
- package/src/base/BaseLines.ts +692 -695
- package/src/base/BaseValueAxis.ts +479 -479
- package/src/base/types.ts +2 -2
- package/src/grid/defaults.ts +121 -121
- package/src/grid/gridObservables.ts +263 -263
- package/src/grid/index.ts +15 -15
- package/src/grid/plugins/BarStack.ts +37 -37
- package/src/grid/plugins/Bars.ts +37 -37
- package/src/grid/plugins/BarsDiverging.ts +39 -39
- package/src/grid/plugins/BarsTriangle.ts +34 -34
- package/src/grid/plugins/Dots.ts +35 -35
- package/src/grid/plugins/GridLegend.ts +58 -58
- package/src/grid/plugins/GroupAux.ts +643 -643
- package/src/grid/plugins/GroupAxis.ts +30 -30
- package/src/grid/plugins/LineAreas.ts +36 -36
- package/src/grid/plugins/Lines.ts +35 -35
- package/src/grid/plugins/ScalingArea.ts +174 -174
- package/src/grid/plugins/ValueAxis.ts +31 -31
- package/src/grid/plugins/ValueStackAxis.ts +70 -70
- package/src/grid/types.ts +120 -120
- package/src/index.ts +9 -9
- package/src/multiGrid/defaults.ts +147 -140
- package/src/multiGrid/index.ts +11 -10
- package/src/multiGrid/multiGridObservables.ts +289 -278
- package/src/multiGrid/plugins/MultiBarStack.ts +60 -60
- package/src/multiGrid/plugins/MultiBars.ts +59 -59
- package/src/multiGrid/plugins/MultiBarsTriangle.ts +58 -58
- package/src/multiGrid/plugins/MultiDots.ts +58 -58
- package/src/multiGrid/plugins/MultiGridLegend.ts +88 -88
- package/src/multiGrid/plugins/MultiGroupAxis.ts +53 -53
- package/src/multiGrid/plugins/MultiLineAreas.ts +59 -0
- package/src/multiGrid/plugins/MultiLines.ts +58 -58
- package/src/multiGrid/plugins/MultiValueAxis.ts +53 -53
- package/src/multiGrid/plugins/OverlappingValueAxes.ts +164 -165
- package/src/multiGrid/types.ts +67 -67
- package/src/noneData/defaults.ts +61 -61
- package/src/noneData/index.ts +3 -3
- package/src/noneData/plugins/Container.ts +10 -10
- package/src/noneData/plugins/Tooltip.ts +304 -304
- package/src/noneData/types.ts +26 -26
- package/src/series/defaults.ts +99 -99
- package/src/series/index.ts +6 -6
- package/src/series/plugins/Bubbles.ts +551 -549
- package/src/series/plugins/Pie.ts +600 -598
- package/src/series/plugins/PieEventTexts.ts +194 -194
- package/src/series/plugins/PieLabels.ts +288 -285
- package/src/series/plugins/SeriesLegend.ts +58 -58
- package/src/series/seriesUtils.ts +50 -50
- package/src/series/types.ts +67 -67
- package/src/tree/defaults.ts +22 -22
- package/src/tree/index.ts +3 -3
- package/src/tree/plugins/TreeLegend.ts +58 -58
- package/src/tree/plugins/TreeMap.ts +302 -300
- package/src/tree/types.ts +23 -23
- package/src/utils/commonUtils.ts +21 -21
- package/src/utils/d3Graphics.ts +124 -124
- package/src/utils/d3Utils.ts +73 -73
- package/src/utils/observables.ts +14 -14
- package/src/utils/orbchartsUtils.ts +100 -100
- package/tsconfig.dev.json +16 -16
- package/tsconfig.json +13 -13
- package/tsconfig.prod.json +13 -13
- package/vite.config.js +49 -49
package/src/grid/plugins/Bars.ts
CHANGED
@@ -1,37 +1,37 @@
|
|
1
|
-
import {
|
2
|
-
Subject,
|
3
|
-
Observable } from 'rxjs'
|
4
|
-
import {
|
5
|
-
defineGridPlugin } from '@orbcharts/core'
|
6
|
-
import { DEFAULT_BARS_PARAMS } from '../defaults'
|
7
|
-
import { createBaseBars } from '../../base/BaseBars'
|
8
|
-
|
9
|
-
const pluginName = 'Bars'
|
10
|
-
|
11
|
-
export const Bars = defineGridPlugin(pluginName, DEFAULT_BARS_PARAMS)(({ selection, name, subject, observer }) => {
|
12
|
-
const destroy$ = new Subject()
|
13
|
-
|
14
|
-
const unsubscribeBaseBars = createBaseBars(pluginName, {
|
15
|
-
selection,
|
16
|
-
computedData$: observer.computedData$,
|
17
|
-
visibleComputedData$: observer.visibleComputedData$,
|
18
|
-
existSeriesLabels$: observer.existSeriesLabels$,
|
19
|
-
SeriesDataMap$: observer.SeriesDataMap$,
|
20
|
-
GroupDataMap$: observer.GroupDataMap$,
|
21
|
-
fullParams$: observer.fullParams$,
|
22
|
-
fullChartParams$: observer.fullChartParams$,
|
23
|
-
gridAxesTransform$: observer.gridAxesTransform$,
|
24
|
-
gridGraphicTransform$: observer.gridGraphicTransform$,
|
25
|
-
gridGraphicReverseScale$: observer.gridGraphicReverseScale$,
|
26
|
-
gridAxesSize$: observer.gridAxesSize$,
|
27
|
-
gridHighlight$: observer.gridHighlight$,
|
28
|
-
gridContainer$: observer.gridContainer$,
|
29
|
-
isSeriesPositionSeprate$: observer.isSeriesPositionSeprate$,
|
30
|
-
event$: subject.event$,
|
31
|
-
})
|
32
|
-
|
33
|
-
return () => {
|
34
|
-
destroy$.next(undefined)
|
35
|
-
unsubscribeBaseBars()
|
36
|
-
}
|
37
|
-
})
|
1
|
+
import {
|
2
|
+
Subject,
|
3
|
+
Observable } from 'rxjs'
|
4
|
+
import {
|
5
|
+
defineGridPlugin } from '@orbcharts/core'
|
6
|
+
import { DEFAULT_BARS_PARAMS } from '../defaults'
|
7
|
+
import { createBaseBars } from '../../base/BaseBars'
|
8
|
+
|
9
|
+
const pluginName = 'Bars'
|
10
|
+
|
11
|
+
export const Bars = defineGridPlugin(pluginName, DEFAULT_BARS_PARAMS)(({ selection, name, subject, observer }) => {
|
12
|
+
const destroy$ = new Subject()
|
13
|
+
|
14
|
+
const unsubscribeBaseBars = createBaseBars(pluginName, {
|
15
|
+
selection,
|
16
|
+
computedData$: observer.computedData$,
|
17
|
+
visibleComputedData$: observer.visibleComputedData$,
|
18
|
+
existSeriesLabels$: observer.existSeriesLabels$,
|
19
|
+
SeriesDataMap$: observer.SeriesDataMap$,
|
20
|
+
GroupDataMap$: observer.GroupDataMap$,
|
21
|
+
fullParams$: observer.fullParams$,
|
22
|
+
fullChartParams$: observer.fullChartParams$,
|
23
|
+
gridAxesTransform$: observer.gridAxesTransform$,
|
24
|
+
gridGraphicTransform$: observer.gridGraphicTransform$,
|
25
|
+
gridGraphicReverseScale$: observer.gridGraphicReverseScale$,
|
26
|
+
gridAxesSize$: observer.gridAxesSize$,
|
27
|
+
gridHighlight$: observer.gridHighlight$,
|
28
|
+
gridContainer$: observer.gridContainer$,
|
29
|
+
isSeriesPositionSeprate$: observer.isSeriesPositionSeprate$,
|
30
|
+
event$: subject.event$,
|
31
|
+
})
|
32
|
+
|
33
|
+
return () => {
|
34
|
+
destroy$.next(undefined)
|
35
|
+
unsubscribeBaseBars()
|
36
|
+
}
|
37
|
+
})
|
@@ -1,39 +1,39 @@
|
|
1
|
-
import {
|
2
|
-
of,
|
3
|
-
Subject,
|
4
|
-
Observable } from 'rxjs'
|
5
|
-
import {
|
6
|
-
defineGridPlugin } from '@orbcharts/core'
|
7
|
-
import { DEFAULT_BARS_PARAMS } from '../defaults'
|
8
|
-
import { createBaseBars } from '../../base/BaseBars'
|
9
|
-
|
10
|
-
const pluginName = 'BarsDiverging'
|
11
|
-
|
12
|
-
export const BarsDiverging = defineGridPlugin(pluginName, DEFAULT_BARS_PARAMS)(({ selection, name, subject, observer }) => {
|
13
|
-
const destroy$ = new Subject()
|
14
|
-
|
15
|
-
const unsubscribeBaseBars = createBaseBars(pluginName, {
|
16
|
-
selection,
|
17
|
-
computedData$: observer.computedData$,
|
18
|
-
visibleComputedData$: observer.visibleComputedData$,
|
19
|
-
existSeriesLabels$: observer.existSeriesLabels$,
|
20
|
-
SeriesDataMap$: observer.SeriesDataMap$,
|
21
|
-
GroupDataMap$: observer.GroupDataMap$,
|
22
|
-
fullParams$: observer.fullParams$,
|
23
|
-
fullChartParams$: observer.fullChartParams$,
|
24
|
-
gridAxesTransform$: observer.gridAxesTransform$,
|
25
|
-
gridGraphicTransform$: observer.gridGraphicTransform$,
|
26
|
-
gridGraphicReverseScale$: observer.gridGraphicReverseScale$,
|
27
|
-
gridAxesSize$: observer.gridAxesSize$,
|
28
|
-
gridHighlight$: observer.gridHighlight$,
|
29
|
-
gridContainer$: observer.gridContainer$,
|
30
|
-
// isSeriesPositionSeprate$: observer.isSeriesPositionSeprate$,
|
31
|
-
isSeriesPositionSeprate$: of(true), // hack: 永遠為true,可以強制讓每組series的bars的x位置都是一樣的
|
32
|
-
event$: subject.event$,
|
33
|
-
})
|
34
|
-
|
35
|
-
return () => {
|
36
|
-
destroy$.next(undefined)
|
37
|
-
unsubscribeBaseBars()
|
38
|
-
}
|
39
|
-
})
|
1
|
+
import {
|
2
|
+
of,
|
3
|
+
Subject,
|
4
|
+
Observable } from 'rxjs'
|
5
|
+
import {
|
6
|
+
defineGridPlugin } from '@orbcharts/core'
|
7
|
+
import { DEFAULT_BARS_PARAMS } from '../defaults'
|
8
|
+
import { createBaseBars } from '../../base/BaseBars'
|
9
|
+
|
10
|
+
const pluginName = 'BarsDiverging'
|
11
|
+
|
12
|
+
export const BarsDiverging = defineGridPlugin(pluginName, DEFAULT_BARS_PARAMS)(({ selection, name, subject, observer }) => {
|
13
|
+
const destroy$ = new Subject()
|
14
|
+
|
15
|
+
const unsubscribeBaseBars = createBaseBars(pluginName, {
|
16
|
+
selection,
|
17
|
+
computedData$: observer.computedData$,
|
18
|
+
visibleComputedData$: observer.visibleComputedData$,
|
19
|
+
existSeriesLabels$: observer.existSeriesLabels$,
|
20
|
+
SeriesDataMap$: observer.SeriesDataMap$,
|
21
|
+
GroupDataMap$: observer.GroupDataMap$,
|
22
|
+
fullParams$: observer.fullParams$,
|
23
|
+
fullChartParams$: observer.fullChartParams$,
|
24
|
+
gridAxesTransform$: observer.gridAxesTransform$,
|
25
|
+
gridGraphicTransform$: observer.gridGraphicTransform$,
|
26
|
+
gridGraphicReverseScale$: observer.gridGraphicReverseScale$,
|
27
|
+
gridAxesSize$: observer.gridAxesSize$,
|
28
|
+
gridHighlight$: observer.gridHighlight$,
|
29
|
+
gridContainer$: observer.gridContainer$,
|
30
|
+
// isSeriesPositionSeprate$: observer.isSeriesPositionSeprate$,
|
31
|
+
isSeriesPositionSeprate$: of(true), // hack: 永遠為true,可以強制讓每組series的bars的x位置都是一樣的
|
32
|
+
event$: subject.event$,
|
33
|
+
})
|
34
|
+
|
35
|
+
return () => {
|
36
|
+
destroy$.next(undefined)
|
37
|
+
unsubscribeBaseBars()
|
38
|
+
}
|
39
|
+
})
|
@@ -1,35 +1,35 @@
|
|
1
|
-
import {
|
2
|
-
Subject,
|
3
|
-
Observable } from 'rxjs'
|
4
|
-
import { defineGridPlugin } from '@orbcharts/core'
|
5
|
-
import { DEFAULT_BARS_TRIANGLE_PARAMS } from '../defaults'
|
6
|
-
import { createBaseBarsTriangle } from '../../base/BaseBarsTriangle'
|
7
|
-
|
8
|
-
const pluginName = 'BarsTriangle'
|
9
|
-
|
10
|
-
export const BarsTriangle = defineGridPlugin(pluginName, DEFAULT_BARS_TRIANGLE_PARAMS)(({ selection, name, subject, observer }) => {
|
11
|
-
const destroy$ = new Subject()
|
12
|
-
|
13
|
-
const unsubscribeBaseBars = createBaseBarsTriangle(pluginName, {
|
14
|
-
selection,
|
15
|
-
computedData$: observer.computedData$,
|
16
|
-
visibleComputedData$: observer.visibleComputedData$,
|
17
|
-
existSeriesLabels$: observer.existSeriesLabels$,
|
18
|
-
SeriesDataMap$: observer.SeriesDataMap$,
|
19
|
-
GroupDataMap$: observer.GroupDataMap$,
|
20
|
-
fullParams$: observer.fullParams$,
|
21
|
-
fullChartParams$: observer.fullChartParams$,
|
22
|
-
gridAxesTransform$: observer.gridAxesTransform$,
|
23
|
-
gridGraphicTransform$: observer.gridGraphicTransform$,
|
24
|
-
gridAxesSize$: observer.gridAxesSize$,
|
25
|
-
gridHighlight$: observer.gridHighlight$,
|
26
|
-
gridContainer$: observer.gridContainer$,
|
27
|
-
isSeriesPositionSeprate$: observer.isSeriesPositionSeprate$,
|
28
|
-
event$: subject.event$,
|
29
|
-
})
|
30
|
-
|
31
|
-
return () => {
|
32
|
-
destroy$.next(undefined)
|
33
|
-
unsubscribeBaseBars()
|
34
|
-
}
|
1
|
+
import {
|
2
|
+
Subject,
|
3
|
+
Observable } from 'rxjs'
|
4
|
+
import { defineGridPlugin } from '@orbcharts/core'
|
5
|
+
import { DEFAULT_BARS_TRIANGLE_PARAMS } from '../defaults'
|
6
|
+
import { createBaseBarsTriangle } from '../../base/BaseBarsTriangle'
|
7
|
+
|
8
|
+
const pluginName = 'BarsTriangle'
|
9
|
+
|
10
|
+
export const BarsTriangle = defineGridPlugin(pluginName, DEFAULT_BARS_TRIANGLE_PARAMS)(({ selection, name, subject, observer }) => {
|
11
|
+
const destroy$ = new Subject()
|
12
|
+
|
13
|
+
const unsubscribeBaseBars = createBaseBarsTriangle(pluginName, {
|
14
|
+
selection,
|
15
|
+
computedData$: observer.computedData$,
|
16
|
+
visibleComputedData$: observer.visibleComputedData$,
|
17
|
+
existSeriesLabels$: observer.existSeriesLabels$,
|
18
|
+
SeriesDataMap$: observer.SeriesDataMap$,
|
19
|
+
GroupDataMap$: observer.GroupDataMap$,
|
20
|
+
fullParams$: observer.fullParams$,
|
21
|
+
fullChartParams$: observer.fullChartParams$,
|
22
|
+
gridAxesTransform$: observer.gridAxesTransform$,
|
23
|
+
gridGraphicTransform$: observer.gridGraphicTransform$,
|
24
|
+
gridAxesSize$: observer.gridAxesSize$,
|
25
|
+
gridHighlight$: observer.gridHighlight$,
|
26
|
+
gridContainer$: observer.gridContainer$,
|
27
|
+
isSeriesPositionSeprate$: observer.isSeriesPositionSeprate$,
|
28
|
+
event$: subject.event$,
|
29
|
+
})
|
30
|
+
|
31
|
+
return () => {
|
32
|
+
destroy$.next(undefined)
|
33
|
+
unsubscribeBaseBars()
|
34
|
+
}
|
35
35
|
})
|
package/src/grid/plugins/Dots.ts
CHANGED
@@ -1,36 +1,36 @@
|
|
1
|
-
import {
|
2
|
-
Subject } from 'rxjs'
|
3
|
-
import {
|
4
|
-
defineGridPlugin } from '@orbcharts/core'
|
5
|
-
import { DEFAULT_DOTS_PARAMS } from '../defaults'
|
6
|
-
import { createBaseDots } from '../../base/BaseDots'
|
7
|
-
|
8
|
-
const pluginName = 'Dots'
|
9
|
-
|
10
|
-
export const Dots = defineGridPlugin(pluginName, DEFAULT_DOTS_PARAMS)(({ selection, name, subject, observer }) => {
|
11
|
-
|
12
|
-
const destroy$ = new Subject()
|
13
|
-
|
14
|
-
const unsubscribeBaseBars = createBaseDots(pluginName, {
|
15
|
-
selection,
|
16
|
-
computedData$: observer.computedData$,
|
17
|
-
visibleComputedData$: observer.visibleComputedData$,
|
18
|
-
existSeriesLabels$: observer.existSeriesLabels$,
|
19
|
-
SeriesDataMap$: observer.SeriesDataMap$,
|
20
|
-
GroupDataMap$: observer.GroupDataMap$,
|
21
|
-
fullParams$: observer.fullParams$,
|
22
|
-
fullChartParams$: observer.fullChartParams$,
|
23
|
-
gridAxesTransform$: observer.gridAxesTransform$,
|
24
|
-
gridGraphicTransform$: observer.gridGraphicTransform$,
|
25
|
-
gridGraphicReverseScale$: observer.gridGraphicReverseScale$,
|
26
|
-
gridAxesSize$: observer.gridAxesSize$,
|
27
|
-
gridHighlight$: observer.gridHighlight$,
|
28
|
-
gridContainer$: observer.gridContainer$,
|
29
|
-
event$: subject.event$,
|
30
|
-
})
|
31
|
-
|
32
|
-
return () => {
|
33
|
-
destroy$.next(undefined)
|
34
|
-
unsubscribeBaseBars()
|
35
|
-
}
|
1
|
+
import {
|
2
|
+
Subject } from 'rxjs'
|
3
|
+
import {
|
4
|
+
defineGridPlugin } from '@orbcharts/core'
|
5
|
+
import { DEFAULT_DOTS_PARAMS } from '../defaults'
|
6
|
+
import { createBaseDots } from '../../base/BaseDots'
|
7
|
+
|
8
|
+
const pluginName = 'Dots'
|
9
|
+
|
10
|
+
export const Dots = defineGridPlugin(pluginName, DEFAULT_DOTS_PARAMS)(({ selection, name, subject, observer }) => {
|
11
|
+
|
12
|
+
const destroy$ = new Subject()
|
13
|
+
|
14
|
+
const unsubscribeBaseBars = createBaseDots(pluginName, {
|
15
|
+
selection,
|
16
|
+
computedData$: observer.computedData$,
|
17
|
+
visibleComputedData$: observer.visibleComputedData$,
|
18
|
+
existSeriesLabels$: observer.existSeriesLabels$,
|
19
|
+
SeriesDataMap$: observer.SeriesDataMap$,
|
20
|
+
GroupDataMap$: observer.GroupDataMap$,
|
21
|
+
fullParams$: observer.fullParams$,
|
22
|
+
fullChartParams$: observer.fullChartParams$,
|
23
|
+
gridAxesTransform$: observer.gridAxesTransform$,
|
24
|
+
gridGraphicTransform$: observer.gridGraphicTransform$,
|
25
|
+
gridGraphicReverseScale$: observer.gridGraphicReverseScale$,
|
26
|
+
gridAxesSize$: observer.gridAxesSize$,
|
27
|
+
gridHighlight$: observer.gridHighlight$,
|
28
|
+
gridContainer$: observer.gridContainer$,
|
29
|
+
event$: subject.event$,
|
30
|
+
})
|
31
|
+
|
32
|
+
return () => {
|
33
|
+
destroy$.next(undefined)
|
34
|
+
unsubscribeBaseBars()
|
35
|
+
}
|
36
36
|
})
|
@@ -1,58 +1,58 @@
|
|
1
|
-
import * as d3 from 'd3'
|
2
|
-
import {
|
3
|
-
combineLatest,
|
4
|
-
map,
|
5
|
-
switchMap,
|
6
|
-
takeUntil,
|
7
|
-
Observable,
|
8
|
-
Subject } from 'rxjs'
|
9
|
-
import {
|
10
|
-
defineGridPlugin } from '@orbcharts/core'
|
11
|
-
import { DEFAULT_GRID_LEGEND_PARAMS } from '../defaults'
|
12
|
-
import { createBaseLegend } from '../../base/BaseLegend'
|
13
|
-
|
14
|
-
const pluginName = 'GridLegend'
|
15
|
-
|
16
|
-
export const GridLegend = defineGridPlugin(pluginName, DEFAULT_GRID_LEGEND_PARAMS)(({ selection, rootSelection, observer, subject }) => {
|
17
|
-
|
18
|
-
const destroy$ = new Subject()
|
19
|
-
|
20
|
-
const seriesLabels$: Observable<string[]> = observer.SeriesDataMap$.pipe(
|
21
|
-
takeUntil(destroy$),
|
22
|
-
map(data => {
|
23
|
-
return Array.from(data.keys())
|
24
|
-
})
|
25
|
-
)
|
26
|
-
|
27
|
-
// 全部列點矩型使用相同樣式參數
|
28
|
-
const fullParams$ = observer.fullParams$.pipe(
|
29
|
-
takeUntil(destroy$),
|
30
|
-
map(d => {
|
31
|
-
const seriesList = [
|
32
|
-
{
|
33
|
-
listRectWidth: d.listRectWidth,
|
34
|
-
listRectHeight: d.listRectHeight,
|
35
|
-
listRectRadius: d.listRectRadius,
|
36
|
-
}
|
37
|
-
]
|
38
|
-
return {
|
39
|
-
...d,
|
40
|
-
seriesList
|
41
|
-
}
|
42
|
-
})
|
43
|
-
)
|
44
|
-
|
45
|
-
const unsubscribeBaseLegend = createBaseLegend(pluginName, {
|
46
|
-
rootSelection,
|
47
|
-
seriesLabels$,
|
48
|
-
fullParams$,
|
49
|
-
layout$: observer.layout$,
|
50
|
-
fullChartParams$: observer.fullChartParams$
|
51
|
-
})
|
52
|
-
|
53
|
-
return () => {
|
54
|
-
destroy$.next(undefined)
|
55
|
-
unsubscribeBaseLegend()
|
56
|
-
}
|
57
|
-
})
|
58
|
-
|
1
|
+
import * as d3 from 'd3'
|
2
|
+
import {
|
3
|
+
combineLatest,
|
4
|
+
map,
|
5
|
+
switchMap,
|
6
|
+
takeUntil,
|
7
|
+
Observable,
|
8
|
+
Subject } from 'rxjs'
|
9
|
+
import {
|
10
|
+
defineGridPlugin } from '@orbcharts/core'
|
11
|
+
import { DEFAULT_GRID_LEGEND_PARAMS } from '../defaults'
|
12
|
+
import { createBaseLegend } from '../../base/BaseLegend'
|
13
|
+
|
14
|
+
const pluginName = 'GridLegend'
|
15
|
+
|
16
|
+
export const GridLegend = defineGridPlugin(pluginName, DEFAULT_GRID_LEGEND_PARAMS)(({ selection, rootSelection, observer, subject }) => {
|
17
|
+
|
18
|
+
const destroy$ = new Subject()
|
19
|
+
|
20
|
+
const seriesLabels$: Observable<string[]> = observer.SeriesDataMap$.pipe(
|
21
|
+
takeUntil(destroy$),
|
22
|
+
map(data => {
|
23
|
+
return Array.from(data.keys())
|
24
|
+
})
|
25
|
+
)
|
26
|
+
|
27
|
+
// 全部列點矩型使用相同樣式參數
|
28
|
+
const fullParams$ = observer.fullParams$.pipe(
|
29
|
+
takeUntil(destroy$),
|
30
|
+
map(d => {
|
31
|
+
const seriesList = [
|
32
|
+
{
|
33
|
+
listRectWidth: d.listRectWidth,
|
34
|
+
listRectHeight: d.listRectHeight,
|
35
|
+
listRectRadius: d.listRectRadius,
|
36
|
+
}
|
37
|
+
]
|
38
|
+
return {
|
39
|
+
...d,
|
40
|
+
seriesList
|
41
|
+
}
|
42
|
+
})
|
43
|
+
)
|
44
|
+
|
45
|
+
const unsubscribeBaseLegend = createBaseLegend(pluginName, {
|
46
|
+
rootSelection,
|
47
|
+
seriesLabels$,
|
48
|
+
fullParams$,
|
49
|
+
layout$: observer.layout$,
|
50
|
+
fullChartParams$: observer.fullChartParams$
|
51
|
+
})
|
52
|
+
|
53
|
+
return () => {
|
54
|
+
destroy$.next(undefined)
|
55
|
+
unsubscribeBaseLegend()
|
56
|
+
}
|
57
|
+
})
|
58
|
+
|