@orbcharts/plugins-basic 3.0.0-alpha.43 → 3.0.0-alpha.45
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/{src → orbcharts-plugins-basic/src}/base/BaseBarStack.d.ts +6 -4
- package/dist/{src → orbcharts-plugins-basic/src}/base/BaseBars.d.ts +6 -4
- package/dist/{src → orbcharts-plugins-basic/src}/base/BaseBarsTriangle.d.ts +7 -4
- package/dist/{src → orbcharts-plugins-basic/src}/base/BaseDots.d.ts +5 -3
- package/dist/{src → orbcharts-plugins-basic/src}/base/BaseGroupAxis.d.ts +3 -3
- package/dist/{src → orbcharts-plugins-basic/src}/base/BaseLegend.d.ts +1 -0
- package/dist/{src → orbcharts-plugins-basic/src}/base/BaseLineAreas.d.ts +6 -3
- package/dist/{src → orbcharts-plugins-basic/src}/base/BaseLines.d.ts +6 -3
- package/dist/{src → orbcharts-plugins-basic/src}/base/BaseValueAxis.d.ts +3 -3
- package/dist/{src → orbcharts-plugins-basic/src}/grid/gridObservables.d.ts +4 -4
- package/dist/orbcharts-plugins-basic/src/index.d.ts +5 -0
- package/dist/orbcharts-plugins-basic/src/multiGrid/multiGridObservables.d.ts +8 -0
- package/dist/orbcharts-plugins-basic/src/series/plugins/PieEventTexts.d.ts +3 -0
- package/dist/orbcharts-plugins-basic/src/series/seriesObservables.d.ts +21 -0
- package/dist/{src → orbcharts-plugins-basic/src}/series/seriesUtils.d.ts +3 -3
- package/dist/orbcharts-plugins-basic.es.js +8349 -8142
- package/dist/orbcharts-plugins-basic.umd.js +8 -8
- package/dist/src/index.d.ts +1 -5
- package/package.json +2 -2
- package/src/base/BaseBarStack.ts +105 -208
- package/src/base/BaseBars.ts +78 -64
- package/src/base/BaseBarsTriangle.ts +76 -63
- package/src/base/BaseDots.ts +41 -178
- package/src/base/BaseGroupAxis.ts +16 -16
- package/src/base/BaseLegend.ts +18 -13
- package/src/base/BaseLineAreas.ts +85 -81
- package/src/base/BaseLines.ts +82 -75
- package/src/base/BaseValueAxis.ts +17 -18
- package/src/grid/gridObservables.ts +22 -38
- package/src/grid/plugins/BarStack.ts +16 -3
- package/src/grid/plugins/Bars.ts +18 -4
- package/src/grid/plugins/BarsDiverging.ts +6 -4
- package/src/grid/plugins/BarsTriangle.ts +20 -4
- package/src/grid/plugins/Dots.ts +4 -2
- package/src/grid/plugins/GridLegend.ts +2 -1
- package/src/grid/plugins/GroupAux.ts +8 -6
- package/src/grid/plugins/GroupAxis.ts +15 -3
- package/src/grid/plugins/LineAreas.ts +5 -2
- package/src/grid/plugins/Lines.ts +5 -2
- package/src/grid/plugins/ScalingArea.ts +0 -1
- package/src/grid/plugins/ValueAxis.ts +15 -3
- package/src/grid/plugins/ValueStackAxis.ts +14 -5
- package/src/multiGrid/multiGridObservables.ts +14 -261
- package/src/multiGrid/plugins/MultiBarStack.ts +22 -8
- package/src/multiGrid/plugins/MultiBars.ts +21 -7
- package/src/multiGrid/plugins/MultiBarsTriangle.ts +22 -7
- package/src/multiGrid/plugins/MultiDots.ts +7 -5
- package/src/multiGrid/plugins/MultiGridLegend.ts +3 -2
- package/src/multiGrid/plugins/MultiGroupAxis.ts +19 -7
- package/src/multiGrid/plugins/MultiLineAreas.ts +9 -6
- package/src/multiGrid/plugins/MultiLines.ts +9 -6
- package/src/multiGrid/plugins/MultiValueAxis.ts +19 -7
- package/src/multiGrid/plugins/OverlappingValueAxes.ts +52 -47
- package/src/noneData/defaults.ts +3 -0
- package/src/noneData/plugins/Tooltip.ts +9 -3
- package/src/series/defaults.ts +13 -3
- package/src/series/plugins/Bubbles.ts +57 -37
- package/src/series/plugins/Pie.ts +300 -352
- package/src/series/plugins/PieEventTexts.ts +102 -38
- package/src/series/plugins/PieLabels.ts +95 -48
- package/src/series/plugins/SeriesLegend.ts +2 -1
- package/src/series/seriesObservables.ts +145 -0
- package/src/series/seriesUtils.ts +4 -4
- package/src/tree/plugins/TreeLegend.ts +2 -1
- package/src/tree/plugins/TreeMap.ts +8 -5
- package/tsconfig.json +3 -0
- package/dist/src/multiGrid/multiGridObservables.d.ts +0 -12
- package/dist/src/series/plugins/PieEventTexts.d.ts +0 -1
- /package/dist/{src → orbcharts-plugins-basic/src}/base/BaseGroupArea.d.ts +0 -0
- /package/dist/{src → orbcharts-plugins-basic/src}/base/types.d.ts +0 -0
- /package/dist/{src → orbcharts-plugins-basic/src}/grid/defaults.d.ts +0 -0
- /package/dist/{src → orbcharts-plugins-basic/src}/grid/index.d.ts +0 -0
- /package/dist/{src → orbcharts-plugins-basic/src}/grid/plugins/BarStack.d.ts +0 -0
- /package/dist/{src → orbcharts-plugins-basic/src}/grid/plugins/Bars.d.ts +0 -0
- /package/dist/{src → orbcharts-plugins-basic/src}/grid/plugins/BarsDiverging.d.ts +0 -0
- /package/dist/{src → orbcharts-plugins-basic/src}/grid/plugins/BarsTriangle.d.ts +0 -0
- /package/dist/{src → orbcharts-plugins-basic/src}/grid/plugins/Dots.d.ts +0 -0
- /package/dist/{src → orbcharts-plugins-basic/src}/grid/plugins/GridLegend.d.ts +0 -0
- /package/dist/{src → orbcharts-plugins-basic/src}/grid/plugins/GroupAux.d.ts +0 -0
- /package/dist/{src → orbcharts-plugins-basic/src}/grid/plugins/GroupAxis.d.ts +0 -0
- /package/dist/{src → orbcharts-plugins-basic/src}/grid/plugins/LineAreas.d.ts +0 -0
- /package/dist/{src → orbcharts-plugins-basic/src}/grid/plugins/Lines.d.ts +0 -0
- /package/dist/{src → orbcharts-plugins-basic/src}/grid/plugins/Ranking.d.ts +0 -0
- /package/dist/{src → orbcharts-plugins-basic/src}/grid/plugins/RankingAxis.d.ts +0 -0
- /package/dist/{src → orbcharts-plugins-basic/src}/grid/plugins/ScalingArea.d.ts +0 -0
- /package/dist/{src → orbcharts-plugins-basic/src}/grid/plugins/ValueAxis.d.ts +0 -0
- /package/dist/{src → orbcharts-plugins-basic/src}/grid/plugins/ValueStackAxis.d.ts +0 -0
- /package/dist/{src → orbcharts-plugins-basic/src}/grid/types.d.ts +0 -0
- /package/dist/{src → orbcharts-plugins-basic/src}/multiGrid/defaults.d.ts +0 -0
- /package/dist/{src → orbcharts-plugins-basic/src}/multiGrid/index.d.ts +0 -0
- /package/dist/{src → orbcharts-plugins-basic/src}/multiGrid/plugins/MultiBarStack.d.ts +0 -0
- /package/dist/{src → orbcharts-plugins-basic/src}/multiGrid/plugins/MultiBars.d.ts +0 -0
- /package/dist/{src → orbcharts-plugins-basic/src}/multiGrid/plugins/MultiBarsTriangle.d.ts +0 -0
- /package/dist/{src → orbcharts-plugins-basic/src}/multiGrid/plugins/MultiDots.d.ts +0 -0
- /package/dist/{src → orbcharts-plugins-basic/src}/multiGrid/plugins/MultiGridLegend.d.ts +0 -0
- /package/dist/{src → orbcharts-plugins-basic/src}/multiGrid/plugins/MultiGroupAxis.d.ts +0 -0
- /package/dist/{src → orbcharts-plugins-basic/src}/multiGrid/plugins/MultiLineAreas.d.ts +0 -0
- /package/dist/{src → orbcharts-plugins-basic/src}/multiGrid/plugins/MultiLines.d.ts +0 -0
- /package/dist/{src → orbcharts-plugins-basic/src}/multiGrid/plugins/MultiValueAxis.d.ts +0 -0
- /package/dist/{src → orbcharts-plugins-basic/src}/multiGrid/plugins/OverlappingValueAxes.d.ts +0 -0
- /package/dist/{src → orbcharts-plugins-basic/src}/multiGrid/types.d.ts +0 -0
- /package/dist/{src → orbcharts-plugins-basic/src}/multiValue/index.d.ts +0 -0
- /package/dist/{src → orbcharts-plugins-basic/src}/multiValue/plugins/Scatter.d.ts +0 -0
- /package/dist/{src → orbcharts-plugins-basic/src}/multiValue/plugins/ScatterAxes.d.ts +0 -0
- /package/dist/{src → orbcharts-plugins-basic/src}/noneData/defaults.d.ts +0 -0
- /package/dist/{src → orbcharts-plugins-basic/src}/noneData/index.d.ts +0 -0
- /package/dist/{src → orbcharts-plugins-basic/src}/noneData/plugins/Container.d.ts +0 -0
- /package/dist/{src → orbcharts-plugins-basic/src}/noneData/plugins/Tooltip.d.ts +0 -0
- /package/dist/{src → orbcharts-plugins-basic/src}/noneData/types.d.ts +0 -0
- /package/dist/{src → orbcharts-plugins-basic/src}/relationship/index.d.ts +0 -0
- /package/dist/{src → orbcharts-plugins-basic/src}/relationship/plugins/Relationship.d.ts +0 -0
- /package/dist/{src → orbcharts-plugins-basic/src}/series/defaults.d.ts +0 -0
- /package/dist/{src → orbcharts-plugins-basic/src}/series/index.d.ts +0 -0
- /package/dist/{src → orbcharts-plugins-basic/src}/series/plugins/Bubbles.d.ts +0 -0
- /package/dist/{src → orbcharts-plugins-basic/src}/series/plugins/Pie.d.ts +0 -0
- /package/dist/{src → orbcharts-plugins-basic/src}/series/plugins/PieLabels.d.ts +0 -0
- /package/dist/{src → orbcharts-plugins-basic/src}/series/plugins/SeriesLegend.d.ts +0 -0
- /package/dist/{src → orbcharts-plugins-basic/src}/series/plugins/Waffle.d.ts +0 -0
- /package/dist/{src → orbcharts-plugins-basic/src}/series/types.d.ts +0 -0
- /package/dist/{src → orbcharts-plugins-basic/src}/tree/defaults.d.ts +0 -0
- /package/dist/{src → orbcharts-plugins-basic/src}/tree/index.d.ts +0 -0
- /package/dist/{src → orbcharts-plugins-basic/src}/tree/plugins/TreeLegend.d.ts +0 -0
- /package/dist/{src → orbcharts-plugins-basic/src}/tree/plugins/TreeMap.d.ts +0 -0
- /package/dist/{src → orbcharts-plugins-basic/src}/tree/types.d.ts +0 -0
- /package/dist/{src → orbcharts-plugins-basic/src}/utils/commonUtils.d.ts +0 -0
- /package/dist/{src → orbcharts-plugins-basic/src}/utils/d3Graphics.d.ts +0 -0
- /package/dist/{src → orbcharts-plugins-basic/src}/utils/d3Utils.d.ts +0 -0
- /package/dist/{src → orbcharts-plugins-basic/src}/utils/observables.d.ts +0 -0
- /package/dist/{src → orbcharts-plugins-basic/src}/utils/orbchartsUtils.d.ts +0 -0
- /package/dist/{vite.config.d.ts → orbcharts-plugins-basic/vite.config.d.ts} +0 -0
@@ -19,18 +19,19 @@ import type {
|
|
19
19
|
ComputedDataGrid,
|
20
20
|
ComputedDatumGrid,
|
21
21
|
TransformData,
|
22
|
-
|
22
|
+
GridContainerPosition,
|
23
23
|
Layout } from '@orbcharts/core'
|
24
24
|
import { createAxisQuantizeScale } from '@orbcharts/core'
|
25
25
|
import { getClassName, getUniID } from '../utils/orbchartsUtils'
|
26
26
|
|
27
|
-
|
27
|
+
// grid選取器
|
28
|
+
export const gridSelectionsObservable = ({ selection, pluginName, clipPathID, seriesLabels$, gridContainerPosition$, gridAxesTransform$, gridGraphicTransform$ }: {
|
28
29
|
selection: d3.Selection<any, unknown, any, unknown>
|
29
30
|
pluginName: string
|
30
31
|
clipPathID: string
|
31
32
|
// computedData$: Observable<ComputedDataGrid>
|
32
|
-
|
33
|
-
|
33
|
+
seriesLabels$: Observable<string[]>
|
34
|
+
gridContainerPosition$: Observable<GridContainerPosition[]>
|
34
35
|
gridAxesTransform$: Observable<TransformData>
|
35
36
|
gridGraphicTransform$: Observable<TransformData>
|
36
37
|
}) => {
|
@@ -38,7 +39,7 @@ export const gridSelectionsObservable = ({ selection, pluginName, clipPathID, ex
|
|
38
39
|
const axesClassName = getClassName(pluginName, 'axes')
|
39
40
|
const graphicClassName = getClassName(pluginName, 'graphic')
|
40
41
|
|
41
|
-
const seriesSelection$ =
|
42
|
+
const seriesSelection$ = seriesLabels$.pipe(
|
42
43
|
map((existSeriesLabels, i) => {
|
43
44
|
return selection
|
44
45
|
.selectAll<SVGGElement, string>(`g.${seriesClassName}`)
|
@@ -80,39 +81,24 @@ export const gridSelectionsObservable = ({ selection, pluginName, clipPathID, ex
|
|
80
81
|
exit => exit.remove()
|
81
82
|
)
|
82
83
|
}),
|
83
|
-
switchMap(selection => combineLatest({
|
84
|
-
seriesSelection: of(selection),
|
85
|
-
gridContainer: gridContainer$
|
86
|
-
})),
|
87
|
-
map(data => {
|
88
|
-
data.seriesSelection
|
89
|
-
.transition()
|
90
|
-
.attr('transform', (d, i) => {
|
91
|
-
const gridContainer = data.gridContainer[i] ?? data.gridContainer[0]
|
92
|
-
const translate = gridContainer.translate
|
93
|
-
const scale = gridContainer.scale
|
94
|
-
return `translate(${translate[0]}, ${translate[1]}) scale(${scale[0]}, ${scale[1]})`
|
95
|
-
})
|
96
|
-
return data.seriesSelection
|
97
|
-
}),
|
98
84
|
shareReplay(1)
|
99
85
|
)
|
100
86
|
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
87
|
+
combineLatest({
|
88
|
+
seriesSelection: seriesSelection$,
|
89
|
+
gridContainerPosition: gridContainerPosition$
|
90
|
+
}).pipe(
|
91
|
+
switchMap(async d => d)
|
92
|
+
).subscribe(data => {
|
93
|
+
data.seriesSelection
|
94
|
+
.transition()
|
95
|
+
.attr('transform', (d, i) => {
|
96
|
+
const gridContainerPosition = data.gridContainerPosition[i] ?? data.gridContainerPosition[0]
|
97
|
+
const translate = gridContainerPosition.translate
|
98
|
+
const scale = gridContainerPosition.scale
|
99
|
+
return `translate(${translate[0]}, ${translate[1]}) scale(${scale[0]}, ${scale[1]})`
|
100
|
+
})
|
101
|
+
})
|
116
102
|
|
117
103
|
const axesSelection$ = combineLatest({
|
118
104
|
seriesSelection: seriesSelection$,
|
@@ -177,7 +163,6 @@ export const gridGroupPositionFnObservable = ({ fullDataFormatter$, gridAxesSize
|
|
177
163
|
computedData: computedData$
|
178
164
|
}).pipe(
|
179
165
|
takeUntil(destroy$),
|
180
|
-
// 轉換後會退訂前一個未完成的訂閱事件,因此可以取到「同時間」最後一次的訂閱事件
|
181
166
|
switchMap(async (d) => d),
|
182
167
|
).subscribe(data => {
|
183
168
|
const groupMin = 0
|
@@ -193,7 +178,7 @@ export const gridGroupPositionFnObservable = ({ fullDataFormatter$, gridAxesSize
|
|
193
178
|
// ? data.computedData[0].length
|
194
179
|
// : 0
|
195
180
|
|
196
|
-
let _labels = data.dataFormatter.grid.
|
181
|
+
let _labels = data.dataFormatter.grid.seriesDirection === 'row'
|
197
182
|
? (data.computedData[0] ?? []).map(d => d.groupLabel)
|
198
183
|
: data.computedData.map(d => d[0].groupLabel)
|
199
184
|
|
@@ -220,7 +205,6 @@ export const gridGroupPositionFnObservable = ({ fullDataFormatter$, gridAxesSize
|
|
220
205
|
scaleRangeGroupLabels: scaleRangeGroupLabels$
|
221
206
|
}).pipe(
|
222
207
|
takeUntil(destroy$),
|
223
|
-
// 轉換後會退訂前一個未完成的訂閱事件,因此可以取到「同時間」最後一次的訂閱事件
|
224
208
|
switchMap(async (d) => d),
|
225
209
|
).subscribe(data => {
|
226
210
|
|
@@ -1,4 +1,8 @@
|
|
1
1
|
import {
|
2
|
+
map,
|
3
|
+
distinctUntilChanged,
|
4
|
+
shareReplay,
|
5
|
+
takeUntil,
|
2
6
|
Subject,
|
3
7
|
Observable } from 'rxjs'
|
4
8
|
import { defineGridPlugin } from '@orbcharts/core'
|
@@ -11,11 +15,20 @@ const pluginName = 'BarStack'
|
|
11
15
|
export const BarStack = defineGridPlugin(pluginName, DEFAULT_BAR_STACK_PARAMS)(({ selection, name, subject, observer }) => {
|
12
16
|
const destroy$ = new Subject()
|
13
17
|
|
18
|
+
const isSeriesSeprate$ = observer.fullDataFormatter$.pipe(
|
19
|
+
takeUntil(destroy$),
|
20
|
+
map(d => d.grid.separateSeries),
|
21
|
+
distinctUntilChanged(),
|
22
|
+
shareReplay(1)
|
23
|
+
)
|
24
|
+
|
14
25
|
const unsubscribeBaseBars = createBaseBarStack(pluginName, {
|
15
26
|
selection,
|
16
27
|
computedData$: observer.computedData$,
|
28
|
+
computedLayoutData$: observer.computedLayoutData$,
|
17
29
|
visibleComputedData$: observer.visibleComputedData$,
|
18
|
-
|
30
|
+
visibleComputedLayoutData$: observer.visibleComputedLayoutData$,
|
31
|
+
seriesLabels$: observer.seriesLabels$,
|
19
32
|
SeriesDataMap$: observer.SeriesDataMap$,
|
20
33
|
GroupDataMap$: observer.GroupDataMap$,
|
21
34
|
fullParams$: observer.fullParams$,
|
@@ -26,8 +39,8 @@ export const BarStack = defineGridPlugin(pluginName, DEFAULT_BAR_STACK_PARAMS)((
|
|
26
39
|
gridGraphicReverseScale$: observer.gridGraphicReverseScale$,
|
27
40
|
gridAxesSize$: observer.gridAxesSize$,
|
28
41
|
gridHighlight$: observer.gridHighlight$,
|
29
|
-
|
30
|
-
|
42
|
+
gridContainerPosition$: observer.gridContainerPosition$,
|
43
|
+
isSeriesSeprate$,
|
31
44
|
event$: subject.event$,
|
32
45
|
})
|
33
46
|
|
package/src/grid/plugins/Bars.ts
CHANGED
@@ -1,6 +1,11 @@
|
|
1
1
|
import {
|
2
2
|
Subject,
|
3
|
-
Observable
|
3
|
+
Observable,
|
4
|
+
map,
|
5
|
+
distinctUntilChanged,
|
6
|
+
shareReplay,
|
7
|
+
takeUntil
|
8
|
+
} from 'rxjs'
|
4
9
|
import {
|
5
10
|
defineGridPlugin } from '@orbcharts/core'
|
6
11
|
import { DEFAULT_BARS_PARAMS } from '../defaults'
|
@@ -11,11 +16,20 @@ const pluginName = 'Bars'
|
|
11
16
|
export const Bars = defineGridPlugin(pluginName, DEFAULT_BARS_PARAMS)(({ selection, name, subject, observer }) => {
|
12
17
|
const destroy$ = new Subject()
|
13
18
|
|
19
|
+
const isSeriesSeprate$ = observer.fullDataFormatter$.pipe(
|
20
|
+
takeUntil(destroy$),
|
21
|
+
map(d => d.grid.separateSeries),
|
22
|
+
distinctUntilChanged(),
|
23
|
+
shareReplay(1)
|
24
|
+
)
|
25
|
+
|
14
26
|
const unsubscribeBaseBars = createBaseBars(pluginName, {
|
15
27
|
selection,
|
16
28
|
computedData$: observer.computedData$,
|
29
|
+
computedLayoutData$: observer.computedLayoutData$,
|
17
30
|
visibleComputedData$: observer.visibleComputedData$,
|
18
|
-
|
31
|
+
visibleComputedLayoutData$: observer.visibleComputedLayoutData$,
|
32
|
+
seriesLabels$: observer.seriesLabels$,
|
19
33
|
SeriesDataMap$: observer.SeriesDataMap$,
|
20
34
|
GroupDataMap$: observer.GroupDataMap$,
|
21
35
|
fullParams$: observer.fullParams$,
|
@@ -25,8 +39,8 @@ export const Bars = defineGridPlugin(pluginName, DEFAULT_BARS_PARAMS)(({ selecti
|
|
25
39
|
gridGraphicReverseScale$: observer.gridGraphicReverseScale$,
|
26
40
|
gridAxesSize$: observer.gridAxesSize$,
|
27
41
|
gridHighlight$: observer.gridHighlight$,
|
28
|
-
|
29
|
-
|
42
|
+
gridContainerPosition$: observer.gridContainerPosition$,
|
43
|
+
isSeriesSeprate$: isSeriesSeprate$,
|
30
44
|
event$: subject.event$,
|
31
45
|
})
|
32
46
|
|
@@ -15,8 +15,10 @@ export const BarsDiverging = defineGridPlugin(pluginName, DEFAULT_BARS_PARAMS)((
|
|
15
15
|
const unsubscribeBaseBars = createBaseBars(pluginName, {
|
16
16
|
selection,
|
17
17
|
computedData$: observer.computedData$,
|
18
|
+
computedLayoutData$: observer.computedLayoutData$,
|
18
19
|
visibleComputedData$: observer.visibleComputedData$,
|
19
|
-
|
20
|
+
visibleComputedLayoutData$: observer.visibleComputedLayoutData$,
|
21
|
+
seriesLabels$: observer.seriesLabels$,
|
20
22
|
SeriesDataMap$: observer.SeriesDataMap$,
|
21
23
|
GroupDataMap$: observer.GroupDataMap$,
|
22
24
|
fullParams$: observer.fullParams$,
|
@@ -26,9 +28,9 @@ export const BarsDiverging = defineGridPlugin(pluginName, DEFAULT_BARS_PARAMS)((
|
|
26
28
|
gridGraphicReverseScale$: observer.gridGraphicReverseScale$,
|
27
29
|
gridAxesSize$: observer.gridAxesSize$,
|
28
30
|
gridHighlight$: observer.gridHighlight$,
|
29
|
-
|
30
|
-
//
|
31
|
-
|
31
|
+
gridContainerPosition$: observer.gridContainerPosition$,
|
32
|
+
// isSeriesSeprate$: observer.isSeriesSeprate$,
|
33
|
+
isSeriesSeprate$: of(true), // hack: 永遠為true,可以強制讓每組series的bars的x位置都是一樣的
|
32
34
|
event$: subject.event$,
|
33
35
|
})
|
34
36
|
|
@@ -1,6 +1,11 @@
|
|
1
1
|
import {
|
2
2
|
Subject,
|
3
|
-
Observable
|
3
|
+
Observable,
|
4
|
+
takeUntil,
|
5
|
+
map,
|
6
|
+
distinctUntilChanged,
|
7
|
+
shareReplay
|
8
|
+
} from 'rxjs'
|
4
9
|
import { defineGridPlugin } from '@orbcharts/core'
|
5
10
|
import { DEFAULT_BARS_TRIANGLE_PARAMS } from '../defaults'
|
6
11
|
import { createBaseBarsTriangle } from '../../base/BaseBarsTriangle'
|
@@ -10,11 +15,22 @@ const pluginName = 'BarsTriangle'
|
|
10
15
|
export const BarsTriangle = defineGridPlugin(pluginName, DEFAULT_BARS_TRIANGLE_PARAMS)(({ selection, name, subject, observer }) => {
|
11
16
|
const destroy$ = new Subject()
|
12
17
|
|
18
|
+
|
19
|
+
const isSeriesSeprate$ = observer.fullDataFormatter$.pipe(
|
20
|
+
takeUntil(destroy$),
|
21
|
+
map(d => d.grid.separateSeries),
|
22
|
+
distinctUntilChanged(),
|
23
|
+
shareReplay(1)
|
24
|
+
)
|
25
|
+
|
13
26
|
const unsubscribeBaseBars = createBaseBarsTriangle(pluginName, {
|
14
27
|
selection,
|
15
28
|
computedData$: observer.computedData$,
|
29
|
+
computedLayoutData$: observer.computedLayoutData$,
|
16
30
|
visibleComputedData$: observer.visibleComputedData$,
|
17
|
-
|
31
|
+
visibleComputedLayoutData$: observer.visibleComputedLayoutData$,
|
32
|
+
fullDataFormatter$: observer.fullDataFormatter$,
|
33
|
+
seriesLabels$: observer.seriesLabels$,
|
18
34
|
SeriesDataMap$: observer.SeriesDataMap$,
|
19
35
|
GroupDataMap$: observer.GroupDataMap$,
|
20
36
|
fullParams$: observer.fullParams$,
|
@@ -23,8 +39,8 @@ export const BarsTriangle = defineGridPlugin(pluginName, DEFAULT_BARS_TRIANGLE_P
|
|
23
39
|
gridGraphicTransform$: observer.gridGraphicTransform$,
|
24
40
|
gridAxesSize$: observer.gridAxesSize$,
|
25
41
|
gridHighlight$: observer.gridHighlight$,
|
26
|
-
|
27
|
-
|
42
|
+
gridContainerPosition$: observer.gridContainerPosition$,
|
43
|
+
isSeriesSeprate$,
|
28
44
|
event$: subject.event$,
|
29
45
|
})
|
30
46
|
|
package/src/grid/plugins/Dots.ts
CHANGED
@@ -14,8 +14,10 @@ export const Dots = defineGridPlugin(pluginName, DEFAULT_DOTS_PARAMS)(({ selecti
|
|
14
14
|
const unsubscribeBaseBars = createBaseDots(pluginName, {
|
15
15
|
selection,
|
16
16
|
computedData$: observer.computedData$,
|
17
|
+
computedLayoutData$: observer.computedLayoutData$,
|
17
18
|
visibleComputedData$: observer.visibleComputedData$,
|
18
|
-
|
19
|
+
visibleComputedLayoutData$: observer.visibleComputedLayoutData$,
|
20
|
+
seriesLabels$: observer.seriesLabels$,
|
19
21
|
SeriesDataMap$: observer.SeriesDataMap$,
|
20
22
|
GroupDataMap$: observer.GroupDataMap$,
|
21
23
|
fullParams$: observer.fullParams$,
|
@@ -25,7 +27,7 @@ export const Dots = defineGridPlugin(pluginName, DEFAULT_DOTS_PARAMS)(({ selecti
|
|
25
27
|
gridGraphicReverseScale$: observer.gridGraphicReverseScale$,
|
26
28
|
gridAxesSize$: observer.gridAxesSize$,
|
27
29
|
gridHighlight$: observer.gridHighlight$,
|
28
|
-
|
30
|
+
gridContainerPosition$: observer.gridContainerPosition$,
|
29
31
|
event$: subject.event$,
|
30
32
|
})
|
31
33
|
|
@@ -47,7 +47,8 @@ export const GridLegend = defineGridPlugin(pluginName, DEFAULT_GRID_LEGEND_PARAM
|
|
47
47
|
seriesLabels$,
|
48
48
|
fullParams$,
|
49
49
|
layout$: observer.layout$,
|
50
|
-
fullChartParams$: observer.fullChartParams
|
50
|
+
fullChartParams$: observer.fullChartParams$,
|
51
|
+
textSizePx$: observer.textSizePx$
|
51
52
|
})
|
52
53
|
|
53
54
|
return () => {
|
@@ -126,14 +126,15 @@ function createLabelData ({ groupLabel, axisX, fullParams }: {
|
|
126
126
|
: []
|
127
127
|
}
|
128
128
|
|
129
|
-
function renderLabel ({ selection, labelData, fullParams, fullChartParams, gridAxesReverseTransformValue }: {
|
129
|
+
function renderLabel ({ selection, labelData, fullParams, fullChartParams, gridAxesReverseTransformValue, textSizePx }: {
|
130
130
|
selection: d3.Selection<any, unknown, any, unknown>
|
131
131
|
labelData: LabelDatum[]
|
132
132
|
fullParams: GroupAuxParams
|
133
133
|
fullChartParams: ChartParams
|
134
134
|
gridAxesReverseTransformValue: string
|
135
|
+
textSizePx: number
|
135
136
|
}) {
|
136
|
-
const rectHeight =
|
137
|
+
const rectHeight = textSizePx + 4
|
137
138
|
|
138
139
|
const gUpdate = selection
|
139
140
|
.selectAll<SVGGElement, LabelDatum>(`g.${labelClassName}`)
|
@@ -157,7 +158,7 @@ function renderLabel ({ selection, labelData, fullParams, fullChartParams, gridA
|
|
157
158
|
gUpdate.exit().remove()
|
158
159
|
|
159
160
|
axisLabelSelection.each((datum, i, n) => {
|
160
|
-
const rectWidth = measureTextWidth(datum.text,
|
161
|
+
const rectWidth = measureTextWidth(datum.text, textSizePx) + 12
|
161
162
|
const rectX = - rectWidth / 2
|
162
163
|
|
163
164
|
const rectUpdate = d3.select(n[i])
|
@@ -335,7 +336,7 @@ export const GroupAux = defineGridPlugin(pluginName, DEFAULT_GROUP_AREA_PARAMS)(
|
|
335
336
|
? data.computedData[0].length
|
336
337
|
: 0
|
337
338
|
|
338
|
-
let _labels = data.fullDataFormatter.grid.
|
339
|
+
let _labels = data.fullDataFormatter.grid.seriesDirection === 'row'
|
339
340
|
// ? data.fullDataFormatter.grid.columnLabels
|
340
341
|
// : data.fullDataFormatter.grid.rowLabels
|
341
342
|
? (data.computedData[0] ?? []).map(d => d.groupLabel)
|
@@ -390,7 +391,6 @@ export const GroupAux = defineGridPlugin(pluginName, DEFAULT_GROUP_AREA_PARAMS)(
|
|
390
391
|
groupScale: groupScale$,
|
391
392
|
}).pipe(
|
392
393
|
takeUntil(destroy$),
|
393
|
-
// 轉換後會退訂前一個未完成的訂閱事件,因此可以取到「同時間」最後一次的訂閱事件
|
394
394
|
switchMap(async (d) => d),
|
395
395
|
).subscribe(data => {
|
396
396
|
|
@@ -503,6 +503,7 @@ export const GroupAux = defineGridPlugin(pluginName, DEFAULT_GROUP_AREA_PARAMS)(
|
|
503
503
|
gridAxesReverseTransform: observer.gridAxesReverseTransform$,
|
504
504
|
GroupDataMap: observer.GroupDataMap$,
|
505
505
|
gridGroupPositionFn: gridGroupPositionFn$,
|
506
|
+
textSizePx: observer.textSizePx$
|
506
507
|
}).pipe(
|
507
508
|
takeUntil(destroy$),
|
508
509
|
switchMap(async d => d)
|
@@ -539,7 +540,8 @@ export const GroupAux = defineGridPlugin(pluginName, DEFAULT_GROUP_AREA_PARAMS)(
|
|
539
540
|
labelData,
|
540
541
|
fullParams: data.fullParams,
|
541
542
|
fullChartParams: data.fullChartParams,
|
542
|
-
gridAxesReverseTransformValue: data.gridAxesReverseTransform.value
|
543
|
+
gridAxesReverseTransformValue: data.gridAxesReverseTransform.value,
|
544
|
+
textSizePx: data.textSizePx
|
543
545
|
})
|
544
546
|
|
545
547
|
// label的事件
|
@@ -1,5 +1,10 @@
|
|
1
1
|
import {
|
2
|
-
Subject
|
2
|
+
Subject,
|
3
|
+
takeUntil,
|
4
|
+
map,
|
5
|
+
distinctUntilChanged,
|
6
|
+
shareReplay
|
7
|
+
} from 'rxjs'
|
3
8
|
import {
|
4
9
|
defineGridPlugin } from '@orbcharts/core'
|
5
10
|
import { DEFAULT_GROUP_AXIS_PARAMS } from '../defaults'
|
@@ -11,6 +16,13 @@ export const GroupAxis = defineGridPlugin(pluginName, DEFAULT_GROUP_AXIS_PARAMS)
|
|
11
16
|
|
12
17
|
const destroy$ = new Subject()
|
13
18
|
|
19
|
+
const isSeriesSeprate$ = observer.fullDataFormatter$.pipe(
|
20
|
+
takeUntil(destroy$),
|
21
|
+
map(d => d.grid.separateSeries),
|
22
|
+
distinctUntilChanged(),
|
23
|
+
shareReplay(1)
|
24
|
+
)
|
25
|
+
|
14
26
|
const unsubscribeBaseGroupAxis = createBaseGroupAxis(pluginName, {
|
15
27
|
selection,
|
16
28
|
computedData$: observer.computedData$,
|
@@ -20,8 +32,8 @@ export const GroupAxis = defineGridPlugin(pluginName, DEFAULT_GROUP_AXIS_PARAMS)
|
|
20
32
|
gridAxesTransform$: observer.gridAxesTransform$,
|
21
33
|
gridAxesReverseTransform$: observer.gridAxesReverseTransform$,
|
22
34
|
gridAxesSize$: observer.gridAxesSize$,
|
23
|
-
|
24
|
-
|
35
|
+
gridContainerPosition$: observer.gridContainerPosition$,
|
36
|
+
isSeriesSeprate$,
|
25
37
|
})
|
26
38
|
|
27
39
|
return () => {
|
@@ -14,7 +14,10 @@ export const LineAreas = defineGridPlugin(pluginName, DEFAULT_LINE_AREAS_PARAMS)
|
|
14
14
|
const unsubscribeBaseBars = createBaseLineAreas(pluginName, {
|
15
15
|
selection,
|
16
16
|
computedData$: observer.computedData$,
|
17
|
-
|
17
|
+
visibleComputedData$: observer.visibleComputedData$,
|
18
|
+
computedLayoutData$: observer.computedLayoutData$,
|
19
|
+
visibleComputedLayoutData$: observer.visibleComputedLayoutData$,
|
20
|
+
seriesLabels$: observer.seriesLabels$,
|
18
21
|
SeriesDataMap$: observer.SeriesDataMap$,
|
19
22
|
GroupDataMap$: observer.GroupDataMap$,
|
20
23
|
fullParams$: observer.fullParams$,
|
@@ -24,7 +27,7 @@ export const LineAreas = defineGridPlugin(pluginName, DEFAULT_LINE_AREAS_PARAMS)
|
|
24
27
|
gridGraphicTransform$: observer.gridGraphicTransform$,
|
25
28
|
gridAxesSize$: observer.gridAxesSize$,
|
26
29
|
gridHighlight$: observer.gridHighlight$,
|
27
|
-
|
30
|
+
gridContainerPosition$: observer.gridContainerPosition$,
|
28
31
|
layout$: observer.layout$,
|
29
32
|
event$: subject.event$,
|
30
33
|
})
|
@@ -14,7 +14,10 @@ export const Lines = defineGridPlugin(pluginName, DEFAULT_LINES_PARAMS)(({ selec
|
|
14
14
|
const unsubscribeBaseBars = createBaseLines(pluginName, {
|
15
15
|
selection,
|
16
16
|
computedData$: observer.computedData$,
|
17
|
-
|
17
|
+
computedLayoutData$: observer.computedLayoutData$,
|
18
|
+
visibleComputedData$: observer.visibleComputedData$,
|
19
|
+
visibleComputedLayoutData$: observer.visibleComputedLayoutData$,
|
20
|
+
seriesLabels$: observer.seriesLabels$,
|
18
21
|
SeriesDataMap$: observer.SeriesDataMap$,
|
19
22
|
GroupDataMap$: observer.GroupDataMap$,
|
20
23
|
fullParams$: observer.fullParams$,
|
@@ -24,7 +27,7 @@ export const Lines = defineGridPlugin(pluginName, DEFAULT_LINES_PARAMS)(({ selec
|
|
24
27
|
gridGraphicTransform$: observer.gridGraphicTransform$,
|
25
28
|
gridAxesSize$: observer.gridAxesSize$,
|
26
29
|
gridHighlight$: observer.gridHighlight$,
|
27
|
-
|
30
|
+
gridContainerPosition$: observer.gridContainerPosition$,
|
28
31
|
event$: subject.event$,
|
29
32
|
})
|
30
33
|
|
@@ -76,7 +76,6 @@ export const ScalingArea = defineGridPlugin(pluginName, DEFAULT_SCALING_AREA_PAR
|
|
76
76
|
axisSize: observer.gridAxesSize$
|
77
77
|
}).pipe(
|
78
78
|
takeUntil(destroy$),
|
79
|
-
// 轉換後會退訂前一個未完成的訂閱事件,因此可以取到「同時間」最後一次的訂閱事件
|
80
79
|
switchMap(async (d) => d),
|
81
80
|
).subscribe(data => {
|
82
81
|
const groupMin = 0
|
@@ -1,5 +1,10 @@
|
|
1
1
|
import {
|
2
|
-
Subject
|
2
|
+
Subject,
|
3
|
+
takeUntil,
|
4
|
+
map,
|
5
|
+
distinctUntilChanged,
|
6
|
+
shareReplay
|
7
|
+
} from 'rxjs'
|
3
8
|
import {
|
4
9
|
defineGridPlugin } from '@orbcharts/core'
|
5
10
|
import { DEFAULT_VALUE_AXIS_PARAMS } from '../defaults'
|
@@ -12,6 +17,13 @@ export const ValueAxis = defineGridPlugin(pluginName, DEFAULT_VALUE_AXIS_PARAMS)
|
|
12
17
|
|
13
18
|
const destroy$ = new Subject()
|
14
19
|
|
20
|
+
const isSeriesSeprate$ = observer.fullDataFormatter$.pipe(
|
21
|
+
takeUntil(destroy$),
|
22
|
+
map(d => d.grid.separateSeries),
|
23
|
+
distinctUntilChanged(),
|
24
|
+
shareReplay(1)
|
25
|
+
)
|
26
|
+
|
15
27
|
const unsubscribeBaseValueAxis = createBaseValueAxis(pluginName, {
|
16
28
|
selection,
|
17
29
|
computedData$: observer.computedData$,
|
@@ -21,8 +33,8 @@ export const ValueAxis = defineGridPlugin(pluginName, DEFAULT_VALUE_AXIS_PARAMS)
|
|
21
33
|
gridAxesTransform$: observer.gridAxesTransform$,
|
22
34
|
gridAxesReverseTransform$: observer.gridAxesReverseTransform$,
|
23
35
|
gridAxesSize$: observer.gridAxesSize$,
|
24
|
-
|
25
|
-
|
36
|
+
gridContainerPosition$: observer.gridContainerPosition$,
|
37
|
+
isSeriesSeprate$,
|
26
38
|
})
|
27
39
|
|
28
40
|
return () => {
|
@@ -1,6 +1,8 @@
|
|
1
1
|
import {
|
2
2
|
takeUntil,
|
3
3
|
map,
|
4
|
+
distinctUntilChanged,
|
5
|
+
shareReplay,
|
4
6
|
switchMap,
|
5
7
|
iif,
|
6
8
|
Subject } from 'rxjs'
|
@@ -47,11 +49,18 @@ export const ValueStackAxis = defineGridPlugin(pluginName, DEFAULT_VALUE_STACK_A
|
|
47
49
|
}),
|
48
50
|
)
|
49
51
|
|
52
|
+
const isSeriesSeprate$ = observer.fullDataFormatter$.pipe(
|
53
|
+
takeUntil(destroy$),
|
54
|
+
map(d => d.grid.separateSeries),
|
55
|
+
distinctUntilChanged(),
|
56
|
+
shareReplay(1)
|
57
|
+
)
|
58
|
+
|
50
59
|
const unsubscribeBaseValueAxis = createBaseValueAxis(pluginName, {
|
51
60
|
selection,
|
52
|
-
computedData$:
|
53
|
-
switchMap(
|
54
|
-
return iif(() =>
|
61
|
+
computedData$: isSeriesSeprate$.pipe(
|
62
|
+
switchMap(isSeriesSeprate => {
|
63
|
+
return iif(() => isSeriesSeprate, observer.computedData$, stackedData$)
|
55
64
|
})
|
56
65
|
),
|
57
66
|
fullParams$: observer.fullParams$,
|
@@ -60,8 +69,8 @@ export const ValueStackAxis = defineGridPlugin(pluginName, DEFAULT_VALUE_STACK_A
|
|
60
69
|
gridAxesTransform$: observer.gridAxesTransform$,
|
61
70
|
gridAxesReverseTransform$: observer.gridAxesReverseTransform$,
|
62
71
|
gridAxesSize$: observer.gridAxesSize$,
|
63
|
-
|
64
|
-
|
72
|
+
gridContainerPosition$: observer.gridContainerPosition$,
|
73
|
+
isSeriesSeprate$,
|
65
74
|
})
|
66
75
|
|
67
76
|
return () => {
|