@orbcharts/plugins-basic 3.0.0-alpha.43 → 3.0.0-alpha.45
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/{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
|
@@ -12,13 +12,14 @@ import type { BasePluginFn } from './types'
|
|
|
12
12
|
import type {
|
|
13
13
|
ComputedDatumGrid,
|
|
14
14
|
ComputedDataGrid,
|
|
15
|
+
ComputedLayoutDatumGrid,
|
|
16
|
+
ComputedLayoutDataGrid,
|
|
15
17
|
DataFormatterGrid,
|
|
16
18
|
EventGrid,
|
|
17
|
-
|
|
19
|
+
GridContainerPosition,
|
|
18
20
|
ChartParams,
|
|
19
21
|
Layout,
|
|
20
22
|
TransformData } from '@orbcharts/core'
|
|
21
|
-
import { DATA_FORMATTER_VALUE_AXIS } from '@orbcharts/core/src/defaults'
|
|
22
23
|
import { createAxisLinearScale } from '@orbcharts/core'
|
|
23
24
|
import { getD3TransitionEase } from '../utils/d3Utils'
|
|
24
25
|
import { getClassName, getUniID, getMinAndMaxValue } from '../utils/orbchartsUtils'
|
|
@@ -34,7 +35,10 @@ export interface BaseLineAreasParams {
|
|
|
34
35
|
interface BaseLineAreasContext {
|
|
35
36
|
selection: d3.Selection<any, unknown, any, unknown>
|
|
36
37
|
computedData$: Observable<ComputedDataGrid>
|
|
37
|
-
|
|
38
|
+
computedLayoutData$: Observable<ComputedLayoutDataGrid>
|
|
39
|
+
visibleComputedData$: Observable<ComputedDatumGrid[][]>
|
|
40
|
+
visibleComputedLayoutData$: Observable<ComputedLayoutDataGrid>
|
|
41
|
+
seriesLabels$: Observable<string[]>
|
|
38
42
|
SeriesDataMap$: Observable<Map<string, ComputedDatumGrid[]>>
|
|
39
43
|
GroupDataMap$: Observable<Map<string, ComputedDatumGrid[]>>
|
|
40
44
|
fullDataFormatter$: Observable<DataFormatterGrid>
|
|
@@ -47,7 +51,7 @@ interface BaseLineAreasContext {
|
|
|
47
51
|
height: number;
|
|
48
52
|
}>
|
|
49
53
|
gridHighlight$: Observable<ComputedDatumGrid[]>
|
|
50
|
-
|
|
54
|
+
gridContainerPosition$: Observable<GridContainerPosition[]>
|
|
51
55
|
layout$: Observable<Layout>
|
|
52
56
|
event$: Subject<EventGrid>
|
|
53
57
|
}
|
|
@@ -64,8 +68,8 @@ type ClipPathDatum = {
|
|
|
64
68
|
// const pathClassName = getClassName(pluginName, 'path')
|
|
65
69
|
|
|
66
70
|
|
|
67
|
-
function createAreaPath (lineCurve: string = 'curveLinear', valueAxisStart: number): d3.Line<
|
|
68
|
-
return d3.area<
|
|
71
|
+
function createAreaPath (lineCurve: string = 'curveLinear', valueAxisStart: number): d3.Line<ComputedLayoutDatumGrid> {
|
|
72
|
+
return d3.area<ComputedLayoutDatumGrid>()
|
|
69
73
|
.x((d) => d.axisX)
|
|
70
74
|
.y0(d => valueAxisStart)
|
|
71
75
|
.y1((d) => d.axisY)
|
|
@@ -74,8 +78,8 @@ function createAreaPath (lineCurve: string = 'curveLinear', valueAxisStart: numb
|
|
|
74
78
|
}
|
|
75
79
|
|
|
76
80
|
// 依無值的資料分段
|
|
77
|
-
function makeSegmentData (data:
|
|
78
|
-
let segmentData:
|
|
81
|
+
function makeSegmentData (data: ComputedLayoutDatumGrid[]): ComputedLayoutDatumGrid[][] {
|
|
82
|
+
let segmentData: ComputedLayoutDatumGrid[][] = [[]]
|
|
79
83
|
|
|
80
84
|
let currentIndex = 0
|
|
81
85
|
for (let i in data) {
|
|
@@ -97,17 +101,17 @@ function makeSegmentData (data: ComputedDatumGrid[]): ComputedDatumGrid[][] {
|
|
|
97
101
|
function renderLineAreas ({ selection, pathClassName, segmentData, areaPath, linearGradientIds, params }: {
|
|
98
102
|
selection: d3.Selection<SVGGElement, unknown, any, unknown>
|
|
99
103
|
pathClassName: string
|
|
100
|
-
segmentData:
|
|
101
|
-
areaPath: d3.Line<
|
|
104
|
+
segmentData: ComputedLayoutDatumGrid[][]
|
|
105
|
+
areaPath: d3.Line<ComputedLayoutDatumGrid>
|
|
102
106
|
linearGradientIds: string[]
|
|
103
107
|
params: BaseLineAreasParams
|
|
104
|
-
}): d3.Selection<SVGPathElement,
|
|
108
|
+
}): d3.Selection<SVGPathElement, ComputedLayoutDatumGrid[], any, any> {
|
|
105
109
|
// if (!data[0]) {
|
|
106
110
|
// return undefined
|
|
107
111
|
// }
|
|
108
112
|
|
|
109
113
|
const lineAreas = selection
|
|
110
|
-
.selectAll<SVGPathElement,
|
|
114
|
+
.selectAll<SVGPathElement, ComputedLayoutDatumGrid[]>('path')
|
|
111
115
|
.data(segmentData, (d, i) => d.length ? `${d[0].id}_${d[d.length - 1].id}` : i) // 以線段起迄id結合為線段id
|
|
112
116
|
.join(
|
|
113
117
|
enter => {
|
|
@@ -256,7 +260,10 @@ function renderClipPath ({ defsSelection, clipPathData, transitionDuration, tran
|
|
|
256
260
|
export const createBaseLineAreas: BasePluginFn<BaseLineAreasContext> = (pluginName: string, {
|
|
257
261
|
selection,
|
|
258
262
|
computedData$,
|
|
259
|
-
|
|
263
|
+
computedLayoutData$,
|
|
264
|
+
visibleComputedData$,
|
|
265
|
+
visibleComputedLayoutData$,
|
|
266
|
+
seriesLabels$,
|
|
260
267
|
SeriesDataMap$,
|
|
261
268
|
GroupDataMap$,
|
|
262
269
|
fullParams$,
|
|
@@ -266,7 +273,7 @@ export const createBaseLineAreas: BasePluginFn<BaseLineAreasContext> = (pluginNa
|
|
|
266
273
|
gridGraphicTransform$,
|
|
267
274
|
gridAxesSize$,
|
|
268
275
|
gridHighlight$,
|
|
269
|
-
|
|
276
|
+
gridContainerPosition$,
|
|
270
277
|
layout$,
|
|
271
278
|
event$
|
|
272
279
|
}) => {
|
|
@@ -285,8 +292,8 @@ export const createBaseLineAreas: BasePluginFn<BaseLineAreasContext> = (pluginNa
|
|
|
285
292
|
selection,
|
|
286
293
|
pluginName,
|
|
287
294
|
clipPathID,
|
|
288
|
-
|
|
289
|
-
|
|
295
|
+
seriesLabels$,
|
|
296
|
+
gridContainerPosition$,
|
|
290
297
|
gridAxesTransform$,
|
|
291
298
|
gridGraphicTransform$
|
|
292
299
|
})
|
|
@@ -300,7 +307,7 @@ export const createBaseLineAreas: BasePluginFn<BaseLineAreasContext> = (pluginNa
|
|
|
300
307
|
})
|
|
301
308
|
)
|
|
302
309
|
|
|
303
|
-
const areaPath$: Observable<d3.Line<
|
|
310
|
+
const areaPath$: Observable<d3.Line<ComputedLayoutDatumGrid>> = new Observable(subscriber => {
|
|
304
311
|
const paramsSubscription = combineLatest({
|
|
305
312
|
fullParams: fullParams$,
|
|
306
313
|
valueAxisStart: valueAxisStart$
|
|
@@ -316,19 +323,18 @@ export const createBaseLineAreas: BasePluginFn<BaseLineAreasContext> = (pluginNa
|
|
|
316
323
|
}
|
|
317
324
|
})
|
|
318
325
|
|
|
319
|
-
// 顯示範圍內的series labels
|
|
320
|
-
const seriesLabels$: Observable<string[]> = new Observable(subscriber => {
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
})
|
|
326
|
+
// // 顯示範圍內的series labels
|
|
327
|
+
// const seriesLabels$: Observable<string[]> = new Observable(subscriber => {
|
|
328
|
+
// computedData$.pipe(
|
|
329
|
+
// takeUntil(destroy$),
|
|
330
|
+
// switchMap(async (d) => d),
|
|
331
|
+
// ).subscribe(data => {
|
|
332
|
+
// const labels = data[0] && data[0][0]
|
|
333
|
+
// ? data.map(d => d[0].seriesLabel)
|
|
334
|
+
// : []
|
|
335
|
+
// subscriber.next(labels)
|
|
336
|
+
// })
|
|
337
|
+
// })
|
|
332
338
|
|
|
333
339
|
// const axisSize$ = gridAxisSizeObservable({
|
|
334
340
|
// fullDataFormatter$,
|
|
@@ -355,7 +361,6 @@ export const createBaseLineAreas: BasePluginFn<BaseLineAreasContext> = (pluginNa
|
|
|
355
361
|
transitionEase: transitionEase$
|
|
356
362
|
}).pipe(
|
|
357
363
|
takeUntil(destroy$),
|
|
358
|
-
// 轉換後會退訂前一個未完成的訂閱事件,因此可以取到「同時間」最後一次的訂閱事件
|
|
359
364
|
switchMap(async (d) => d),
|
|
360
365
|
).subscribe(data => {
|
|
361
366
|
// 外層的遮罩
|
|
@@ -419,54 +424,65 @@ export const createBaseLineAreas: BasePluginFn<BaseLineAreasContext> = (pluginNa
|
|
|
419
424
|
}))
|
|
420
425
|
)
|
|
421
426
|
|
|
422
|
-
const
|
|
427
|
+
const pathSelectionArr$ = combineLatest({
|
|
423
428
|
graphicGSelection: graphicGSelection$,
|
|
424
429
|
defsSelection: defsSelection$,
|
|
425
|
-
|
|
426
|
-
computedData: computedData$,
|
|
430
|
+
visibleComputedLayoutData: visibleComputedLayoutData$,
|
|
427
431
|
linearGradientIds: linearGradientIds$,
|
|
428
|
-
SeriesDataMap: SeriesDataMap$,
|
|
429
|
-
GroupDataMap: GroupDataMap$,
|
|
430
432
|
areaPath: areaPath$,
|
|
431
433
|
params: fullParams$,
|
|
434
|
+
}).pipe(
|
|
435
|
+
takeUntil(destroy$),
|
|
436
|
+
switchMap(async (d) => d),
|
|
437
|
+
map(data => {
|
|
438
|
+
// const updateGraphic = data.graphicGSelection
|
|
439
|
+
// .selectAll<SVGGElement, number>('g')
|
|
440
|
+
// .data(data.seriesLabels, (d, i) => d)
|
|
441
|
+
// const enterGraphic = updateGraphic.enter()
|
|
442
|
+
// .append('g')
|
|
443
|
+
// .classed(graphicClassName, true)
|
|
444
|
+
// updateGraphic.exit().remove()
|
|
445
|
+
// const graphicSelection = updateGraphic.merge(enterGraphic)
|
|
446
|
+
// .attr('clip-path', (d, i) => `url(#orbcharts__clipPath_${d})`)
|
|
447
|
+
let pathSelectionArr: d3.Selection<SVGPathElement, ComputedLayoutDatumGrid[], any, any>[] = []
|
|
448
|
+
|
|
449
|
+
// 繪圖
|
|
450
|
+
data.graphicGSelection.each((d, i, all) => {
|
|
451
|
+
// 將資料分段
|
|
452
|
+
const segmentData = makeSegmentData(data.visibleComputedLayoutData[i] ?? [])
|
|
453
|
+
|
|
454
|
+
pathSelectionArr[i] = renderLineAreas({
|
|
455
|
+
selection: d3.select(all[i]),
|
|
456
|
+
pathClassName,
|
|
457
|
+
areaPath: data.areaPath,
|
|
458
|
+
segmentData: segmentData,
|
|
459
|
+
linearGradientIds: data.linearGradientIds,
|
|
460
|
+
params: data.params
|
|
461
|
+
})
|
|
462
|
+
renderLinearGradient({
|
|
463
|
+
defsSelection: data.defsSelection,
|
|
464
|
+
computedData: data.visibleComputedLayoutData,
|
|
465
|
+
linearGradientIds: data.linearGradientIds,
|
|
466
|
+
params: data.params
|
|
467
|
+
})
|
|
468
|
+
})
|
|
469
|
+
|
|
470
|
+
return pathSelectionArr
|
|
471
|
+
})
|
|
472
|
+
)
|
|
473
|
+
|
|
474
|
+
combineLatest({
|
|
475
|
+
pathSelectionArr: pathSelectionArr$,
|
|
476
|
+
computedData: computedData$,
|
|
477
|
+
SeriesDataMap: SeriesDataMap$,
|
|
478
|
+
GroupDataMap: GroupDataMap$,
|
|
432
479
|
highlightTarget: highlightTarget$,
|
|
433
480
|
gridGroupPositionFn: gridGroupPositionFn$,
|
|
434
481
|
}).pipe(
|
|
435
482
|
takeUntil(destroy$),
|
|
436
|
-
// 轉換後會退訂前一個未完成的訂閱事件,因此可以取到「同時間」最後一次的訂閱事件
|
|
437
483
|
switchMap(async (d) => d),
|
|
438
484
|
).subscribe(data => {
|
|
439
|
-
|
|
440
|
-
// const updateGraphic = data.graphicGSelection
|
|
441
|
-
// .selectAll<SVGGElement, number>('g')
|
|
442
|
-
// .data(data.seriesLabels, (d, i) => d)
|
|
443
|
-
// const enterGraphic = updateGraphic.enter()
|
|
444
|
-
// .append('g')
|
|
445
|
-
// .classed(graphicClassName, true)
|
|
446
|
-
// updateGraphic.exit().remove()
|
|
447
|
-
// const graphicSelection = updateGraphic.merge(enterGraphic)
|
|
448
|
-
// .attr('clip-path', (d, i) => `url(#orbcharts__clipPath_${d})`)
|
|
449
|
-
|
|
450
|
-
// 繪圖
|
|
451
|
-
data.graphicGSelection.each((d, i, all) => {
|
|
452
|
-
// 將資料分段
|
|
453
|
-
const segmentData = makeSegmentData(data.computedData[i] ?? [])
|
|
454
|
-
|
|
455
|
-
const pathSelection = renderLineAreas({
|
|
456
|
-
selection: d3.select(all[i]),
|
|
457
|
-
pathClassName,
|
|
458
|
-
areaPath: data.areaPath,
|
|
459
|
-
segmentData: segmentData,
|
|
460
|
-
linearGradientIds: data.linearGradientIds,
|
|
461
|
-
params: data.params
|
|
462
|
-
})
|
|
463
|
-
renderLinearGradient({
|
|
464
|
-
defsSelection: data.defsSelection,
|
|
465
|
-
computedData: data.computedData,
|
|
466
|
-
linearGradientIds: data.linearGradientIds,
|
|
467
|
-
params: data.params
|
|
468
|
-
})
|
|
469
|
-
|
|
485
|
+
data.pathSelectionArr.forEach(pathSelection => {
|
|
470
486
|
pathSelection
|
|
471
487
|
.on('mouseover', (event, datum) => {
|
|
472
488
|
event.stopPropagation()
|
|
@@ -570,21 +586,9 @@ export const createBaseLineAreas: BasePluginFn<BaseLineAreasContext> = (pluginNa
|
|
|
570
586
|
groupLabel: _datum.groupLabel,
|
|
571
587
|
event,
|
|
572
588
|
data: data.computedData
|
|
573
|
-
})
|
|
574
589
|
})
|
|
575
|
-
|
|
590
|
+
})
|
|
576
591
|
})
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
// graphicSelection$.next(graphicSelection)
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
// pathSelection = renderLineAreas({
|
|
584
|
-
// selection: graphicSelection,
|
|
585
|
-
// areaPath: d.areaPath,
|
|
586
|
-
// data: d.computedData
|
|
587
|
-
// })
|
|
588
592
|
})
|
|
589
593
|
|
|
590
594
|
// const datumList$ = computedData$.pipe(
|
package/src/base/BaseLines.ts
CHANGED
|
@@ -12,9 +12,11 @@ import type { BasePluginFn } from './types'
|
|
|
12
12
|
import type {
|
|
13
13
|
ComputedDatumGrid,
|
|
14
14
|
ComputedDataGrid,
|
|
15
|
+
ComputedLayoutDatumGrid,
|
|
16
|
+
ComputedLayoutDataGrid,
|
|
15
17
|
DataFormatterGrid,
|
|
16
18
|
EventGrid,
|
|
17
|
-
|
|
19
|
+
GridContainerPosition,
|
|
18
20
|
ChartParams,
|
|
19
21
|
Layout,
|
|
20
22
|
TransformData } from '@orbcharts/core'
|
|
@@ -38,7 +40,10 @@ export interface BaseLinesParams {
|
|
|
38
40
|
interface BaseLinesContext {
|
|
39
41
|
selection: d3.Selection<any, unknown, any, unknown>
|
|
40
42
|
computedData$: Observable<ComputedDataGrid>
|
|
41
|
-
|
|
43
|
+
computedLayoutData$: Observable<ComputedLayoutDataGrid>
|
|
44
|
+
visibleComputedData$: Observable<ComputedDatumGrid[][]>
|
|
45
|
+
visibleComputedLayoutData$: Observable<ComputedLayoutDataGrid>
|
|
46
|
+
seriesLabels$: Observable<string[]>
|
|
42
47
|
SeriesDataMap$: Observable<Map<string, ComputedDatumGrid[]>>
|
|
43
48
|
GroupDataMap$: Observable<Map<string, ComputedDatumGrid[]>>
|
|
44
49
|
fullDataFormatter$: Observable<DataFormatterGrid>
|
|
@@ -51,7 +56,7 @@ interface BaseLinesContext {
|
|
|
51
56
|
height: number;
|
|
52
57
|
}>
|
|
53
58
|
gridHighlight$: Observable<ComputedDatumGrid[]>
|
|
54
|
-
|
|
59
|
+
gridContainerPosition$: Observable<GridContainerPosition[]>
|
|
55
60
|
event$: Subject<EventGrid>
|
|
56
61
|
}
|
|
57
62
|
|
|
@@ -68,16 +73,16 @@ type ClipPathDatum = {
|
|
|
68
73
|
// const pathClassName = getClassName(pluginName, 'path')
|
|
69
74
|
|
|
70
75
|
|
|
71
|
-
function createLinePath (lineCurve: string = 'curveLinear'): d3.Line<
|
|
72
|
-
return d3.line<
|
|
76
|
+
function createLinePath (lineCurve: string = 'curveLinear'): d3.Line<ComputedLayoutDatumGrid> {
|
|
77
|
+
return d3.line<ComputedLayoutDatumGrid>()
|
|
73
78
|
.x((d) => d.axisX)
|
|
74
79
|
.y((d) => d.axisY)
|
|
75
80
|
.curve((d3 as any)[lineCurve])
|
|
76
81
|
}
|
|
77
82
|
|
|
78
83
|
// 依無值的資料分段
|
|
79
|
-
function
|
|
80
|
-
let segmentData:
|
|
84
|
+
function makeSegmentData (data: ComputedLayoutDatumGrid[]): ComputedLayoutDatumGrid[][] {
|
|
85
|
+
let segmentData: ComputedLayoutDatumGrid[][] = [[]]
|
|
81
86
|
|
|
82
87
|
let currentIndex = 0
|
|
83
88
|
for (let i in data) {
|
|
@@ -99,16 +104,16 @@ function makeSegmentData (data: ComputedDatumGrid[]): ComputedDatumGrid[][] {
|
|
|
99
104
|
function renderLines ({ selection, pathClassName, segmentData, linePath, params }: {
|
|
100
105
|
selection: d3.Selection<SVGGElement, unknown, any, unknown>
|
|
101
106
|
pathClassName: string
|
|
102
|
-
segmentData:
|
|
103
|
-
linePath: d3.Line<
|
|
107
|
+
segmentData: ComputedLayoutDatumGrid[][]
|
|
108
|
+
linePath: d3.Line<ComputedLayoutDatumGrid>
|
|
104
109
|
params: BaseLinesParams
|
|
105
|
-
}): d3.Selection<SVGPathElement,
|
|
110
|
+
}): d3.Selection<SVGPathElement, ComputedLayoutDatumGrid[], any, any> {
|
|
106
111
|
// if (!data[0]) {
|
|
107
112
|
// return undefined
|
|
108
113
|
// }
|
|
109
114
|
|
|
110
115
|
const lines = selection
|
|
111
|
-
.selectAll<SVGPathElement,
|
|
116
|
+
.selectAll<SVGPathElement, ComputedLayoutDatumGrid[]>('path')
|
|
112
117
|
.data(segmentData, (d, i) => d.length ? `${d[0].id}_${d[d.length - 1].id}` : i) // 以線段起迄id結合為線段id
|
|
113
118
|
.join(
|
|
114
119
|
enter => {
|
|
@@ -221,7 +226,10 @@ function renderClipPath ({ defsSelection, clipPathData, transitionDuration, tran
|
|
|
221
226
|
export const createBaseLines: BasePluginFn<BaseLinesContext> = (pluginName: string, {
|
|
222
227
|
selection,
|
|
223
228
|
computedData$,
|
|
224
|
-
|
|
229
|
+
computedLayoutData$,
|
|
230
|
+
visibleComputedData$,
|
|
231
|
+
visibleComputedLayoutData$,
|
|
232
|
+
seriesLabels$,
|
|
225
233
|
SeriesDataMap$,
|
|
226
234
|
GroupDataMap$,
|
|
227
235
|
fullParams$,
|
|
@@ -231,7 +239,7 @@ export const createBaseLines: BasePluginFn<BaseLinesContext> = (pluginName: stri
|
|
|
231
239
|
gridGraphicTransform$,
|
|
232
240
|
gridAxesSize$,
|
|
233
241
|
gridHighlight$,
|
|
234
|
-
|
|
242
|
+
gridContainerPosition$,
|
|
235
243
|
event$
|
|
236
244
|
}) => {
|
|
237
245
|
|
|
@@ -322,7 +330,7 @@ export const createBaseLines: BasePluginFn<BaseLinesContext> = (pluginName: stri
|
|
|
322
330
|
|
|
323
331
|
// combineLatest({
|
|
324
332
|
// seriesSelection: seriesSelection$,
|
|
325
|
-
//
|
|
333
|
+
// gridContainerPosition: gridContainerPosition$
|
|
326
334
|
// }).pipe(
|
|
327
335
|
// takeUntil(destroy$),
|
|
328
336
|
// switchMap(async d => d)
|
|
@@ -330,8 +338,8 @@ export const createBaseLines: BasePluginFn<BaseLinesContext> = (pluginName: stri
|
|
|
330
338
|
// data.seriesSelection
|
|
331
339
|
// .transition()
|
|
332
340
|
// .attr('transform', (d, i) => {
|
|
333
|
-
// const translate = data.
|
|
334
|
-
// const scale = data.
|
|
341
|
+
// const translate = data.gridContainerPosition[i].translate
|
|
342
|
+
// const scale = data.gridContainerPosition[i].scale
|
|
335
343
|
// return `translate(${translate[0]}, ${translate[1]}) scale(${scale[0]}, ${scale[1]})`
|
|
336
344
|
// })
|
|
337
345
|
// })
|
|
@@ -382,13 +390,13 @@ export const createBaseLines: BasePluginFn<BaseLinesContext> = (pluginName: stri
|
|
|
382
390
|
selection,
|
|
383
391
|
pluginName,
|
|
384
392
|
clipPathID,
|
|
385
|
-
|
|
386
|
-
|
|
393
|
+
seriesLabels$,
|
|
394
|
+
gridContainerPosition$,
|
|
387
395
|
gridAxesTransform$,
|
|
388
396
|
gridGraphicTransform$
|
|
389
397
|
})
|
|
390
398
|
|
|
391
|
-
const linePath$: Observable<d3.Line<
|
|
399
|
+
const linePath$: Observable<d3.Line<ComputedLayoutDatumGrid>> = new Observable(subscriber => {
|
|
392
400
|
const paramsSubscription = fullParams$
|
|
393
401
|
.pipe(
|
|
394
402
|
takeUntil(destroy$)
|
|
@@ -403,19 +411,18 @@ export const createBaseLines: BasePluginFn<BaseLinesContext> = (pluginName: stri
|
|
|
403
411
|
}
|
|
404
412
|
})
|
|
405
413
|
|
|
406
|
-
// 顯示範圍內的series labels
|
|
407
|
-
const seriesLabels$: Observable<string[]> = new Observable(subscriber => {
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
})
|
|
414
|
+
// // 顯示範圍內的series labels
|
|
415
|
+
// const seriesLabels$: Observable<string[]> = new Observable(subscriber => {
|
|
416
|
+
// computedData$.pipe(
|
|
417
|
+
// takeUntil(destroy$),
|
|
418
|
+
// switchMap(async (d) => d),
|
|
419
|
+
// ).subscribe(data => {
|
|
420
|
+
// const labels = data[0] && data[0][0]
|
|
421
|
+
// ? data.map(d => d[0].seriesLabel)
|
|
422
|
+
// : []
|
|
423
|
+
// subscriber.next(labels)
|
|
424
|
+
// })
|
|
425
|
+
// })
|
|
419
426
|
|
|
420
427
|
// const axisSize$ = gridAxisSizeObservable({
|
|
421
428
|
// fullDataFormatter$,
|
|
@@ -442,7 +449,6 @@ export const createBaseLines: BasePluginFn<BaseLinesContext> = (pluginName: stri
|
|
|
442
449
|
transitionEase: transitionEase$
|
|
443
450
|
}).pipe(
|
|
444
451
|
takeUntil(destroy$),
|
|
445
|
-
// 轉換後會退訂前一個未完成的訂閱事件,因此可以取到「同時間」最後一次的訂閱事件
|
|
446
452
|
switchMap(async (d) => d),
|
|
447
453
|
).subscribe(data => {
|
|
448
454
|
// 外層的遮罩
|
|
@@ -499,45 +505,58 @@ export const createBaseLines: BasePluginFn<BaseLinesContext> = (pluginName: stri
|
|
|
499
505
|
distinctUntilChanged()
|
|
500
506
|
)
|
|
501
507
|
|
|
502
|
-
const
|
|
508
|
+
const pathSelectionArr$ = combineLatest({
|
|
503
509
|
graphicGSelection: graphicGSelection$,
|
|
504
|
-
|
|
510
|
+
visibleComputedLayoutData: visibleComputedLayoutData$,
|
|
511
|
+
linePath: linePath$,
|
|
512
|
+
params: fullParams$,
|
|
513
|
+
}).pipe(
|
|
514
|
+
takeUntil(destroy$),
|
|
515
|
+
switchMap(async (d) => d),
|
|
516
|
+
map(data => {
|
|
517
|
+
// const updateGraphic = data.graphicGSelection
|
|
518
|
+
// .selectAll<SVGGElement, number>('g')
|
|
519
|
+
// .data(data.seriesLabels, (d, i) => d)
|
|
520
|
+
// const enterGraphic = updateGraphic.enter()
|
|
521
|
+
// .append('g')
|
|
522
|
+
// .classed(graphicClassName, true)
|
|
523
|
+
// updateGraphic.exit().remove()
|
|
524
|
+
// const graphicSelection = updateGraphic.merge(enterGraphic)
|
|
525
|
+
// .attr('clip-path', (d, i) => `url(#orbcharts__clipPath_${d})`)
|
|
526
|
+
let pathSelectionArr: d3.Selection<SVGPathElement, ComputedLayoutDatumGrid[], any, any>[] = []
|
|
527
|
+
|
|
528
|
+
// 繪圖
|
|
529
|
+
data.graphicGSelection.each((d, i, all) => {
|
|
530
|
+
// 將資料分段
|
|
531
|
+
const segmentData = makeSegmentData(data.visibleComputedLayoutData[i] ?? [])
|
|
532
|
+
|
|
533
|
+
pathSelectionArr[i] = renderLines({
|
|
534
|
+
selection: d3.select(all[i]),
|
|
535
|
+
pathClassName,
|
|
536
|
+
linePath: data.linePath,
|
|
537
|
+
segmentData: segmentData,
|
|
538
|
+
params: data.params
|
|
539
|
+
})
|
|
540
|
+
})
|
|
541
|
+
|
|
542
|
+
return pathSelectionArr
|
|
543
|
+
})
|
|
544
|
+
|
|
545
|
+
|
|
546
|
+
)
|
|
547
|
+
|
|
548
|
+
combineLatest({
|
|
549
|
+
pathSelectionArr: pathSelectionArr$,
|
|
505
550
|
computedData: computedData$,
|
|
506
551
|
SeriesDataMap: SeriesDataMap$,
|
|
507
552
|
GroupDataMap: GroupDataMap$,
|
|
508
|
-
linePath: linePath$,
|
|
509
|
-
params: fullParams$,
|
|
510
553
|
highlightTarget: highlightTarget$,
|
|
511
554
|
gridGroupPositionFn: gridGroupPositionFn$,
|
|
512
555
|
}).pipe(
|
|
513
556
|
takeUntil(destroy$),
|
|
514
|
-
|
|
515
|
-
switchMap(async (d) => d),
|
|
557
|
+
switchMap(async (d) => d)
|
|
516
558
|
).subscribe(data => {
|
|
517
|
-
|
|
518
|
-
// const updateGraphic = data.graphicGSelection
|
|
519
|
-
// .selectAll<SVGGElement, number>('g')
|
|
520
|
-
// .data(data.seriesLabels, (d, i) => d)
|
|
521
|
-
// const enterGraphic = updateGraphic.enter()
|
|
522
|
-
// .append('g')
|
|
523
|
-
// .classed(graphicClassName, true)
|
|
524
|
-
// updateGraphic.exit().remove()
|
|
525
|
-
// const graphicSelection = updateGraphic.merge(enterGraphic)
|
|
526
|
-
// .attr('clip-path', (d, i) => `url(#orbcharts__clipPath_${d})`)
|
|
527
|
-
|
|
528
|
-
// 繪圖
|
|
529
|
-
data.graphicGSelection.each((d, i, all) => {
|
|
530
|
-
// 將資料分段
|
|
531
|
-
const segmentData = makeSegmentData(data.computedData[i] ?? [])
|
|
532
|
-
|
|
533
|
-
const pathSelection = renderLines({
|
|
534
|
-
selection: d3.select(all[i]),
|
|
535
|
-
pathClassName,
|
|
536
|
-
linePath: data.linePath,
|
|
537
|
-
segmentData: segmentData,
|
|
538
|
-
params: data.params
|
|
539
|
-
})
|
|
540
|
-
|
|
559
|
+
data.pathSelectionArr.forEach(pathSelection => {
|
|
541
560
|
pathSelection
|
|
542
561
|
.on('mouseover', (event, datum) => {
|
|
543
562
|
event.stopPropagation()
|
|
@@ -643,19 +662,7 @@ export const createBaseLines: BasePluginFn<BaseLinesContext> = (pluginName: stri
|
|
|
643
662
|
data: data.computedData
|
|
644
663
|
})
|
|
645
664
|
})
|
|
646
|
-
|
|
647
665
|
})
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
// graphicSelection$.next(graphicSelection)
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
// pathSelection = renderLines({
|
|
655
|
-
// selection: graphicSelection,
|
|
656
|
-
// linePath: d.linePath,
|
|
657
|
-
// data: d.computedData
|
|
658
|
-
// })
|
|
659
666
|
})
|
|
660
667
|
|
|
661
668
|
// const datumList$ = computedData$.pipe(
|
|
@@ -15,7 +15,7 @@ import type {
|
|
|
15
15
|
DataFormatterGrid,
|
|
16
16
|
ChartParams,
|
|
17
17
|
ComputedDatumGrid,
|
|
18
|
-
|
|
18
|
+
GridContainerPosition,
|
|
19
19
|
TransformData,
|
|
20
20
|
EventGrid,
|
|
21
21
|
ColorType } from '@orbcharts/core'
|
|
@@ -50,8 +50,8 @@ interface BaseLinesContext {
|
|
|
50
50
|
width: number;
|
|
51
51
|
height: number;
|
|
52
52
|
}>
|
|
53
|
-
|
|
54
|
-
|
|
53
|
+
gridContainerPosition$: Observable<GridContainerPosition[]>
|
|
54
|
+
isSeriesSeprate$: Observable<boolean>
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
interface TextAlign {
|
|
@@ -107,7 +107,7 @@ function renderLinearAxis ({ selection, yAxisClassName, textClassName, fullParam
|
|
|
107
107
|
)
|
|
108
108
|
.attr('text-anchor', axisLabelAlign.textAnchor)
|
|
109
109
|
.attr('dominant-baseline', axisLabelAlign.dominantBaseline)
|
|
110
|
-
.
|
|
110
|
+
.attr('font-size', fullChartParams.styles.textSize)
|
|
111
111
|
.style('fill', getColor(fullParams.labelColorType, fullChartParams))
|
|
112
112
|
.style('transform', textTransform)
|
|
113
113
|
.text(d => fullDataFormatter.grid.valueAxis.label)
|
|
@@ -153,8 +153,8 @@ function renderLinearAxis ({ selection, yAxisClassName, textClassName, fullParam
|
|
|
153
153
|
|
|
154
154
|
// const yText = yAxisEl.selectAll('text')
|
|
155
155
|
const yText = yAxisSelection.selectAll('text')
|
|
156
|
-
.style('font-family', 'sans-serif')
|
|
157
|
-
.
|
|
156
|
+
// .style('font-family', 'sans-serif')
|
|
157
|
+
.attr('font-size', fullChartParams.styles.textSize)
|
|
158
158
|
.style('color', getColor(fullParams.tickTextColorType, fullChartParams))
|
|
159
159
|
.attr('text-anchor', tickTextAlign.textAnchor)
|
|
160
160
|
.attr('dominant-baseline', tickTextAlign.dominantBaseline)
|
|
@@ -175,8 +175,8 @@ export const createBaseValueAxis: BasePluginFn<BaseLinesContext> = (pluginName:
|
|
|
175
175
|
gridAxesTransform$,
|
|
176
176
|
gridAxesReverseTransform$,
|
|
177
177
|
gridAxesSize$,
|
|
178
|
-
|
|
179
|
-
|
|
178
|
+
gridContainerPosition$,
|
|
179
|
+
isSeriesSeprate$,
|
|
180
180
|
}) => {
|
|
181
181
|
|
|
182
182
|
const destroy$ = new Subject()
|
|
@@ -193,12 +193,12 @@ export const createBaseValueAxis: BasePluginFn<BaseLinesContext> = (pluginName:
|
|
|
193
193
|
return a.length === b.length
|
|
194
194
|
}),
|
|
195
195
|
),
|
|
196
|
-
|
|
196
|
+
isSeriesSeprate: isSeriesSeprate$
|
|
197
197
|
}).pipe(
|
|
198
198
|
takeUntil(destroy$),
|
|
199
199
|
switchMap(async (d) => d),
|
|
200
200
|
map(data => {
|
|
201
|
-
return data.
|
|
201
|
+
return data.isSeriesSeprate
|
|
202
202
|
// series分開的時候顯示各別axis
|
|
203
203
|
? data.computedData
|
|
204
204
|
// series合併的時候只顯示第一個axis
|
|
@@ -226,16 +226,16 @@ export const createBaseValueAxis: BasePluginFn<BaseLinesContext> = (pluginName:
|
|
|
226
226
|
|
|
227
227
|
combineLatest({
|
|
228
228
|
containerSelection: containerSelection$,
|
|
229
|
-
|
|
229
|
+
gridContainerPosition: gridContainerPosition$
|
|
230
230
|
}).pipe(
|
|
231
231
|
takeUntil(destroy$),
|
|
232
232
|
switchMap(async d => d)
|
|
233
233
|
).subscribe(data => {
|
|
234
234
|
data.containerSelection
|
|
235
235
|
.attr('transform', (d, i) => {
|
|
236
|
-
const
|
|
237
|
-
const translate =
|
|
238
|
-
const scale =
|
|
236
|
+
const gridContainerPosition = data.gridContainerPosition[i] ?? data.gridContainerPosition[0]
|
|
237
|
+
const translate = gridContainerPosition.translate
|
|
238
|
+
const scale = gridContainerPosition.scale
|
|
239
239
|
return `translate(${translate[0]}, ${translate[1]}) scale(${scale[0]}, ${scale[1]})`
|
|
240
240
|
})
|
|
241
241
|
// .attr('opacity', 0)
|
|
@@ -308,14 +308,14 @@ export const createBaseValueAxis: BasePluginFn<BaseLinesContext> = (pluginName:
|
|
|
308
308
|
fullParams: fullParams$,
|
|
309
309
|
fullDataFormatter: fullDataFormatter$,
|
|
310
310
|
gridAxesReverseTransform: gridAxesReverseTransform$,
|
|
311
|
-
|
|
311
|
+
gridContainerPosition: gridContainerPosition$
|
|
312
312
|
}).pipe(
|
|
313
313
|
takeUntil(destroy$),
|
|
314
314
|
switchMap(async (d) => d),
|
|
315
315
|
map(data => {
|
|
316
316
|
const axisReverseTranslateValue = `translate(${data.gridAxesReverseTransform.translate[0]}px, ${data.gridAxesReverseTransform.translate[1]}px)`
|
|
317
317
|
const axisReverseRotateValue = `rotate(${data.gridAxesReverseTransform.rotate}deg) rotateX(${data.gridAxesReverseTransform.rotateX}deg) rotateY(${data.gridAxesReverseTransform.rotateY}deg)`
|
|
318
|
-
const containerScaleReverseScaleValue = `scale(${1 / data.
|
|
318
|
+
const containerScaleReverseScaleValue = `scale(${1 / data.gridContainerPosition[0].scale[0]}, ${1 / data.gridContainerPosition[0].scale[1]})`
|
|
319
319
|
const tickTextRotateDeg = (data.fullDataFormatter.grid.groupAxis.position === 'left' && data.fullDataFormatter.grid.valueAxis.position === 'top')
|
|
320
320
|
|| (data.fullDataFormatter.grid.groupAxis.position === 'right' && data.fullDataFormatter.grid.valueAxis.position === 'bottom')
|
|
321
321
|
? data.fullParams.tickTextRotate + 180 // 修正文字倒轉
|
|
@@ -354,7 +354,7 @@ export const createBaseValueAxis: BasePluginFn<BaseLinesContext> = (pluginName:
|
|
|
354
354
|
})
|
|
355
355
|
|
|
356
356
|
const filteredMinAndMax = getMinAndMaxValue(filteredData.flat())
|
|
357
|
-
|
|
357
|
+
|
|
358
358
|
subscriber.next(filteredMinAndMax)
|
|
359
359
|
})
|
|
360
360
|
})
|
|
@@ -366,7 +366,6 @@ export const createBaseValueAxis: BasePluginFn<BaseLinesContext> = (pluginName:
|
|
|
366
366
|
minAndMax: minAndMax$
|
|
367
367
|
}).pipe(
|
|
368
368
|
takeUntil(destroy$),
|
|
369
|
-
// 轉換後會退訂前一個未完成的訂閱事件,因此可以取到「同時間」最後一次的訂閱事件
|
|
370
369
|
switchMap(async (d) => d),
|
|
371
370
|
).subscribe(data => {
|
|
372
371
|
|