@orbcharts/plugins-basic 3.0.0-alpha.34 → 3.0.0-alpha.35
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/orbcharts-plugins-basic.es.js +10198 -9511
- 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/BaseLines.ts +180 -50
- package/src/base/BaseValueAxis.ts +475 -0
- package/src/grid/defaults.ts +3 -3
- package/src/grid/gridObservables.ts +147 -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,148 @@
|
|
1
|
-
import
|
1
|
+
import * as d3 from 'd3'
|
2
|
+
import { Observable, Subject, of, takeUntil, filter, map, switchMap, combineLatest, merge, distinctUntilChanged } from 'rxjs'
|
2
3
|
import type {
|
3
4
|
ChartParams,
|
4
5
|
HighlightTarget,
|
5
6
|
DataFormatterGrid,
|
6
7
|
ComputedDataGrid,
|
7
8
|
ComputedDatumGrid,
|
9
|
+
TransformData,
|
10
|
+
ContainerPosition,
|
8
11
|
Layout } from '@orbcharts/core'
|
9
12
|
import { createAxisQuantizeScale } from '@orbcharts/core'
|
13
|
+
import { getClassName, getUniID } from '../utils/orbchartsUtils'
|
14
|
+
|
15
|
+
export const gridSelectionsObservable = ({ selection, pluginName, clipPathID, existedSeriesLabels$, gridContainer$, gridAxesTransform$, gridGraphicTransform$ }: {
|
16
|
+
selection: d3.Selection<any, unknown, any, unknown>
|
17
|
+
pluginName: string
|
18
|
+
clipPathID: string
|
19
|
+
// computedData$: Observable<ComputedDataGrid>
|
20
|
+
existedSeriesLabels$: Observable<string[]>
|
21
|
+
gridContainer$: Observable<ContainerPosition[]>
|
22
|
+
gridAxesTransform$: Observable<TransformData>
|
23
|
+
gridGraphicTransform$: Observable<TransformData>
|
24
|
+
}) => {
|
25
|
+
const seriesClassName = getClassName(pluginName, 'series')
|
26
|
+
const axesClassName = getClassName(pluginName, 'axes')
|
27
|
+
const graphicClassName = getClassName(pluginName, 'graphic')
|
28
|
+
|
29
|
+
const seriesSelection$ = existedSeriesLabels$.pipe(
|
30
|
+
map((existedSeriesLabels, i) => {
|
31
|
+
return selection
|
32
|
+
.selectAll<SVGGElement, string>(`g.${seriesClassName}`)
|
33
|
+
.data(existedSeriesLabels, d => d)
|
34
|
+
.join(
|
35
|
+
enter => {
|
36
|
+
return enter
|
37
|
+
.append('g')
|
38
|
+
.classed(seriesClassName, true)
|
39
|
+
.each((d, i, g) => {
|
40
|
+
const axesSelection = d3.select(g[i])
|
41
|
+
.selectAll<SVGGElement, ComputedDatumGrid[]>(`g.${axesClassName}`)
|
42
|
+
.data([i])
|
43
|
+
.join(
|
44
|
+
enter => {
|
45
|
+
return enter
|
46
|
+
.append('g')
|
47
|
+
.classed(axesClassName, true)
|
48
|
+
.attr('clip-path', `url(#${clipPathID})`)
|
49
|
+
.each((d, i, g) => {
|
50
|
+
const defsSelection = d3.select(g[i])
|
51
|
+
.selectAll<SVGDefsElement, any>('defs')
|
52
|
+
.data([i])
|
53
|
+
.join('defs')
|
54
|
+
|
55
|
+
const graphicGSelection = d3.select(g[i])
|
56
|
+
.selectAll<SVGGElement, any>('g')
|
57
|
+
.data([i])
|
58
|
+
.join('g')
|
59
|
+
.classed(graphicClassName, true)
|
60
|
+
})
|
61
|
+
},
|
62
|
+
update => update,
|
63
|
+
exit => exit.remove()
|
64
|
+
)
|
65
|
+
})
|
66
|
+
},
|
67
|
+
update => update,
|
68
|
+
exit => exit.remove()
|
69
|
+
)
|
70
|
+
}),
|
71
|
+
switchMap(selection => combineLatest({
|
72
|
+
seriesSelection: of(selection),
|
73
|
+
gridContainer: gridContainer$
|
74
|
+
})),
|
75
|
+
map(data => {
|
76
|
+
data.seriesSelection
|
77
|
+
.transition()
|
78
|
+
.attr('transform', (d, i) => {
|
79
|
+
const gridContainer = data.gridContainer[i] ?? data.gridContainer[0]
|
80
|
+
const translate = gridContainer.translate
|
81
|
+
const scale = gridContainer.scale
|
82
|
+
return `translate(${translate[0]}, ${translate[1]}) scale(${scale[0]}, ${scale[1]})`
|
83
|
+
})
|
84
|
+
return data.seriesSelection
|
85
|
+
})
|
86
|
+
)
|
87
|
+
|
88
|
+
// combineLatest({
|
89
|
+
// seriesSelection: seriesSelection$,
|
90
|
+
// gridContainer: gridContainer$
|
91
|
+
// }).pipe(
|
92
|
+
// switchMap(async d => d)
|
93
|
+
// ).subscribe(data => {
|
94
|
+
// data.seriesSelection
|
95
|
+
// .transition()
|
96
|
+
// .attr('transform', (d, i) => {
|
97
|
+
// const translate = data.gridContainer[i].translate
|
98
|
+
// const scale = data.gridContainer[i].scale
|
99
|
+
// return `translate(${translate[0]}, ${translate[1]}) scale(${scale[0]}, ${scale[1]})`
|
100
|
+
// })
|
101
|
+
// })
|
102
|
+
|
103
|
+
|
104
|
+
const axesSelection$ = combineLatest({
|
105
|
+
seriesSelection: seriesSelection$,
|
106
|
+
gridAxesTransform: gridAxesTransform$
|
107
|
+
}).pipe(
|
108
|
+
switchMap(async d => d),
|
109
|
+
map(data => {
|
110
|
+
return data.seriesSelection
|
111
|
+
.select<SVGGElement>(`g.${axesClassName}`)
|
112
|
+
.style('transform', data.gridAxesTransform.value)
|
113
|
+
})
|
114
|
+
)
|
115
|
+
const defsSelection$ = axesSelection$.pipe(
|
116
|
+
map(axesSelection => {
|
117
|
+
return axesSelection.select<SVGDefsElement>('defs')
|
118
|
+
})
|
119
|
+
)
|
120
|
+
const graphicGSelection$ = combineLatest({
|
121
|
+
axesSelection: axesSelection$,
|
122
|
+
gridGraphicTransform: gridGraphicTransform$
|
123
|
+
}).pipe(
|
124
|
+
switchMap(async d => d),
|
125
|
+
map(data => {
|
126
|
+
const graphicGSelection = data.axesSelection
|
127
|
+
.select<SVGGElement>(`g.${graphicClassName}`)
|
128
|
+
graphicGSelection
|
129
|
+
.transition()
|
130
|
+
.duration(50)
|
131
|
+
.style('transform', data.gridGraphicTransform.value)
|
132
|
+
return graphicGSelection
|
133
|
+
})
|
134
|
+
)
|
135
|
+
|
136
|
+
return {
|
137
|
+
seriesSelection$,
|
138
|
+
axesSelection$,
|
139
|
+
defsSelection$,
|
140
|
+
graphicGSelection$
|
141
|
+
}
|
142
|
+
}
|
10
143
|
|
11
144
|
// 由事件取得group data的function
|
12
|
-
export
|
145
|
+
export const gridGroupPositionFnObservable = ({ fullDataFormatter$, gridAxesSize$, computedData$, fullChartParams$ }: {
|
13
146
|
fullDataFormatter$: Observable<DataFormatterGrid>
|
14
147
|
gridAxesSize$: Observable<{
|
15
148
|
width: number;
|
@@ -18,7 +151,7 @@ export function gridGroupPositionFnObservable ({ fullDataFormatter$, gridAxesSiz
|
|
18
151
|
computedData$: Observable<ComputedDataGrid>
|
19
152
|
// GroupDataMap$: Observable<Map<string, ComputedDatumGrid[]>>
|
20
153
|
fullChartParams$: Observable<ChartParams>
|
21
|
-
}): Observable<(event: any) => { groupIndex: number; groupLabel: string }> {
|
154
|
+
}): Observable<(event: any) => { groupIndex: number; groupLabel: string }> => {
|
22
155
|
const destroy$ = new Subject()
|
23
156
|
|
24
157
|
// 顯示範圍內的group labels
|
@@ -33,18 +166,18 @@ export function gridGroupPositionFnObservable ({ fullDataFormatter$, gridAxesSiz
|
|
33
166
|
).subscribe(data => {
|
34
167
|
const groupMin = 0
|
35
168
|
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
|
169
|
+
const groupScaleDomainMin = data.dataFormatter.grid.groupAxis.scaleDomain[0] === 'auto'
|
170
|
+
? groupMin - data.dataFormatter.grid.groupAxis.scalePadding
|
171
|
+
: data.dataFormatter.grid.groupAxis.scaleDomain[0] as number - data.dataFormatter.grid.groupAxis.scalePadding
|
172
|
+
const groupScaleDomainMax = data.dataFormatter.grid.groupAxis.scaleDomain[1] === 'auto'
|
173
|
+
? groupMax + data.dataFormatter.grid.groupAxis.scalePadding
|
174
|
+
: data.dataFormatter.grid.groupAxis.scaleDomain[1] as number + data.dataFormatter.grid.groupAxis.scalePadding
|
42
175
|
|
43
176
|
// const groupingAmount = data.computedData[0]
|
44
177
|
// ? data.computedData[0].length
|
45
178
|
// : 0
|
46
179
|
|
47
|
-
let _labels = data.dataFormatter.grid.
|
180
|
+
let _labels = data.dataFormatter.grid.gridData.seriesDirection === 'row'
|
48
181
|
? (data.computedData[0] ?? []).map(d => d.groupLabel)
|
49
182
|
: data.computedData.map(d => d[0].groupLabel)
|
50
183
|
|
@@ -75,8 +208,8 @@ export function gridGroupPositionFnObservable ({ fullDataFormatter$, gridAxesSiz
|
|
75
208
|
switchMap(async (d) => d),
|
76
209
|
).subscribe(data => {
|
77
210
|
|
78
|
-
const reverse = data.dataFormatter.valueAxis.position === 'right'
|
79
|
-
|| data.dataFormatter.valueAxis.position === 'bottom'
|
211
|
+
const reverse = data.dataFormatter.grid.valueAxis.position === 'right'
|
212
|
+
|| data.dataFormatter.grid.valueAxis.position === 'bottom'
|
80
213
|
? true : false
|
81
214
|
|
82
215
|
// 比例尺座標對應非連續資料索引
|
@@ -88,8 +221,8 @@ export function gridGroupPositionFnObservable ({ fullDataFormatter$, gridAxesSiz
|
|
88
221
|
|
89
222
|
// 依比例尺位置計算座標
|
90
223
|
const axisValuePredicate = (event: any) => {
|
91
|
-
return data.dataFormatter.groupAxis.position === 'bottom'
|
92
|
-
|| data.dataFormatter.groupAxis.position === 'top'
|
224
|
+
return data.dataFormatter.grid.groupAxis.position === 'bottom'
|
225
|
+
|| data.dataFormatter.grid.groupAxis.position === 'top'
|
93
226
|
? event.offsetX - data.fullChartParams.padding.left
|
94
227
|
: event.offsetY - data.fullChartParams.padding.top
|
95
228
|
}
|
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的事件
|