@orbcharts/plugins-basic 3.0.0-alpha.44 → 3.0.0-alpha.45
Sign up to get free protection for your applications and to get access to all the features.
- package/LICENSE +200 -200
- 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/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 +7696 -7529
- package/dist/orbcharts-plugins-basic.umd.js +8 -8
- package/dist/src/index.d.ts +1 -5
- package/package.json +42 -42
- package/src/base/BaseBarStack.ts +778 -881
- package/src/base/BaseBars.ts +764 -750
- package/src/base/BaseBarsTriangle.ts +672 -659
- package/src/base/BaseDots.ts +502 -639
- package/src/base/BaseGroupAxis.ts +496 -496
- package/src/base/BaseLegend.ts +641 -641
- package/src/base/BaseLineAreas.ts +625 -621
- package/src/base/BaseLines.ts +699 -692
- package/src/base/BaseValueAxis.ts +478 -479
- package/src/base/types.ts +2 -2
- package/src/grid/defaults.ts +121 -121
- package/src/grid/gridObservables.ts +247 -263
- package/src/grid/index.ts +15 -15
- package/src/grid/plugins/BarStack.ts +50 -37
- package/src/grid/plugins/Bars.ts +51 -37
- package/src/grid/plugins/BarsDiverging.ts +41 -39
- package/src/grid/plugins/BarsTriangle.ts +50 -34
- package/src/grid/plugins/Dots.ts +37 -35
- package/src/grid/plugins/GridLegend.ts +59 -59
- package/src/grid/plugins/GroupAux.ts +645 -646
- package/src/grid/plugins/GroupAxis.ts +42 -30
- package/src/grid/plugins/LineAreas.ts +39 -36
- package/src/grid/plugins/Lines.ts +38 -35
- package/src/grid/plugins/ScalingArea.ts +173 -174
- package/src/grid/plugins/ValueAxis.ts +43 -31
- package/src/grid/plugins/ValueStackAxis.ts +79 -70
- package/src/grid/types.ts +120 -120
- package/src/index.ts +9 -9
- package/src/multiGrid/defaults.ts +147 -147
- package/src/multiGrid/index.ts +11 -11
- package/src/multiGrid/multiGridObservables.ts +42 -289
- package/src/multiGrid/plugins/MultiBarStack.ts +74 -60
- package/src/multiGrid/plugins/MultiBars.ts +73 -59
- package/src/multiGrid/plugins/MultiBarsTriangle.ts +73 -58
- package/src/multiGrid/plugins/MultiDots.ts +60 -58
- package/src/multiGrid/plugins/MultiGridLegend.ts +89 -89
- package/src/multiGrid/plugins/MultiGroupAxis.ts +65 -53
- package/src/multiGrid/plugins/MultiLineAreas.ts +62 -59
- package/src/multiGrid/plugins/MultiLines.ts +61 -58
- package/src/multiGrid/plugins/MultiValueAxis.ts +65 -53
- package/src/multiGrid/plugins/OverlappingValueAxes.ts +169 -164
- package/src/multiGrid/types.ts +67 -67
- package/src/noneData/defaults.ts +64 -61
- package/src/noneData/index.ts +3 -3
- package/src/noneData/plugins/Container.ts +10 -10
- package/src/noneData/plugins/Tooltip.ts +310 -310
- package/src/noneData/types.ts +26 -26
- package/src/series/defaults.ts +109 -99
- package/src/series/index.ts +6 -6
- package/src/series/plugins/Bubbles.ts +571 -551
- package/src/series/plugins/Pie.ts +548 -600
- package/src/series/plugins/PieEventTexts.ts +258 -194
- package/src/series/plugins/PieLabels.ts +335 -288
- package/src/series/plugins/SeriesLegend.ts +59 -59
- package/src/series/seriesObservables.ts +145 -0
- 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 +59 -59
- package/src/tree/plugins/TreeMap.ts +305 -305
- 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 +16 -13
- package/tsconfig.prod.json +13 -13
- package/vite.config.js +49 -49
- 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/BaseLegend.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
@@ -1,194 +1,258 @@
|
|
1
|
-
import * as d3 from 'd3'
|
2
|
-
import {
|
3
|
-
combineLatest,
|
4
|
-
switchMap,
|
5
|
-
first,
|
6
|
-
takeUntil,
|
7
|
-
map,
|
8
|
-
distinctUntilChanged,
|
9
|
-
|
10
|
-
|
11
|
-
import {
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
type
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
}
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
.
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
}
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
)
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
})
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
1
|
+
import * as d3 from 'd3'
|
2
|
+
import {
|
3
|
+
combineLatest,
|
4
|
+
switchMap,
|
5
|
+
first,
|
6
|
+
takeUntil,
|
7
|
+
map,
|
8
|
+
distinctUntilChanged,
|
9
|
+
Observable,
|
10
|
+
Subject } from 'rxjs'
|
11
|
+
import type { Subscription } from 'rxjs'
|
12
|
+
import {
|
13
|
+
defineSeriesPlugin} from '@orbcharts/core'
|
14
|
+
import type {
|
15
|
+
ComputedDatumSeries,
|
16
|
+
ChartParams,
|
17
|
+
SeriesContainerPosition,
|
18
|
+
EventName,
|
19
|
+
EventSeries } from '@orbcharts/core'
|
20
|
+
import type { PieEventTextsParams } from '../types'
|
21
|
+
import { DEFAULT_PIE_EVENT_TEXTS_PARAMS } from '../defaults'
|
22
|
+
import { getD3TransitionEase } from '../../utils/d3Utils'
|
23
|
+
import { getClassName } from '../../utils/orbchartsUtils'
|
24
|
+
import { seriesCenterSelectionObservable } from '../seriesObservables'
|
25
|
+
|
26
|
+
|
27
|
+
type TextDatum = {
|
28
|
+
text: string
|
29
|
+
attr: { [key:string]: any }
|
30
|
+
style: { [key:string]: any }
|
31
|
+
}
|
32
|
+
|
33
|
+
const pluginName = 'PieEventTexts'
|
34
|
+
const textClassName = getClassName(pluginName, 'text')
|
35
|
+
|
36
|
+
function renderText (
|
37
|
+
selection: d3.Selection<SVGGElement, unknown, any, any>,
|
38
|
+
data: Array<TextDatum>
|
39
|
+
): d3.Selection<SVGTextElement, TextDatum, SVGGElement, unknown> {
|
40
|
+
const textUpdate = selection
|
41
|
+
.selectAll<SVGTextElement, TextDatum>(`text.${textClassName}`)
|
42
|
+
.data(data)
|
43
|
+
const textEnter = textUpdate.enter()
|
44
|
+
.append('text')
|
45
|
+
.classed(textClassName, true)
|
46
|
+
const text = textUpdate.merge(textEnter)
|
47
|
+
text
|
48
|
+
.each((d, i, g) => {
|
49
|
+
const t = d3.select(g[i])
|
50
|
+
.text(d.text)
|
51
|
+
Object.keys(d.attr)
|
52
|
+
.forEach(key => {
|
53
|
+
t.attr(key, d.attr[key])
|
54
|
+
})
|
55
|
+
Object.keys(d.style)
|
56
|
+
.forEach(key => {
|
57
|
+
t.style(key, d.style[key])
|
58
|
+
})
|
59
|
+
})
|
60
|
+
|
61
|
+
textUpdate.exit().remove()
|
62
|
+
|
63
|
+
return text
|
64
|
+
}
|
65
|
+
|
66
|
+
function makeTextData ({ eventData, eventName, t, eventFn, textAttrs, textStyles }: {
|
67
|
+
eventData: EventSeries,
|
68
|
+
eventName: EventName,
|
69
|
+
t: number,
|
70
|
+
eventFn: (d: EventSeries, eventName: EventName, t: number) => string[]
|
71
|
+
textAttrs: Array<{ [key:string]: string | number }>
|
72
|
+
textStyles: Array<{ [key:string]: string | number }>
|
73
|
+
}): TextDatum[] {
|
74
|
+
const callbackText = eventFn(eventData, eventName, t)
|
75
|
+
return callbackText.map((d, i) => {
|
76
|
+
return {
|
77
|
+
text: d,
|
78
|
+
attr: textAttrs[i],
|
79
|
+
style: textStyles[i]
|
80
|
+
}
|
81
|
+
})
|
82
|
+
}
|
83
|
+
|
84
|
+
function createEachPieEventTexts (pluginName: string, context: {
|
85
|
+
containerSelection: d3.Selection<SVGGElement, any, any, unknown>
|
86
|
+
computedData$: Observable<ComputedDatumSeries[][]>
|
87
|
+
containerComputedLayoutData$: Observable<ComputedDatumSeries[]>
|
88
|
+
SeriesDataMap$: Observable<Map<string, ComputedDatumSeries[]>>
|
89
|
+
fullParams$: Observable<PieEventTextsParams>
|
90
|
+
fullChartParams$: Observable<ChartParams>
|
91
|
+
seriesHighlight$: Observable<ComputedDatumSeries[]>
|
92
|
+
seriesContainerPosition$: Observable<SeriesContainerPosition>
|
93
|
+
event$: Subject<EventSeries>
|
94
|
+
}) {
|
95
|
+
const destroy$ = new Subject()
|
96
|
+
|
97
|
+
// const graphicSelection: d3.Selection<SVGGElement, any, any, any> = selection.append('g')
|
98
|
+
let centerTextSelection: d3.Selection<SVGTextElement, TextDatum, SVGGElement, unknown> | undefined
|
99
|
+
let storeEventSubscription: Subscription | undefined
|
100
|
+
|
101
|
+
// context.layout$
|
102
|
+
// .pipe(
|
103
|
+
// first()
|
104
|
+
// )
|
105
|
+
// .subscribe(size => {
|
106
|
+
// selection
|
107
|
+
// .attr('transform', `translate(${size.width / 2}, ${size.height / 2})`)
|
108
|
+
// context.layout$
|
109
|
+
// .pipe(
|
110
|
+
// takeUntil(destroy$)
|
111
|
+
// )
|
112
|
+
// .subscribe(size => {
|
113
|
+
// selection
|
114
|
+
// .transition()
|
115
|
+
// .attr('transform', `translate(${size.width / 2}, ${size.height / 2})`)
|
116
|
+
// })
|
117
|
+
// })
|
118
|
+
|
119
|
+
const highlightTarget$ = context.fullChartParams$.pipe(
|
120
|
+
takeUntil(destroy$),
|
121
|
+
map(d => d.highlightTarget),
|
122
|
+
distinctUntilChanged()
|
123
|
+
)
|
124
|
+
|
125
|
+
combineLatest({
|
126
|
+
computedData: context.computedData$,
|
127
|
+
fullParams: context.fullParams$,
|
128
|
+
fullChartParams: context.fullChartParams$,
|
129
|
+
highlightTarget: highlightTarget$,
|
130
|
+
}).pipe(
|
131
|
+
takeUntil(destroy$),
|
132
|
+
switchMap(async (d) => d),
|
133
|
+
).subscribe(data => {
|
134
|
+
|
135
|
+
context.containerSelection
|
136
|
+
.transition('move')
|
137
|
+
.duration(data.fullChartParams.transitionDuration!)
|
138
|
+
// .ease(getD3TransitionEase(data.fullChartParams.transitionEase!))
|
139
|
+
.tween('move', (event, datum) => {
|
140
|
+
return (t) => {
|
141
|
+
const renderData = makeTextData({
|
142
|
+
eventData: {
|
143
|
+
type: 'series',
|
144
|
+
pluginName,
|
145
|
+
eventName: 'transitionMove',
|
146
|
+
event,
|
147
|
+
highlightTarget: data.highlightTarget,
|
148
|
+
data: data.computedData,
|
149
|
+
series: [],
|
150
|
+
seriesIndex: -1,
|
151
|
+
seriesLabel: '',
|
152
|
+
datum: null
|
153
|
+
},
|
154
|
+
eventName: 'transitionMove',
|
155
|
+
t,
|
156
|
+
eventFn: data.fullParams.eventFn!,
|
157
|
+
textAttrs: data.fullParams.textAttrs!,
|
158
|
+
textStyles: data.fullParams.textStyles!
|
159
|
+
})
|
160
|
+
centerTextSelection = renderText(context.containerSelection, renderData)
|
161
|
+
}
|
162
|
+
})
|
163
|
+
.on('end', (event, datum) => {
|
164
|
+
const renderData = makeTextData({
|
165
|
+
eventData: {
|
166
|
+
type: 'series',
|
167
|
+
pluginName,
|
168
|
+
eventName: 'transitionEnd',
|
169
|
+
event,
|
170
|
+
highlightTarget: data.highlightTarget,
|
171
|
+
data: data.computedData,
|
172
|
+
series: [],
|
173
|
+
seriesIndex: -1,
|
174
|
+
seriesLabel: '',
|
175
|
+
datum: null
|
176
|
+
},
|
177
|
+
eventName: 'transitionMove',
|
178
|
+
t: 1,
|
179
|
+
eventFn: data.fullParams.eventFn!,
|
180
|
+
textAttrs: data.fullParams.textAttrs!,
|
181
|
+
textStyles: data.fullParams.textStyles!
|
182
|
+
})
|
183
|
+
centerTextSelection = renderText(context.containerSelection, renderData)
|
184
|
+
|
185
|
+
if (storeEventSubscription) {
|
186
|
+
storeEventSubscription.unsubscribe()
|
187
|
+
}
|
188
|
+
storeEventSubscription = context.event$
|
189
|
+
.subscribe(eventData => {
|
190
|
+
const renderData = makeTextData({
|
191
|
+
eventData,
|
192
|
+
eventName: eventData.eventName,
|
193
|
+
t: 1,
|
194
|
+
eventFn: data.fullParams.eventFn!,
|
195
|
+
textAttrs: data.fullParams.textAttrs!,
|
196
|
+
textStyles: data.fullParams.textStyles!
|
197
|
+
})
|
198
|
+
centerTextSelection = renderText(context.containerSelection, renderData)
|
199
|
+
})
|
200
|
+
})
|
201
|
+
})
|
202
|
+
|
203
|
+
return () => {
|
204
|
+
destroy$.next(undefined)
|
205
|
+
}
|
206
|
+
}
|
207
|
+
|
208
|
+
export const PieEventTexts = defineSeriesPlugin(pluginName, DEFAULT_PIE_EVENT_TEXTS_PARAMS)(({ selection, name, observer, subject }) => {
|
209
|
+
const destroy$ = new Subject()
|
210
|
+
|
211
|
+
const { seriesCenterSelection$ } = seriesCenterSelectionObservable({
|
212
|
+
selection: selection,
|
213
|
+
pluginName,
|
214
|
+
seriesSeparate$: observer.seriesSeparate$,
|
215
|
+
seriesLabels$: observer.seriesLabels$,
|
216
|
+
seriesContainerPosition$: observer.seriesContainerPosition$
|
217
|
+
})
|
218
|
+
|
219
|
+
const unsubscribeFnArr: (() => void)[] = []
|
220
|
+
|
221
|
+
seriesCenterSelection$.subscribe(seriesCenterSelection => {
|
222
|
+
// 每次重新計算時,清除之前的訂閱
|
223
|
+
unsubscribeFnArr.forEach(fn => fn())
|
224
|
+
|
225
|
+
seriesCenterSelection.each((d, containerIndex, g) => {
|
226
|
+
|
227
|
+
const containerSelection = d3.select(g[containerIndex])
|
228
|
+
|
229
|
+
const containerComputedLayoutData$ = observer.computedLayoutData$.pipe(
|
230
|
+
takeUntil(destroy$),
|
231
|
+
map(data => data[containerIndex] ?? data[0])
|
232
|
+
)
|
233
|
+
|
234
|
+
const containerPosition$ = observer.seriesContainerPosition$.pipe(
|
235
|
+
takeUntil(destroy$),
|
236
|
+
map(data => data[containerIndex] ?? data[0])
|
237
|
+
)
|
238
|
+
|
239
|
+
unsubscribeFnArr[containerIndex] = createEachPieEventTexts(pluginName, {
|
240
|
+
containerSelection: containerSelection,
|
241
|
+
computedData$: observer.computedData$,
|
242
|
+
containerComputedLayoutData$: containerComputedLayoutData$,
|
243
|
+
SeriesDataMap$: observer.SeriesDataMap$,
|
244
|
+
fullParams$: observer.fullParams$,
|
245
|
+
fullChartParams$: observer.fullChartParams$,
|
246
|
+
seriesHighlight$: observer.seriesHighlight$,
|
247
|
+
seriesContainerPosition$: containerPosition$,
|
248
|
+
event$: subject.event$,
|
249
|
+
})
|
250
|
+
|
251
|
+
})
|
252
|
+
})
|
253
|
+
|
254
|
+
return () => {
|
255
|
+
destroy$.next(undefined)
|
256
|
+
unsubscribeFnArr.forEach(fn => fn())
|
257
|
+
}
|
258
|
+
})
|