@orbcharts/plugins-basic 3.0.10 → 3.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/orbcharts-plugins-basic.es.js +5499 -5405
- package/dist/orbcharts-plugins-basic.umd.js +50 -50
- package/package.json +4 -4
- package/src/series/defaults.ts +4 -2
- package/src/series/plugins/Indicator.ts +296 -58
- package/src/series/plugins/Pie.ts +107 -3
- package/src/series/plugins/PieEventTexts.ts +35 -14
@@ -87,11 +87,14 @@ function renderText (
|
|
87
87
|
function createTextData ({ eventData, renderFn, textAttrs, textStyles }: {
|
88
88
|
eventData: EventSeries,
|
89
89
|
// t: number,
|
90
|
-
renderFn: (d: EventSeries) => string[] | string
|
90
|
+
renderFn: (d: EventSeries) => string[] | string | null
|
91
91
|
textAttrs: Array<{ [key:string]: string | number }>
|
92
92
|
textStyles: Array<{ [key:string]: string | number }>
|
93
|
-
}): TextDatum[] {
|
94
|
-
const callbackText = renderFn(eventData)
|
93
|
+
}): TextDatum[] | null {
|
94
|
+
const callbackText: string[] | string | null = renderFn(eventData)
|
95
|
+
if (callbackText === null) {
|
96
|
+
return null
|
97
|
+
}
|
95
98
|
const textArr = Array.isArray(callbackText) ? callbackText : [callbackText]
|
96
99
|
return textArr.map((d, i) => {
|
97
100
|
return {
|
@@ -142,6 +145,14 @@ function createEachPieEventTexts (pluginName: string, context: {
|
|
142
145
|
map(d => d.highlightTarget),
|
143
146
|
distinctUntilChanged()
|
144
147
|
)
|
148
|
+
|
149
|
+
// highlight的對象(不做成observable是因為要避免觸發監聽)
|
150
|
+
let seriesHighlight: ComputedDatumSeries[] = []
|
151
|
+
context.seriesHighlight$
|
152
|
+
.pipe(
|
153
|
+
takeUntil(destroy$)
|
154
|
+
)
|
155
|
+
.subscribe(d => seriesHighlight = d)
|
145
156
|
|
146
157
|
combineLatest({
|
147
158
|
computedData: context.computedData$,
|
@@ -151,8 +162,11 @@ function createEachPieEventTexts (pluginName: string, context: {
|
|
151
162
|
}).pipe(
|
152
163
|
takeUntil(destroy$),
|
153
164
|
switchMap(async (d) => d),
|
165
|
+
// first()
|
154
166
|
).subscribe(data => {
|
155
167
|
|
168
|
+
// console.log('PieEventTexts data', data)
|
169
|
+
|
156
170
|
context.containerSelection
|
157
171
|
.transition('move')
|
158
172
|
.duration(data.fullChartParams.transitionDuration!)
|
@@ -168,10 +182,10 @@ function createEachPieEventTexts (pluginName: string, context: {
|
|
168
182
|
tween: t,
|
169
183
|
highlightTarget: data.highlightTarget,
|
170
184
|
data: data.computedData,
|
171
|
-
series:
|
172
|
-
seriesIndex: -1,
|
173
|
-
seriesLabel: '',
|
174
|
-
datum: null
|
185
|
+
series: seriesHighlight,
|
186
|
+
seriesIndex: seriesHighlight[0] ? seriesHighlight[0].seriesIndex : -1,
|
187
|
+
seriesLabel: seriesHighlight[0] ? seriesHighlight[0].seriesLabel : '',
|
188
|
+
datum: seriesHighlight[0] || null
|
175
189
|
},
|
176
190
|
// eventName: 'transitionMove',
|
177
191
|
// t,
|
@@ -179,7 +193,9 @@ function createEachPieEventTexts (pluginName: string, context: {
|
|
179
193
|
textAttrs: data.fullParams.textAttrs!,
|
180
194
|
textStyles: data.fullParams.textStyles!
|
181
195
|
})
|
182
|
-
|
196
|
+
if (renderData != null) {
|
197
|
+
centerTextSelection = renderText(context.containerSelection, renderData)
|
198
|
+
}
|
183
199
|
}
|
184
200
|
})
|
185
201
|
.on('end', (event, datum) => {
|
@@ -192,10 +208,10 @@ function createEachPieEventTexts (pluginName: string, context: {
|
|
192
208
|
tween: 1,
|
193
209
|
highlightTarget: data.highlightTarget,
|
194
210
|
data: data.computedData,
|
195
|
-
series:
|
196
|
-
seriesIndex: -1,
|
197
|
-
seriesLabel: '',
|
198
|
-
datum: null
|
211
|
+
series: seriesHighlight,
|
212
|
+
seriesIndex: seriesHighlight[0] ? seriesHighlight[0].seriesIndex : -1,
|
213
|
+
seriesLabel: seriesHighlight[0] ? seriesHighlight[0].seriesLabel : '',
|
214
|
+
datum: seriesHighlight[0] || null
|
199
215
|
},
|
200
216
|
// eventName: 'transitionMove',
|
201
217
|
// t: 1,
|
@@ -203,8 +219,11 @@ function createEachPieEventTexts (pluginName: string, context: {
|
|
203
219
|
textAttrs: data.fullParams.textAttrs!,
|
204
220
|
textStyles: data.fullParams.textStyles!
|
205
221
|
})
|
206
|
-
|
222
|
+
if (renderData != null) {
|
223
|
+
centerTextSelection = renderText(context.containerSelection, renderData)
|
224
|
+
}
|
207
225
|
|
226
|
+
// 監聽 highlight
|
208
227
|
if (storeEventSubscription) {
|
209
228
|
storeEventSubscription.unsubscribe()
|
210
229
|
}
|
@@ -217,7 +236,9 @@ function createEachPieEventTexts (pluginName: string, context: {
|
|
217
236
|
textAttrs: data.fullParams.textAttrs!,
|
218
237
|
textStyles: data.fullParams.textStyles!
|
219
238
|
})
|
220
|
-
|
239
|
+
if (renderData != null) {
|
240
|
+
centerTextSelection = renderText(context.containerSelection, renderData)
|
241
|
+
}
|
221
242
|
})
|
222
243
|
})
|
223
244
|
})
|