@orbcharts/plugins-basic 3.0.0-alpha.34 → 3.0.0-alpha.36
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/orbcharts-plugins-basic.es.js +10136 -9414
- package/dist/orbcharts-plugins-basic.umd.js +10 -10
- package/dist/src/base/BaseBarStack.d.ts +5 -1
- package/dist/src/base/BaseBars.d.ts +5 -1
- package/dist/src/base/BaseBarsTriangle.d.ts +5 -1
- package/dist/src/base/BaseDots.d.ts +4 -1
- package/dist/src/base/BaseGroupAxis.d.ts +35 -0
- package/dist/src/base/BaseLines.d.ts +3 -1
- package/dist/src/base/BaseValueAxis.d.ts +36 -0
- package/dist/src/grid/defaults.d.ts +3 -3
- package/dist/src/grid/gridObservables.d.ts +18 -4
- package/dist/src/grid/index.d.ts +1 -1
- package/dist/src/grid/plugins/GroupAux.d.ts +3 -0
- package/dist/src/grid/plugins/GroupAxis.d.ts +1 -3
- package/dist/src/grid/plugins/ValueAxis.d.ts +1 -3
- package/dist/src/grid/plugins/ValueStackAxis.d.ts +1 -3
- package/dist/src/grid/types.d.ts +1 -1
- package/dist/src/multiGrid/defaults.d.ts +9 -2
- package/dist/src/multiGrid/index.d.ts +8 -1
- package/dist/src/multiGrid/multiGridObservables.d.ts +12 -0
- package/dist/src/multiGrid/plugins/MultiBarStack.d.ts +1 -0
- package/dist/src/multiGrid/plugins/MultiBars.d.ts +1 -0
- package/dist/src/multiGrid/plugins/MultiBarsTriangle.d.ts +1 -0
- package/dist/src/multiGrid/plugins/MultiDots.d.ts +1 -0
- package/dist/src/multiGrid/plugins/MultiGroupAxis.d.ts +1 -0
- package/dist/src/multiGrid/plugins/MultiLines.d.ts +1 -0
- package/dist/src/multiGrid/plugins/MultiValueAxis.d.ts +1 -0
- package/dist/src/multiGrid/plugins/OverlappingValueAxes.d.ts +1 -0
- package/dist/src/multiGrid/types.d.ts +31 -0
- package/package.json +2 -2
- package/src/base/BaseBarStack.ts +375 -198
- package/src/base/BaseBars.ts +297 -191
- package/src/base/BaseBarsTriangle.ts +344 -229
- package/src/base/BaseDots.ts +285 -117
- package/src/base/BaseGroupAxis.ts +497 -0
- package/src/base/BaseLegend.ts +54 -5
- package/src/base/BaseLines.ts +180 -50
- package/src/base/BaseValueAxis.ts +475 -0
- package/src/grid/defaults.ts +3 -3
- package/src/grid/gridObservables.ts +163 -14
- package/src/grid/index.ts +1 -1
- package/src/grid/plugins/BarStack.ts +4 -0
- package/src/grid/plugins/Bars.ts +4 -0
- package/src/grid/plugins/BarsTriangle.ts +4 -0
- package/src/grid/plugins/Dots.ts +3 -0
- package/src/grid/plugins/{GroupArea.ts → GroupAux.ts} +24 -24
- package/src/grid/plugins/GroupAxis.ts +16 -348
- package/src/grid/plugins/Lines.ts +2 -0
- package/src/grid/plugins/ScalingArea.ts +9 -6
- package/src/grid/plugins/ValueAxis.ts +13 -337
- package/src/grid/plugins/ValueStackAxis.ts +35 -336
- package/src/grid/types.ts +1 -1
- package/src/index.ts +1 -0
- package/src/multiGrid/defaults.ts +120 -14
- package/src/multiGrid/index.ts +9 -2
- package/src/multiGrid/multiGridObservables.ts +279 -0
- package/src/multiGrid/plugins/MultiBarStack.ts +60 -0
- package/src/multiGrid/plugins/MultiBars.ts +59 -0
- package/src/multiGrid/plugins/MultiBarsTriangle.ts +58 -0
- package/src/multiGrid/plugins/MultiDots.ts +58 -0
- package/src/multiGrid/plugins/MultiGridLegend.ts +2 -7
- package/src/multiGrid/plugins/MultiGroupAxis.ts +53 -0
- package/src/multiGrid/plugins/MultiLines.ts +58 -0
- package/src/multiGrid/plugins/MultiValueAxis.ts +53 -0
- package/src/multiGrid/plugins/OverlappingValueAxes.ts +165 -0
- package/src/multiGrid/types.ts +39 -0
- package/tsconfig.dev.json +17 -0
- package/tsconfig.prod.json +14 -0
- package/vite.config.js +5 -0
- package/dist/src/grid/plugins/GroupArea.d.ts +0 -3
- package/dist/src/multiGrid/plugins/BarsAndLines.d.ts +0 -1
- package/dist/src/multiGrid/plugins/FirstGroupScaleAxis.d.ts +0 -0
- package/dist/src/multiGrid/plugins/TwoValueScaleAxes.d.ts +0 -0
- package/src/multiGrid/plugins/BarStackAndLines.ts +0 -0
- package/src/multiGrid/plugins/BarsAndLines.ts +0 -126
- package/src/multiGrid/plugins/BarsTriangleAndLines.ts +0 -0
- package/src/multiGrid/plugins/FirstGroupScaleAxis.ts +0 -0
- package/src/multiGrid/plugins/TwoValueScaleAxes.ts +0 -0
- /package/dist/src/{multiGrid/plugins/BarStackAndLines.d.ts → base/BaseGroupArea.d.ts} +0 -0
- /package/{dist/src/multiGrid/plugins/BarsTriangleAndLines.d.ts → src/base/BaseGroupArea.ts} +0 -0
@@ -1,15 +1,164 @@
|
|
1
|
-
import
|
1
|
+
import * as d3 from 'd3'
|
2
|
+
import {
|
3
|
+
Observable,
|
4
|
+
Subject,
|
5
|
+
of,
|
6
|
+
takeUntil,
|
7
|
+
filter,
|
8
|
+
map,
|
9
|
+
switchMap,
|
10
|
+
combineLatest,
|
11
|
+
merge,
|
12
|
+
shareReplay,
|
13
|
+
distinctUntilChanged
|
14
|
+
} from 'rxjs'
|
2
15
|
import type {
|
3
16
|
ChartParams,
|
4
17
|
HighlightTarget,
|
5
18
|
DataFormatterGrid,
|
6
19
|
ComputedDataGrid,
|
7
20
|
ComputedDatumGrid,
|
21
|
+
TransformData,
|
22
|
+
ContainerPosition,
|
8
23
|
Layout } from '@orbcharts/core'
|
9
24
|
import { createAxisQuantizeScale } from '@orbcharts/core'
|
25
|
+
import { getClassName, getUniID } from '../utils/orbchartsUtils'
|
26
|
+
|
27
|
+
export const gridSelectionsObservable = ({ selection, pluginName, clipPathID, existedSeriesLabels$, gridContainer$, gridAxesTransform$, gridGraphicTransform$ }: {
|
28
|
+
selection: d3.Selection<any, unknown, any, unknown>
|
29
|
+
pluginName: string
|
30
|
+
clipPathID: string
|
31
|
+
// computedData$: Observable<ComputedDataGrid>
|
32
|
+
existedSeriesLabels$: Observable<string[]>
|
33
|
+
gridContainer$: Observable<ContainerPosition[]>
|
34
|
+
gridAxesTransform$: Observable<TransformData>
|
35
|
+
gridGraphicTransform$: Observable<TransformData>
|
36
|
+
}) => {
|
37
|
+
const seriesClassName = getClassName(pluginName, 'series')
|
38
|
+
const axesClassName = getClassName(pluginName, 'axes')
|
39
|
+
const graphicClassName = getClassName(pluginName, 'graphic')
|
40
|
+
|
41
|
+
const seriesSelection$ = existedSeriesLabels$.pipe(
|
42
|
+
map((existedSeriesLabels, i) => {
|
43
|
+
return selection
|
44
|
+
.selectAll<SVGGElement, string>(`g.${seriesClassName}`)
|
45
|
+
.data(existedSeriesLabels, d => d)
|
46
|
+
.join(
|
47
|
+
enter => {
|
48
|
+
return enter
|
49
|
+
.append('g')
|
50
|
+
.classed(seriesClassName, true)
|
51
|
+
.each((d, i, g) => {
|
52
|
+
const axesSelection = d3.select(g[i])
|
53
|
+
.selectAll<SVGGElement, ComputedDatumGrid[]>(`g.${axesClassName}`)
|
54
|
+
.data([i])
|
55
|
+
.join(
|
56
|
+
enter => {
|
57
|
+
return enter
|
58
|
+
.append('g')
|
59
|
+
.classed(axesClassName, true)
|
60
|
+
.attr('clip-path', `url(#${clipPathID})`)
|
61
|
+
.each((d, i, g) => {
|
62
|
+
const defsSelection = d3.select(g[i])
|
63
|
+
.selectAll<SVGDefsElement, any>('defs')
|
64
|
+
.data([i])
|
65
|
+
.join('defs')
|
66
|
+
|
67
|
+
const graphicGSelection = d3.select(g[i])
|
68
|
+
.selectAll<SVGGElement, any>('g')
|
69
|
+
.data([i])
|
70
|
+
.join('g')
|
71
|
+
.classed(graphicClassName, true)
|
72
|
+
})
|
73
|
+
},
|
74
|
+
update => update,
|
75
|
+
exit => exit.remove()
|
76
|
+
)
|
77
|
+
})
|
78
|
+
},
|
79
|
+
update => update,
|
80
|
+
exit => exit.remove()
|
81
|
+
)
|
82
|
+
}),
|
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
|
+
shareReplay(1)
|
99
|
+
)
|
100
|
+
|
101
|
+
// combineLatest({
|
102
|
+
// seriesSelection: seriesSelection$,
|
103
|
+
// gridContainer: gridContainer$
|
104
|
+
// }).pipe(
|
105
|
+
// switchMap(async d => d)
|
106
|
+
// ).subscribe(data => {
|
107
|
+
// data.seriesSelection
|
108
|
+
// .transition()
|
109
|
+
// .attr('transform', (d, i) => {
|
110
|
+
// const translate = data.gridContainer[i].translate
|
111
|
+
// const scale = data.gridContainer[i].scale
|
112
|
+
// return `translate(${translate[0]}, ${translate[1]}) scale(${scale[0]}, ${scale[1]})`
|
113
|
+
// })
|
114
|
+
// })
|
115
|
+
|
116
|
+
|
117
|
+
const axesSelection$ = combineLatest({
|
118
|
+
seriesSelection: seriesSelection$,
|
119
|
+
gridAxesTransform: gridAxesTransform$
|
120
|
+
}).pipe(
|
121
|
+
switchMap(async d => d),
|
122
|
+
map(data => {
|
123
|
+
return data.seriesSelection
|
124
|
+
.select<SVGGElement>(`g.${axesClassName}`)
|
125
|
+
.style('transform', data.gridAxesTransform.value)
|
126
|
+
}),
|
127
|
+
shareReplay(1)
|
128
|
+
)
|
129
|
+
const defsSelection$ = axesSelection$.pipe(
|
130
|
+
map(axesSelection => {
|
131
|
+
return axesSelection.select<SVGDefsElement>('defs')
|
132
|
+
}),
|
133
|
+
shareReplay(1)
|
134
|
+
)
|
135
|
+
const graphicGSelection$ = combineLatest({
|
136
|
+
axesSelection: axesSelection$,
|
137
|
+
gridGraphicTransform: gridGraphicTransform$
|
138
|
+
}).pipe(
|
139
|
+
switchMap(async d => d),
|
140
|
+
map(data => {
|
141
|
+
const graphicGSelection = data.axesSelection
|
142
|
+
.select<SVGGElement>(`g.${graphicClassName}`)
|
143
|
+
graphicGSelection
|
144
|
+
.transition()
|
145
|
+
.duration(50)
|
146
|
+
.style('transform', data.gridGraphicTransform.value)
|
147
|
+
return graphicGSelection
|
148
|
+
}),
|
149
|
+
shareReplay(1)
|
150
|
+
)
|
151
|
+
|
152
|
+
return {
|
153
|
+
seriesSelection$,
|
154
|
+
axesSelection$,
|
155
|
+
defsSelection$,
|
156
|
+
graphicGSelection$
|
157
|
+
}
|
158
|
+
}
|
10
159
|
|
11
160
|
// 由事件取得group data的function
|
12
|
-
export
|
161
|
+
export const gridGroupPositionFnObservable = ({ fullDataFormatter$, gridAxesSize$, computedData$, fullChartParams$ }: {
|
13
162
|
fullDataFormatter$: Observable<DataFormatterGrid>
|
14
163
|
gridAxesSize$: Observable<{
|
15
164
|
width: number;
|
@@ -18,7 +167,7 @@ export function gridGroupPositionFnObservable ({ fullDataFormatter$, gridAxesSiz
|
|
18
167
|
computedData$: Observable<ComputedDataGrid>
|
19
168
|
// GroupDataMap$: Observable<Map<string, ComputedDatumGrid[]>>
|
20
169
|
fullChartParams$: Observable<ChartParams>
|
21
|
-
}): Observable<(event: any) => { groupIndex: number; groupLabel: string }> {
|
170
|
+
}): Observable<(event: any) => { groupIndex: number; groupLabel: string }> => {
|
22
171
|
const destroy$ = new Subject()
|
23
172
|
|
24
173
|
// 顯示範圍內的group labels
|
@@ -33,18 +182,18 @@ export function gridGroupPositionFnObservable ({ fullDataFormatter$, gridAxesSiz
|
|
33
182
|
).subscribe(data => {
|
34
183
|
const groupMin = 0
|
35
184
|
const groupMax = data.computedData[0] ? data.computedData[0].length - 1 : 0
|
36
|
-
const groupScaleDomainMin = data.dataFormatter.groupAxis.scaleDomain[0] === 'auto'
|
37
|
-
? groupMin - data.dataFormatter.groupAxis.scalePadding
|
38
|
-
: data.dataFormatter.groupAxis.scaleDomain[0] as number - data.dataFormatter.groupAxis.scalePadding
|
39
|
-
const groupScaleDomainMax = data.dataFormatter.groupAxis.scaleDomain[1] === 'auto'
|
40
|
-
? groupMax + data.dataFormatter.groupAxis.scalePadding
|
41
|
-
: data.dataFormatter.groupAxis.scaleDomain[1] as number + data.dataFormatter.groupAxis.scalePadding
|
185
|
+
const groupScaleDomainMin = data.dataFormatter.grid.groupAxis.scaleDomain[0] === 'auto'
|
186
|
+
? groupMin - data.dataFormatter.grid.groupAxis.scalePadding
|
187
|
+
: data.dataFormatter.grid.groupAxis.scaleDomain[0] as number - data.dataFormatter.grid.groupAxis.scalePadding
|
188
|
+
const groupScaleDomainMax = data.dataFormatter.grid.groupAxis.scaleDomain[1] === 'auto'
|
189
|
+
? groupMax + data.dataFormatter.grid.groupAxis.scalePadding
|
190
|
+
: data.dataFormatter.grid.groupAxis.scaleDomain[1] as number + data.dataFormatter.grid.groupAxis.scalePadding
|
42
191
|
|
43
192
|
// const groupingAmount = data.computedData[0]
|
44
193
|
// ? data.computedData[0].length
|
45
194
|
// : 0
|
46
195
|
|
47
|
-
let _labels = data.dataFormatter.grid.
|
196
|
+
let _labels = data.dataFormatter.grid.gridData.seriesDirection === 'row'
|
48
197
|
? (data.computedData[0] ?? []).map(d => d.groupLabel)
|
49
198
|
: data.computedData.map(d => d[0].groupLabel)
|
50
199
|
|
@@ -75,8 +224,8 @@ export function gridGroupPositionFnObservable ({ fullDataFormatter$, gridAxesSiz
|
|
75
224
|
switchMap(async (d) => d),
|
76
225
|
).subscribe(data => {
|
77
226
|
|
78
|
-
const reverse = data.dataFormatter.valueAxis.position === 'right'
|
79
|
-
|| data.dataFormatter.valueAxis.position === 'bottom'
|
227
|
+
const reverse = data.dataFormatter.grid.valueAxis.position === 'right'
|
228
|
+
|| data.dataFormatter.grid.valueAxis.position === 'bottom'
|
80
229
|
? true : false
|
81
230
|
|
82
231
|
// 比例尺座標對應非連續資料索引
|
@@ -88,8 +237,8 @@ export function gridGroupPositionFnObservable ({ fullDataFormatter$, gridAxesSiz
|
|
88
237
|
|
89
238
|
// 依比例尺位置計算座標
|
90
239
|
const axisValuePredicate = (event: any) => {
|
91
|
-
return data.dataFormatter.groupAxis.position === 'bottom'
|
92
|
-
|| data.dataFormatter.groupAxis.position === 'top'
|
240
|
+
return data.dataFormatter.grid.groupAxis.position === 'bottom'
|
241
|
+
|| data.dataFormatter.grid.groupAxis.position === 'top'
|
93
242
|
? event.offsetX - data.fullChartParams.padding.left
|
94
243
|
: event.offsetY - data.fullChartParams.padding.top
|
95
244
|
}
|
package/src/grid/index.ts
CHANGED
@@ -10,4 +10,4 @@ export { GroupAxis } from './plugins/GroupAxis'
|
|
10
10
|
export { ValueAxis } from './plugins/ValueAxis'
|
11
11
|
export { ValueStackAxis } from './plugins/ValueStackAxis'
|
12
12
|
export { ScalingArea } from './plugins/ScalingArea'
|
13
|
-
export {
|
13
|
+
export { GroupAux } from './plugins/GroupAux'
|
@@ -15,6 +15,7 @@ export const BarStack = defineGridPlugin(pluginName, DEFAULT_BAR_STACK_PARAMS)((
|
|
15
15
|
selection,
|
16
16
|
computedData$: observer.computedData$,
|
17
17
|
visibleComputedData$: observer.visibleComputedData$,
|
18
|
+
existedSeriesLabels$: observer.existedSeriesLabels$,
|
18
19
|
SeriesDataMap$: observer.SeriesDataMap$,
|
19
20
|
GroupDataMap$: observer.GroupDataMap$,
|
20
21
|
fullParams$: observer.fullParams$,
|
@@ -22,8 +23,11 @@ export const BarStack = defineGridPlugin(pluginName, DEFAULT_BAR_STACK_PARAMS)((
|
|
22
23
|
fullChartParams$: observer.fullChartParams$,
|
23
24
|
gridAxesTransform$: observer.gridAxesTransform$,
|
24
25
|
gridGraphicTransform$: observer.gridGraphicTransform$,
|
26
|
+
gridGraphicReverseScale$: observer.gridGraphicReverseScale$,
|
25
27
|
gridAxesSize$: observer.gridAxesSize$,
|
26
28
|
gridHighlight$: observer.gridHighlight$,
|
29
|
+
gridContainer$: observer.gridContainer$,
|
30
|
+
isSeriesPositionSeprate$: observer.isSeriesPositionSeprate$,
|
27
31
|
event$: subject.event$,
|
28
32
|
})
|
29
33
|
|
package/src/grid/plugins/Bars.ts
CHANGED
@@ -15,14 +15,18 @@ export const Bars = defineGridPlugin(pluginName, DEFAULT_BARS_PARAMS)(({ selecti
|
|
15
15
|
selection,
|
16
16
|
computedData$: observer.computedData$,
|
17
17
|
visibleComputedData$: observer.visibleComputedData$,
|
18
|
+
existedSeriesLabels$: observer.existedSeriesLabels$,
|
18
19
|
SeriesDataMap$: observer.SeriesDataMap$,
|
19
20
|
GroupDataMap$: observer.GroupDataMap$,
|
20
21
|
fullParams$: observer.fullParams$,
|
21
22
|
fullChartParams$: observer.fullChartParams$,
|
22
23
|
gridAxesTransform$: observer.gridAxesTransform$,
|
23
24
|
gridGraphicTransform$: observer.gridGraphicTransform$,
|
25
|
+
gridGraphicReverseScale$: observer.gridGraphicReverseScale$,
|
24
26
|
gridAxesSize$: observer.gridAxesSize$,
|
25
27
|
gridHighlight$: observer.gridHighlight$,
|
28
|
+
gridContainer$: observer.gridContainer$,
|
29
|
+
isSeriesPositionSeprate$: observer.isSeriesPositionSeprate$,
|
26
30
|
event$: subject.event$,
|
27
31
|
})
|
28
32
|
|
@@ -13,6 +13,8 @@ export const BarsTriangle = defineGridPlugin(pluginName, DEFAULT_BARS_TRIANGLE_P
|
|
13
13
|
const unsubscribeBaseBars = createBaseBarsTriangle(pluginName, {
|
14
14
|
selection,
|
15
15
|
computedData$: observer.computedData$,
|
16
|
+
visibleComputedData$: observer.visibleComputedData$,
|
17
|
+
existedSeriesLabels$: observer.existedSeriesLabels$,
|
16
18
|
SeriesDataMap$: observer.SeriesDataMap$,
|
17
19
|
GroupDataMap$: observer.GroupDataMap$,
|
18
20
|
fullParams$: observer.fullParams$,
|
@@ -21,6 +23,8 @@ export const BarsTriangle = defineGridPlugin(pluginName, DEFAULT_BARS_TRIANGLE_P
|
|
21
23
|
gridGraphicTransform$: observer.gridGraphicTransform$,
|
22
24
|
gridAxesSize$: observer.gridAxesSize$,
|
23
25
|
gridHighlight$: observer.gridHighlight$,
|
26
|
+
gridContainer$: observer.gridContainer$,
|
27
|
+
isSeriesPositionSeprate$: observer.isSeriesPositionSeprate$,
|
24
28
|
event$: subject.event$,
|
25
29
|
})
|
26
30
|
|
package/src/grid/plugins/Dots.ts
CHANGED
@@ -15,14 +15,17 @@ export const Dots = defineGridPlugin(pluginName, DEFAULT_DOTS_PARAMS)(({ selecti
|
|
15
15
|
selection,
|
16
16
|
computedData$: observer.computedData$,
|
17
17
|
visibleComputedData$: observer.visibleComputedData$,
|
18
|
+
existedSeriesLabels$: observer.existedSeriesLabels$,
|
18
19
|
SeriesDataMap$: observer.SeriesDataMap$,
|
19
20
|
GroupDataMap$: observer.GroupDataMap$,
|
20
21
|
fullParams$: observer.fullParams$,
|
21
22
|
fullChartParams$: observer.fullChartParams$,
|
22
23
|
gridAxesTransform$: observer.gridAxesTransform$,
|
23
24
|
gridGraphicTransform$: observer.gridGraphicTransform$,
|
25
|
+
gridGraphicReverseScale$: observer.gridGraphicReverseScale$,
|
24
26
|
gridAxesSize$: observer.gridAxesSize$,
|
25
27
|
gridHighlight$: observer.gridHighlight$,
|
28
|
+
gridContainer$: observer.gridContainer$,
|
26
29
|
event$: subject.event$,
|
27
30
|
})
|
28
31
|
|
@@ -24,7 +24,7 @@ import { getColor, getClassName, getUniID } from '../../utils/orbchartsUtils'
|
|
24
24
|
import { d3EventObservable } from '../../utils/observables'
|
25
25
|
import { gridGroupPositionFnObservable } from '../gridObservables'
|
26
26
|
import { createAxisPointScale } from '@orbcharts/core'
|
27
|
-
import type {
|
27
|
+
import type { GroupAuxParams } from '../types'
|
28
28
|
|
29
29
|
interface LineDatum {
|
30
30
|
id: string
|
@@ -41,14 +41,14 @@ interface LabelDatum {
|
|
41
41
|
y: number
|
42
42
|
}
|
43
43
|
|
44
|
-
const pluginName = '
|
44
|
+
const pluginName = 'GroupAux'
|
45
45
|
const labelClassName = getClassName(pluginName, 'label-box')
|
46
46
|
|
47
47
|
function createLineData ({ groupLabel, axisX, axisHeight, fullParams }: {
|
48
48
|
groupLabel: string
|
49
49
|
axisX: number
|
50
50
|
axisHeight: number
|
51
|
-
fullParams:
|
51
|
+
fullParams: GroupAuxParams
|
52
52
|
}): LineDatum[] {
|
53
53
|
return fullParams.showLine && groupLabel
|
54
54
|
? [{
|
@@ -65,7 +65,7 @@ function renderLine ({ selection, pluginName, lineData, fullParams, fullChartPar
|
|
65
65
|
selection: d3.Selection<any, unknown, any, unknown>
|
66
66
|
pluginName: string
|
67
67
|
lineData: LineDatum[]
|
68
|
-
fullParams:
|
68
|
+
fullParams: GroupAuxParams
|
69
69
|
fullChartParams: ChartParams
|
70
70
|
}) {
|
71
71
|
const gClassName = getClassName(pluginName, 'auxline')
|
@@ -114,7 +114,7 @@ function removeLine (selection: d3.Selection<any, unknown, any, unknown>) {
|
|
114
114
|
function createLabelData ({ groupLabel, axisX, fullParams }: {
|
115
115
|
groupLabel: string
|
116
116
|
axisX: number
|
117
|
-
fullParams:
|
117
|
+
fullParams: GroupAuxParams
|
118
118
|
}) {
|
119
119
|
return fullParams.showLabel && groupLabel
|
120
120
|
? [{
|
@@ -126,12 +126,12 @@ function createLabelData ({ groupLabel, axisX, fullParams }: {
|
|
126
126
|
: []
|
127
127
|
}
|
128
128
|
|
129
|
-
function renderLabel ({ selection, labelData, fullParams, fullChartParams,
|
129
|
+
function renderLabel ({ selection, labelData, fullParams, fullChartParams, gridAxesReverseTransformValue }: {
|
130
130
|
selection: d3.Selection<any, unknown, any, unknown>
|
131
131
|
labelData: LabelDatum[]
|
132
|
-
fullParams:
|
132
|
+
fullParams: GroupAuxParams
|
133
133
|
fullChartParams: ChartParams
|
134
|
-
|
134
|
+
gridAxesReverseTransformValue: string
|
135
135
|
}) {
|
136
136
|
const rectHeight = fullChartParams.styles.textSize + 4
|
137
137
|
|
@@ -176,7 +176,7 @@ function renderLabel ({ selection, labelData, fullParams, fullChartParams, gridA
|
|
176
176
|
// .style('pointer-events', 'none')
|
177
177
|
const rect = rectUpdate.merge(rectEnter)
|
178
178
|
.attr('width', d => `${rectWidth}px`)
|
179
|
-
.style('transform',
|
179
|
+
.style('transform', gridAxesReverseTransformValue)
|
180
180
|
rectUpdate.exit().remove()
|
181
181
|
|
182
182
|
const textUpdate = d3.select(n[i])
|
@@ -190,7 +190,7 @@ function renderLabel ({ selection, labelData, fullParams, fullChartParams, gridA
|
|
190
190
|
// .style('pointer-events', 'none')
|
191
191
|
const text = textUpdate.merge(textEnter)
|
192
192
|
.text(d => d.text)
|
193
|
-
.style('transform',
|
193
|
+
.style('transform', gridAxesReverseTransformValue)
|
194
194
|
.attr('fill', d => getColor(fullParams.labelTextColorType, fullChartParams))
|
195
195
|
.attr('font-size', fullChartParams.styles.textSize)
|
196
196
|
.attr('x', rectX + 6)
|
@@ -208,7 +208,7 @@ function removeLabel (selection: d3.Selection<any, unknown, any, unknown>) {
|
|
208
208
|
gUpdate.exit().remove()
|
209
209
|
}
|
210
210
|
|
211
|
-
export const
|
211
|
+
export const GroupAux = defineGridPlugin(pluginName, DEFAULT_GROUP_AREA_PARAMS)(({ selection, rootSelection, name, subject, observer }) => {
|
212
212
|
const destroy$ = new Subject()
|
213
213
|
|
214
214
|
const rootRectSelection: d3.Selection<SVGRectElement, any, any, any> = rootSelection
|
@@ -283,7 +283,7 @@ export const GroupArea = defineGridPlugin(pluginName, DEFAULT_GROUP_AREA_PARAMS)
|
|
283
283
|
// subscriber.next(transformData.value)
|
284
284
|
// })
|
285
285
|
// })
|
286
|
-
// const
|
286
|
+
// const reverseTransform$: Observable<TransformData> = observer.gridAxesTransform$.pipe(
|
287
287
|
// takeUntil(destroy$),
|
288
288
|
// map(d => {
|
289
289
|
// const translate: [number, number] = [d.translate[0] * -1, d.translate[1] * -1]
|
@@ -303,12 +303,12 @@ export const GroupArea = defineGridPlugin(pluginName, DEFAULT_GROUP_AREA_PARAMS)
|
|
303
303
|
// )
|
304
304
|
// const contentTransform$ = combineLatest({
|
305
305
|
// fullParams: observer.fullParams$,
|
306
|
-
//
|
306
|
+
// reverseTransform: reverseTransform$
|
307
307
|
// }).pipe(
|
308
308
|
// takeUntil(destroy$),
|
309
309
|
// switchMap(async data => {
|
310
310
|
// const translate = [0, 0]
|
311
|
-
// return `translate(${translate[0]}px, ${translate[1]}px) rotate(${data.
|
311
|
+
// return `translate(${translate[0]}px, ${translate[1]}px) rotate(${data.reverseTransform.rotate}deg) rotateX(${data.reverseTransform.rotateX}deg) rotateY(${data.reverseTransform.rotateY}deg)`
|
312
312
|
// }),
|
313
313
|
// distinctUntilChanged()
|
314
314
|
// )
|
@@ -324,18 +324,18 @@ export const GroupArea = defineGridPlugin(pluginName, DEFAULT_GROUP_AREA_PARAMS)
|
|
324
324
|
).subscribe(data => {
|
325
325
|
const groupMin = 0
|
326
326
|
const groupMax = data.computedData[0] ? data.computedData[0].length - 1 : 0
|
327
|
-
const groupScaleDomainMin = data.fullDataFormatter.groupAxis.scaleDomain[0] === 'auto'
|
328
|
-
? groupMin - data.fullDataFormatter.groupAxis.scalePadding
|
329
|
-
: data.fullDataFormatter.groupAxis.scaleDomain[0] as number - data.fullDataFormatter.groupAxis.scalePadding
|
330
|
-
const groupScaleDomainMax = data.fullDataFormatter.groupAxis.scaleDomain[1] === 'auto'
|
331
|
-
? groupMax + data.fullDataFormatter.groupAxis.scalePadding
|
332
|
-
: data.fullDataFormatter.groupAxis.scaleDomain[1] as number + data.fullDataFormatter.groupAxis.scalePadding
|
327
|
+
const groupScaleDomainMin = data.fullDataFormatter.grid.groupAxis.scaleDomain[0] === 'auto'
|
328
|
+
? groupMin - data.fullDataFormatter.grid.groupAxis.scalePadding
|
329
|
+
: data.fullDataFormatter.grid.groupAxis.scaleDomain[0] as number - data.fullDataFormatter.grid.groupAxis.scalePadding
|
330
|
+
const groupScaleDomainMax = data.fullDataFormatter.grid.groupAxis.scaleDomain[1] === 'auto'
|
331
|
+
? groupMax + data.fullDataFormatter.grid.groupAxis.scalePadding
|
332
|
+
: data.fullDataFormatter.grid.groupAxis.scaleDomain[1] as number + data.fullDataFormatter.grid.groupAxis.scalePadding
|
333
333
|
|
334
334
|
const groupingLength = data.computedData[0]
|
335
335
|
? data.computedData[0].length
|
336
336
|
: 0
|
337
337
|
|
338
|
-
let _labels = data.fullDataFormatter.grid.
|
338
|
+
let _labels = data.fullDataFormatter.grid.gridData.seriesDirection === 'row'
|
339
339
|
// ? data.fullDataFormatter.grid.columnLabels
|
340
340
|
// : data.fullDataFormatter.grid.rowLabels
|
341
341
|
? (data.computedData[0] ?? []).map(d => d.groupLabel)
|
@@ -352,7 +352,7 @@ export const GroupArea = defineGridPlugin(pluginName, DEFAULT_GROUP_AREA_PARAMS)
|
|
352
352
|
})
|
353
353
|
|
354
354
|
|
355
|
-
const padding = data.fullDataFormatter.groupAxis.scalePadding
|
355
|
+
const padding = data.fullDataFormatter.grid.groupAxis.scalePadding
|
356
356
|
|
357
357
|
const groupScale = createAxisPointScale({
|
358
358
|
axisLabels,
|
@@ -496,7 +496,7 @@ export const GroupArea = defineGridPlugin(pluginName, DEFAULT_GROUP_AREA_PARAMS)
|
|
496
496
|
fullParams: observer.fullParams$,
|
497
497
|
fullChartParams: observer.fullChartParams$,
|
498
498
|
highlightTarget: highlightTarget$,
|
499
|
-
|
499
|
+
gridAxesReverseTransform: observer.gridAxesReverseTransform$,
|
500
500
|
GroupDataMap: observer.GroupDataMap$,
|
501
501
|
gridGroupPositionFn: gridGroupPositionFn$,
|
502
502
|
}).pipe(
|
@@ -535,7 +535,7 @@ export const GroupArea = defineGridPlugin(pluginName, DEFAULT_GROUP_AREA_PARAMS)
|
|
535
535
|
labelData,
|
536
536
|
fullParams: data.fullParams,
|
537
537
|
fullChartParams: data.fullChartParams,
|
538
|
-
|
538
|
+
gridAxesReverseTransformValue: data.gridAxesReverseTransform.value
|
539
539
|
})
|
540
540
|
|
541
541
|
// label的事件
|