@orbcharts/plugin-basic 4.0.0-pre-alpha.0
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/LICENSE +201 -0
- package/dist/orbcharts-plugin-basic.es.js +25335 -0
- package/dist/orbcharts-plugin-basic.umd.js +341 -0
- package/dist/plugin-basic/src/baseLayers/BaseBars.d.ts +38 -0
- package/dist/plugin-basic/src/baseLayers/BaseBarsTriangle.d.ts +37 -0
- package/dist/plugin-basic/src/baseLayers/BaseCategoryAxis.d.ts +42 -0
- package/dist/plugin-basic/src/baseLayers/BaseDots.d.ts +38 -0
- package/dist/plugin-basic/src/baseLayers/BaseLegend.d.ts +31 -0
- package/dist/plugin-basic/src/baseLayers/BaseLineAreas.d.ts +36 -0
- package/dist/plugin-basic/src/baseLayers/BaseLines.d.ts +36 -0
- package/dist/plugin-basic/src/baseLayers/BaseStackedBars.d.ts +41 -0
- package/dist/plugin-basic/src/baseLayers/BaseTooltip.d.ts +47 -0
- package/dist/plugin-basic/src/baseLayers/BaseValueAxis.d.ts +38 -0
- package/dist/plugin-basic/src/baseLayers/BaseXAxis.d.ts +25 -0
- package/dist/plugin-basic/src/baseLayers/BaseXZoom.d.ts +22 -0
- package/dist/plugin-basic/src/baseLayers/BaseYAxis.d.ts +23 -0
- package/dist/plugin-basic/src/baseLayers/types.d.ts +171 -0
- package/dist/plugin-basic/src/const/layerIndex.d.ts +10 -0
- package/dist/plugin-basic/src/const/sharedPluginParams.d.ts +6 -0
- package/dist/plugin-basic/src/index.d.ts +2 -0
- package/dist/plugin-basic/src/plugins/CompositionPlot/CompositionPlot.d.ts +22 -0
- package/dist/plugin-basic/src/plugins/CompositionPlot/contextObservables.d.ts +40 -0
- package/dist/plugin-basic/src/plugins/CompositionPlot/defaults.d.ts +10 -0
- package/dist/plugin-basic/src/plugins/CompositionPlot/index.d.ts +3 -0
- package/dist/plugin-basic/src/plugins/CompositionPlot/layers/Bubbles.d.ts +16 -0
- package/dist/plugin-basic/src/plugins/CompositionPlot/layers/Indicator.d.ts +0 -0
- package/dist/plugin-basic/src/plugins/CompositionPlot/layers/Pie.d.ts +16 -0
- package/dist/plugin-basic/src/plugins/CompositionPlot/layers/PieEventTexts.d.ts +16 -0
- package/dist/plugin-basic/src/plugins/CompositionPlot/layers/PieLabels.d.ts +16 -0
- package/dist/plugin-basic/src/plugins/CompositionPlot/layers/Rose.d.ts +16 -0
- package/dist/plugin-basic/src/plugins/CompositionPlot/layers/RoseLabels.d.ts +16 -0
- package/dist/plugin-basic/src/plugins/CompositionPlot/layers/Waffle.d.ts +0 -0
- package/dist/plugin-basic/src/plugins/CompositionPlot/types.d.ts +110 -0
- package/dist/plugin-basic/src/plugins/CompositionPlot/utils.d.ts +19 -0
- package/dist/plugin-basic/src/plugins/HierarchyPlot/HierarchyPlot.d.ts +22 -0
- package/dist/plugin-basic/src/plugins/HierarchyPlot/contextObservables.d.ts +16 -0
- package/dist/plugin-basic/src/plugins/HierarchyPlot/defaults.d.ts +4 -0
- package/dist/plugin-basic/src/plugins/HierarchyPlot/index.d.ts +3 -0
- package/dist/plugin-basic/src/plugins/HierarchyPlot/layers/TreeMap.d.ts +16 -0
- package/dist/plugin-basic/src/plugins/HierarchyPlot/types.d.ts +29 -0
- package/dist/plugin-basic/src/plugins/Legend/Legend.d.ts +22 -0
- package/dist/plugin-basic/src/plugins/Legend/contextObservables.d.ts +9 -0
- package/dist/plugin-basic/src/plugins/Legend/defaults.d.ts +4 -0
- package/dist/plugin-basic/src/plugins/Legend/index.d.ts +3 -0
- package/dist/plugin-basic/src/plugins/Legend/layers/Legend.d.ts +16 -0
- package/dist/plugin-basic/src/plugins/Legend/types.d.ts +31 -0
- package/dist/plugin-basic/src/plugins/Legend/utils.d.ts +19 -0
- package/dist/plugin-basic/src/plugins/NetworkPlot/NetworkPlot.d.ts +22 -0
- package/dist/plugin-basic/src/plugins/NetworkPlot/contextObservables.d.ts +19 -0
- package/dist/plugin-basic/src/plugins/NetworkPlot/defaults.d.ts +5 -0
- package/dist/plugin-basic/src/plugins/NetworkPlot/index.d.ts +3 -0
- package/dist/plugin-basic/src/plugins/NetworkPlot/layers/ForceDirected.d.ts +16 -0
- package/dist/plugin-basic/src/plugins/NetworkPlot/layers/ForceDirectedBubbles.d.ts +16 -0
- package/dist/plugin-basic/src/plugins/NetworkPlot/types.d.ts +117 -0
- package/dist/plugin-basic/src/plugins/ScatterPlot/ScatterPlot.d.ts +22 -0
- package/dist/plugin-basic/src/plugins/ScatterPlot/contextObservables.d.ts +140 -0
- package/dist/plugin-basic/src/plugins/ScatterPlot/defaults.d.ts +8 -0
- package/dist/plugin-basic/src/plugins/ScatterPlot/index.d.ts +3 -0
- package/dist/plugin-basic/src/plugins/ScatterPlot/layers/Scatter.d.ts +16 -0
- package/dist/plugin-basic/src/plugins/ScatterPlot/layers/ScatterBubbles.d.ts +16 -0
- package/dist/plugin-basic/src/plugins/ScatterPlot/layers/XYAux.d.ts +16 -0
- package/dist/plugin-basic/src/plugins/ScatterPlot/layers/XYAxes.d.ts +16 -0
- package/dist/plugin-basic/src/plugins/ScatterPlot/layers/XZoom.d.ts +16 -0
- package/dist/plugin-basic/src/plugins/ScatterPlot/types.d.ts +146 -0
- package/dist/plugin-basic/src/plugins/SeriesPlot/SeriesPlot.d.ts +22 -0
- package/dist/plugin-basic/src/plugins/SeriesPlot/contextObservables.d.ts +77 -0
- package/dist/plugin-basic/src/plugins/SeriesPlot/defaults.d.ts +15 -0
- package/dist/plugin-basic/src/plugins/SeriesPlot/index.d.ts +3 -0
- package/dist/plugin-basic/src/plugins/SeriesPlot/layers/Bars.d.ts +16 -0
- package/dist/plugin-basic/src/plugins/SeriesPlot/layers/BarsPN.d.ts +16 -0
- package/dist/plugin-basic/src/plugins/SeriesPlot/layers/BarsTriangle.d.ts +16 -0
- package/dist/plugin-basic/src/plugins/SeriesPlot/layers/CategoryAux.d.ts +16 -0
- package/dist/plugin-basic/src/plugins/SeriesPlot/layers/CategoryAxis.d.ts +16 -0
- package/dist/plugin-basic/src/plugins/SeriesPlot/layers/CategoryZoom.d.ts +16 -0
- package/dist/plugin-basic/src/plugins/SeriesPlot/layers/Dots.d.ts +16 -0
- package/dist/plugin-basic/src/plugins/SeriesPlot/layers/LineAreas.d.ts +16 -0
- package/dist/plugin-basic/src/plugins/SeriesPlot/layers/Lines.d.ts +16 -0
- package/dist/plugin-basic/src/plugins/SeriesPlot/layers/StackedBars.d.ts +16 -0
- package/dist/plugin-basic/src/plugins/SeriesPlot/layers/StackedValueAxis.d.ts +16 -0
- package/dist/plugin-basic/src/plugins/SeriesPlot/layers/ValueAxis.d.ts +16 -0
- package/dist/plugin-basic/src/plugins/SeriesPlot/types.d.ts +140 -0
- package/dist/plugin-basic/src/plugins/Tooltip/Tooltip.d.ts +22 -0
- package/dist/plugin-basic/src/plugins/Tooltip/contextObservables.d.ts +9 -0
- package/dist/plugin-basic/src/plugins/Tooltip/defaults.d.ts +4 -0
- package/dist/plugin-basic/src/plugins/Tooltip/index.d.ts +3 -0
- package/dist/plugin-basic/src/plugins/Tooltip/layers/Tooltip.d.ts +16 -0
- package/dist/plugin-basic/src/plugins/Tooltip/types.d.ts +35 -0
- package/dist/plugin-basic/src/plugins/Tooltip/utils.d.ts +19 -0
- package/dist/plugin-basic/src/plugins/index.d.ts +7 -0
- package/dist/plugin-basic/src/types/BaseLayer.d.ts +3 -0
- package/dist/plugin-basic/src/types/Common.d.ts +14 -0
- package/dist/plugin-basic/src/types/ComputedData.d.ts +27 -0
- package/dist/plugin-basic/src/types/PluginParams.d.ts +66 -0
- package/dist/plugin-basic/src/types/index.d.ts +3 -0
- package/dist/plugin-basic/src/utils/commonUtils.d.ts +3 -0
- package/dist/plugin-basic/src/utils/d3Graphics.d.ts +24 -0
- package/dist/plugin-basic/src/utils/d3Scale.d.ts +28 -0
- package/dist/plugin-basic/src/utils/d3Utils.d.ts +14 -0
- package/dist/plugin-basic/src/utils/graphObservables.d.ts +0 -0
- package/dist/plugin-basic/src/utils/gridObservables.d.ts +51 -0
- package/dist/plugin-basic/src/utils/multivariateObservables.d.ts +74 -0
- package/dist/plugin-basic/src/utils/observables.d.ts +34 -0
- package/dist/plugin-basic/src/utils/orbchartsUtils.d.ts +26 -0
- package/dist/plugin-basic/src/utils/seriesObservables.d.ts +22 -0
- package/dist/plugin-basic/vite.config.d.ts +2 -0
- package/dist/src/index.d.ts +1 -0
- package/package.json +62 -0
- package/src/baseLayers/BaseBars.ts +783 -0
- package/src/baseLayers/BaseBarsTriangle.ts +692 -0
- package/src/baseLayers/BaseCategoryAxis.ts +708 -0
- package/src/baseLayers/BaseDots.ts +495 -0
- package/src/baseLayers/BaseLegend.ts +684 -0
- package/src/baseLayers/BaseLineAreas.ts +644 -0
- package/src/baseLayers/BaseLines.ts +721 -0
- package/src/baseLayers/BaseStackedBars.ts +818 -0
- package/src/baseLayers/BaseTooltip.ts +435 -0
- package/src/baseLayers/BaseValueAxis.ts +612 -0
- package/src/baseLayers/BaseXAxis.ts +412 -0
- package/src/baseLayers/BaseXZoom.ts +250 -0
- package/src/baseLayers/BaseYAxis.ts +371 -0
- package/src/baseLayers/types.ts +174 -0
- package/src/const/layerIndex.ts +36 -0
- package/src/const/sharedPluginParams.ts +29 -0
- package/src/index.ts +3 -0
- package/src/plugins/CompositionPlot/CompositionPlot.ts +308 -0
- package/src/plugins/CompositionPlot/contextObservables.ts +251 -0
- package/src/plugins/CompositionPlot/defaults.ts +162 -0
- package/src/plugins/CompositionPlot/index.ts +3 -0
- package/src/plugins/CompositionPlot/layers/Bubbles.ts +808 -0
- package/src/plugins/CompositionPlot/layers/Indicator.ts +0 -0
- package/src/plugins/CompositionPlot/layers/Pie.ts +776 -0
- package/src/plugins/CompositionPlot/layers/PieEventTexts.ts +326 -0
- package/src/plugins/CompositionPlot/layers/PieLabels.ts +651 -0
- package/src/plugins/CompositionPlot/layers/Rose.ts +546 -0
- package/src/plugins/CompositionPlot/layers/RoseLabels.ts +616 -0
- package/src/plugins/CompositionPlot/layers/Waffle.ts +0 -0
- package/src/plugins/CompositionPlot/types.ts +129 -0
- package/src/plugins/CompositionPlot/utils.ts +53 -0
- package/src/plugins/HierarchyPlot/HierarchyPlot.ts +190 -0
- package/src/plugins/HierarchyPlot/contextObservables.ts +136 -0
- package/src/plugins/HierarchyPlot/defaults.ts +31 -0
- package/src/plugins/HierarchyPlot/index.ts +3 -0
- package/src/plugins/HierarchyPlot/layers/TreeMap.ts +371 -0
- package/src/plugins/HierarchyPlot/types.ts +36 -0
- package/src/plugins/Legend/Legend.ts +151 -0
- package/src/plugins/Legend/contextObservables.ts +55 -0
- package/src/plugins/Legend/defaults.ts +37 -0
- package/src/plugins/Legend/index.ts +3 -0
- package/src/plugins/Legend/layers/Legend.ts +114 -0
- package/src/plugins/Legend/types.ts +45 -0
- package/src/plugins/Legend/utils.ts +53 -0
- package/src/plugins/NetworkPlot/NetworkPlot.ts +228 -0
- package/src/plugins/NetworkPlot/contextObservables.ts +123 -0
- package/src/plugins/NetworkPlot/defaults.ts +147 -0
- package/src/plugins/NetworkPlot/index.ts +3 -0
- package/src/plugins/NetworkPlot/layers/ForceDirected.ts +1048 -0
- package/src/plugins/NetworkPlot/layers/ForceDirectedBubbles.ts +1318 -0
- package/src/plugins/NetworkPlot/types.ts +146 -0
- package/src/plugins/ScatterPlot/ScatterPlot.ts +569 -0
- package/src/plugins/ScatterPlot/contextObservables.ts +901 -0
- package/src/plugins/ScatterPlot/defaults.ts +212 -0
- package/src/plugins/ScatterPlot/index.ts +3 -0
- package/src/plugins/ScatterPlot/layers/Scatter.ts +518 -0
- package/src/plugins/ScatterPlot/layers/ScatterBubbles.ts +670 -0
- package/src/plugins/ScatterPlot/layers/XYAux.ts +686 -0
- package/src/plugins/ScatterPlot/layers/XYAxes.ts +205 -0
- package/src/plugins/ScatterPlot/layers/XZoom.ts +48 -0
- package/src/plugins/ScatterPlot/types.ts +179 -0
- package/src/plugins/SeriesPlot/SeriesPlot.ts +494 -0
- package/src/plugins/SeriesPlot/contextObservables.ts +726 -0
- package/src/plugins/SeriesPlot/defaults.ts +142 -0
- package/src/plugins/SeriesPlot/index.ts +3 -0
- package/src/plugins/SeriesPlot/layers/Bars.ts +84 -0
- package/src/plugins/SeriesPlot/layers/BarsPN.ts +85 -0
- package/src/plugins/SeriesPlot/layers/BarsTriangle.ts +89 -0
- package/src/plugins/SeriesPlot/layers/CategoryAux.ts +1131 -0
- package/src/plugins/SeriesPlot/layers/CategoryAxis.ts +92 -0
- package/src/plugins/SeriesPlot/layers/CategoryZoom.ts +233 -0
- package/src/plugins/SeriesPlot/layers/Dots.ts +91 -0
- package/src/plugins/SeriesPlot/layers/LineAreas.ts +82 -0
- package/src/plugins/SeriesPlot/layers/Lines.ts +75 -0
- package/src/plugins/SeriesPlot/layers/StackedBars.ts +85 -0
- package/src/plugins/SeriesPlot/layers/StackedValueAxis.ts +111 -0
- package/src/plugins/SeriesPlot/layers/ValueAxis.ts +111 -0
- package/src/plugins/SeriesPlot/types.ts +201 -0
- package/src/plugins/Tooltip/Tooltip.ts +159 -0
- package/src/plugins/Tooltip/contextObservables.ts +55 -0
- package/src/plugins/Tooltip/defaults.ts +458 -0
- package/src/plugins/Tooltip/index.ts +3 -0
- package/src/plugins/Tooltip/layers/Tooltip.ts +90 -0
- package/src/plugins/Tooltip/types.ts +55 -0
- package/src/plugins/Tooltip/utils.ts +53 -0
- package/src/plugins/index.ts +8 -0
- package/src/types/BaseLayer.ts +3 -0
- package/src/types/Common.ts +20 -0
- package/src/types/ComputedData.ts +55 -0
- package/src/types/PluginParams.ts +81 -0
- package/src/types/index.ts +3 -0
- package/src/utils/commonUtils.ts +31 -0
- package/src/utils/d3Graphics.ts +177 -0
- package/src/utils/d3Scale.ts +198 -0
- package/src/utils/d3Utils.ts +92 -0
- package/src/utils/graphObservables.ts +0 -0
- package/src/utils/gridObservables.ts +637 -0
- package/src/utils/multivariateObservables.ts +790 -0
- package/src/utils/observables.ts +357 -0
- package/src/utils/orbchartsUtils.ts +335 -0
- package/src/utils/seriesObservables.ts +172 -0
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import * as d3 from 'd3'
|
|
2
|
+
import {
|
|
3
|
+
Subject,
|
|
4
|
+
Observable,
|
|
5
|
+
map,
|
|
6
|
+
distinctUntilChanged,
|
|
7
|
+
shareReplay,
|
|
8
|
+
takeUntil
|
|
9
|
+
} from 'rxjs'
|
|
10
|
+
import type { StackedValueAxisParams, SeriesPlotPluginParams } from '../types'
|
|
11
|
+
import { DEFAULT_STACKED_VALUE_AXIS_PARAMS } from '../defaults'
|
|
12
|
+
import { LAYER_INDEX_OF_AXIS } from '../../../const/layerIndex'
|
|
13
|
+
import { defineSVGLayer } from '@orbcharts/core'
|
|
14
|
+
import { SeriesPlotExtendContext } from '../types'
|
|
15
|
+
import { validateObject } from '@orbcharts/core'
|
|
16
|
+
import { createBaseValueAxis } from '../../../baseLayers/BaseValueAxis'
|
|
17
|
+
|
|
18
|
+
const pluginName = 'SeriesPlot'
|
|
19
|
+
const layerName = 'StackedValueAxis'
|
|
20
|
+
|
|
21
|
+
export const StackedValueAxis = defineSVGLayer<SeriesPlotExtendContext, SeriesPlotPluginParams, StackedValueAxisParams>({
|
|
22
|
+
name: layerName,
|
|
23
|
+
defaultParams: DEFAULT_STACKED_VALUE_AXIS_PARAMS,
|
|
24
|
+
layerIndex: LAYER_INDEX_OF_AXIS,
|
|
25
|
+
initShow: false,
|
|
26
|
+
validator: (params) => {
|
|
27
|
+
const result = validateObject(params, {
|
|
28
|
+
labelOffset: {
|
|
29
|
+
toBe: '[number, number]',
|
|
30
|
+
test: (value: any) => {
|
|
31
|
+
return Array.isArray(value)
|
|
32
|
+
&& value.length === 2
|
|
33
|
+
&& typeof value[0] === 'number'
|
|
34
|
+
&& typeof value[1] === 'number'
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
labelColorType: {
|
|
38
|
+
toBeOption: 'ColorType',
|
|
39
|
+
},
|
|
40
|
+
axisLineVisible: {
|
|
41
|
+
toBeTypes: ['boolean']
|
|
42
|
+
},
|
|
43
|
+
axisLineColorType: {
|
|
44
|
+
toBeOption: 'ColorType',
|
|
45
|
+
},
|
|
46
|
+
ticks: {
|
|
47
|
+
toBeTypes: ['number', 'null']
|
|
48
|
+
},
|
|
49
|
+
tickFormat: {
|
|
50
|
+
toBeTypes: ['string', 'Function']
|
|
51
|
+
},
|
|
52
|
+
tickLineVisible: {
|
|
53
|
+
toBeTypes: ['boolean']
|
|
54
|
+
},
|
|
55
|
+
tickPadding: {
|
|
56
|
+
toBeTypes: ['number']
|
|
57
|
+
},
|
|
58
|
+
tickFullLine: {
|
|
59
|
+
toBeTypes: ['boolean']
|
|
60
|
+
},
|
|
61
|
+
tickFullLineDasharray: {
|
|
62
|
+
toBeTypes: ['string']
|
|
63
|
+
},
|
|
64
|
+
tickColorType: {
|
|
65
|
+
toBeOption: 'ColorType',
|
|
66
|
+
},
|
|
67
|
+
tickTextRotate: {
|
|
68
|
+
toBeTypes: ['number']
|
|
69
|
+
},
|
|
70
|
+
tickTextColorType: {
|
|
71
|
+
toBeOption: 'ColorType',
|
|
72
|
+
}
|
|
73
|
+
})
|
|
74
|
+
return result
|
|
75
|
+
},
|
|
76
|
+
setup: ({ svgG, pluginParams$, layerParams$, context }) => {
|
|
77
|
+
|
|
78
|
+
const destroy$ = new Subject()
|
|
79
|
+
|
|
80
|
+
context.layout$
|
|
81
|
+
.pipe(
|
|
82
|
+
takeUntil(destroy$)
|
|
83
|
+
)
|
|
84
|
+
.subscribe(layout => {
|
|
85
|
+
d3.select(svgG)
|
|
86
|
+
.attr('transform', `translate(${layout.left}, ${layout.top})`)
|
|
87
|
+
})
|
|
88
|
+
|
|
89
|
+
const unsubscribeBaseValueAxis = createBaseValueAxis({
|
|
90
|
+
selection: d3.select(svgG),
|
|
91
|
+
pluginName,
|
|
92
|
+
layerName,
|
|
93
|
+
computedData$: context.computedStackedData$, // 計算疊加value的資料
|
|
94
|
+
filteredMinMaxValue$: context.filteredStackedMinMaxValue$,
|
|
95
|
+
baseValueAxisParams$: layerParams$,
|
|
96
|
+
categoryAxis$: pluginParams$.pipe(map(params => params.categoryAxis)),
|
|
97
|
+
valueAxis$: pluginParams$.pipe(map(params => params.valueAxis)),
|
|
98
|
+
theme$: context.theme$,
|
|
99
|
+
gridAxesTransform$: context.gridAxesTransform$,
|
|
100
|
+
gridAxesReverseTransform$: context.gridAxesReverseTransform$,
|
|
101
|
+
gridAxesSize$: context.gridAxesSize$,
|
|
102
|
+
gridContainerPosition$: context.gridContainerPosition$,
|
|
103
|
+
isSeriesSeprate$: context.isSeriesSeprate$,
|
|
104
|
+
})
|
|
105
|
+
|
|
106
|
+
return () => {
|
|
107
|
+
destroy$.next(undefined)
|
|
108
|
+
unsubscribeBaseValueAxis()
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
})
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import * as d3 from 'd3'
|
|
2
|
+
import {
|
|
3
|
+
Subject,
|
|
4
|
+
Observable,
|
|
5
|
+
map,
|
|
6
|
+
distinctUntilChanged,
|
|
7
|
+
shareReplay,
|
|
8
|
+
takeUntil
|
|
9
|
+
} from 'rxjs'
|
|
10
|
+
import type { ValueAxisParams, SeriesPlotPluginParams } from '../types'
|
|
11
|
+
import { DEFAULT_VALUE_AXIS_PARAMS } from '../defaults'
|
|
12
|
+
import { LAYER_INDEX_OF_AXIS } from '../../../const/layerIndex'
|
|
13
|
+
import { defineSVGLayer } from '@orbcharts/core'
|
|
14
|
+
import { SeriesPlotExtendContext } from '../types'
|
|
15
|
+
import { validateObject } from '@orbcharts/core'
|
|
16
|
+
import { createBaseValueAxis } from '../../../baseLayers/BaseValueAxis'
|
|
17
|
+
|
|
18
|
+
const pluginName = 'SeriesPlot'
|
|
19
|
+
const layerName = 'ValueAxis'
|
|
20
|
+
|
|
21
|
+
export const ValueAxis = defineSVGLayer<SeriesPlotExtendContext, SeriesPlotPluginParams, ValueAxisParams>({
|
|
22
|
+
name: layerName,
|
|
23
|
+
defaultParams: DEFAULT_VALUE_AXIS_PARAMS,
|
|
24
|
+
layerIndex: LAYER_INDEX_OF_AXIS,
|
|
25
|
+
initShow: false,
|
|
26
|
+
validator: (params) => {
|
|
27
|
+
const result = validateObject(params, {
|
|
28
|
+
labelOffset: {
|
|
29
|
+
toBe: '[number, number]',
|
|
30
|
+
test: (value: any) => {
|
|
31
|
+
return Array.isArray(value)
|
|
32
|
+
&& value.length === 2
|
|
33
|
+
&& typeof value[0] === 'number'
|
|
34
|
+
&& typeof value[1] === 'number'
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
labelColorType: {
|
|
38
|
+
toBeOption: 'ColorType',
|
|
39
|
+
},
|
|
40
|
+
axisLineVisible: {
|
|
41
|
+
toBeTypes: ['boolean']
|
|
42
|
+
},
|
|
43
|
+
axisLineColorType: {
|
|
44
|
+
toBeOption: 'ColorType',
|
|
45
|
+
},
|
|
46
|
+
ticks: {
|
|
47
|
+
toBeTypes: ['number', 'null']
|
|
48
|
+
},
|
|
49
|
+
tickFormat: {
|
|
50
|
+
toBeTypes: ['string', 'Function']
|
|
51
|
+
},
|
|
52
|
+
tickLineVisible: {
|
|
53
|
+
toBeTypes: ['boolean']
|
|
54
|
+
},
|
|
55
|
+
tickPadding: {
|
|
56
|
+
toBeTypes: ['number']
|
|
57
|
+
},
|
|
58
|
+
tickFullLine: {
|
|
59
|
+
toBeTypes: ['boolean']
|
|
60
|
+
},
|
|
61
|
+
tickFullLineDasharray: {
|
|
62
|
+
toBeTypes: ['string']
|
|
63
|
+
},
|
|
64
|
+
tickColorType: {
|
|
65
|
+
toBeOption: 'ColorType',
|
|
66
|
+
},
|
|
67
|
+
tickTextRotate: {
|
|
68
|
+
toBeTypes: ['number']
|
|
69
|
+
},
|
|
70
|
+
tickTextColorType: {
|
|
71
|
+
toBeOption: 'ColorType',
|
|
72
|
+
}
|
|
73
|
+
})
|
|
74
|
+
return result
|
|
75
|
+
},
|
|
76
|
+
setup: ({ svgG, pluginParams$, layerParams$, context }) => {
|
|
77
|
+
|
|
78
|
+
const destroy$ = new Subject()
|
|
79
|
+
|
|
80
|
+
context.layout$
|
|
81
|
+
.pipe(
|
|
82
|
+
takeUntil(destroy$)
|
|
83
|
+
)
|
|
84
|
+
.subscribe(layout => {
|
|
85
|
+
d3.select(svgG)
|
|
86
|
+
.attr('transform', `translate(${layout.left}, ${layout.top})`)
|
|
87
|
+
})
|
|
88
|
+
|
|
89
|
+
const unsubscribeBaseValueAxis = createBaseValueAxis({
|
|
90
|
+
selection: d3.select(svgG),
|
|
91
|
+
pluginName,
|
|
92
|
+
layerName,
|
|
93
|
+
computedData$: context.computedData$,
|
|
94
|
+
filteredMinMaxValue$: context.filteredMinMaxValue$,
|
|
95
|
+
baseValueAxisParams$: layerParams$,
|
|
96
|
+
categoryAxis$: pluginParams$.pipe(map(params => params.categoryAxis)),
|
|
97
|
+
valueAxis$: pluginParams$.pipe(map(params => params.valueAxis)),
|
|
98
|
+
theme$: context.theme$,
|
|
99
|
+
gridAxesTransform$: context.gridAxesTransform$,
|
|
100
|
+
gridAxesReverseTransform$: context.gridAxesReverseTransform$,
|
|
101
|
+
gridAxesSize$: context.gridAxesSize$,
|
|
102
|
+
gridContainerPosition$: context.gridContainerPosition$,
|
|
103
|
+
isSeriesSeprate$: context.isSeriesSeprate$,
|
|
104
|
+
})
|
|
105
|
+
|
|
106
|
+
return () => {
|
|
107
|
+
destroy$.next(undefined)
|
|
108
|
+
unsubscribeBaseValueAxis()
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
})
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
|
|
2
|
+
import { Observable, Subject } from 'rxjs'
|
|
3
|
+
import type { ColorType, ModelDatumSeries, EventData } from '@orbcharts/core'
|
|
4
|
+
import type { AxisPosition, ContainerPosition, ContainerPositionScaled, Container, GraphicStyles, Layout, VisibleFilter, ValueAxis, CategoryAxis } from '../../types/PluginParams'
|
|
5
|
+
import { ComputedDatumGrid, } from '../../types/ComputedData'
|
|
6
|
+
import type { ContainerSize, Placement, TransformData } from '../../types/Common'
|
|
7
|
+
import { BaseTooltipStyle, BaseTooltipUtils } from '../../baseLayers/types'
|
|
8
|
+
|
|
9
|
+
// context
|
|
10
|
+
export interface ComputedLayoutDatumGrid extends ComputedDatumGrid {
|
|
11
|
+
axisX: number
|
|
12
|
+
axisY: number
|
|
13
|
+
axisYFromZero: number
|
|
14
|
+
}
|
|
15
|
+
export type ComputedAxesDataGrid = ComputedLayoutDatumGrid[][]
|
|
16
|
+
|
|
17
|
+
export interface SeriesPlotExtendContext {
|
|
18
|
+
layout$: Observable<Layout>
|
|
19
|
+
computedData$: Observable<ComputedDatumGrid[][]>
|
|
20
|
+
fontSizePx$: Observable<number>
|
|
21
|
+
containerSize$: Observable<ContainerSize>
|
|
22
|
+
gridHighlight$: Observable<ComputedDatumGrid[]>
|
|
23
|
+
|
|
24
|
+
isSeriesSeprate$: Observable<boolean>
|
|
25
|
+
gridContainerPosition$: Observable<ContainerPositionScaled[]>
|
|
26
|
+
gridAxesSize$: Observable<ContainerSize> // 軸轉後的尺寸
|
|
27
|
+
gridAxesContainerSize$: Observable<ContainerSize> // 軸轉後的container尺寸
|
|
28
|
+
seriesLabels$: Observable<string[]>
|
|
29
|
+
SeriesDataMap$: Observable<Map<string, ComputedDatumGrid[]>>
|
|
30
|
+
CategoryDataMap$: Observable<Map<string, ComputedDatumGrid[]>>
|
|
31
|
+
computedAxesData$: Observable<ComputedAxesDataGrid> // 有座標的資料
|
|
32
|
+
visibleComputedData$: Observable<ComputedDatumGrid[][]> // filter掉visible=false的資料
|
|
33
|
+
visibleComputedAxesData$: Observable<ComputedAxesDataGrid>
|
|
34
|
+
computedStackedData$: Observable<ComputedDatumGrid[][]>
|
|
35
|
+
categoryScaleDomainValue$: Observable<[number, number]>
|
|
36
|
+
filteredMinMaxValue$: Observable<[number, number]>
|
|
37
|
+
filteredStackedMinMaxValue$: Observable<[number, number]>
|
|
38
|
+
gridAxesTransform$: Observable<TransformData>
|
|
39
|
+
gridAxesReverseTransform$: Observable<TransformData>
|
|
40
|
+
gridGraphicTransform$: Observable<TransformData>
|
|
41
|
+
gridGraphicReverseScale$: Observable<[number, number][]>
|
|
42
|
+
zoomedCategoryAxis$: Observable<CategoryAxis>
|
|
43
|
+
// updateScaleDomain$: Subject<[number, number | "max"]> // zoom後要更新categoryAxis的scaleDomain
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// plugin params
|
|
47
|
+
// export type SeriesDirection = 'row' | 'column' // default: 'row'
|
|
48
|
+
|
|
49
|
+
// export interface ValueAxis {
|
|
50
|
+
// position: AxisPosition
|
|
51
|
+
// /* scaleDomain說明
|
|
52
|
+
// * [0] => min: 最小值, 'auto': 取最小值,但若大於0則保持為0
|
|
53
|
+
// * [1] => max: 最大值, 'auto': 取最大值,但若小於0則保持為0
|
|
54
|
+
// */
|
|
55
|
+
// scaleDomain: [number | 'min' | 'auto', number | 'max' | 'auto']
|
|
56
|
+
// scaleRange: [number, number]
|
|
57
|
+
// label: string
|
|
58
|
+
// }
|
|
59
|
+
|
|
60
|
+
// export interface CategoryAxis {
|
|
61
|
+
// position: AxisPosition
|
|
62
|
+
// scaleDomain: [number, number | 'max']
|
|
63
|
+
// scalePadding: number
|
|
64
|
+
// label: string
|
|
65
|
+
// }
|
|
66
|
+
|
|
67
|
+
export interface SeriesPlotPluginParams {
|
|
68
|
+
styles: GraphicStyles
|
|
69
|
+
visibleFilter: VisibleFilter<'grid'>
|
|
70
|
+
container: Container
|
|
71
|
+
// seriesDirection: SeriesDirection
|
|
72
|
+
// rowLabels: string[]
|
|
73
|
+
// columnLabels: string[]
|
|
74
|
+
valueAxis: ValueAxis
|
|
75
|
+
categoryAxis: CategoryAxis
|
|
76
|
+
separateSeries: boolean
|
|
77
|
+
datasetIndex: number
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// all layer params
|
|
81
|
+
export interface SeriesPlotAllLayerParams {
|
|
82
|
+
Lines: LinesParams
|
|
83
|
+
LineAreas: LineAreasParams
|
|
84
|
+
Dots: DotsParams
|
|
85
|
+
CategoryAux: CategoryAuxParams
|
|
86
|
+
Bars: BarsParams
|
|
87
|
+
BarsPN: BarsPNParams
|
|
88
|
+
StackedBars: StackedBarsParams
|
|
89
|
+
BarsTriangle: BarsTriangleParams
|
|
90
|
+
CategoryAxis: CategoryAxisParams
|
|
91
|
+
ValueAxis: ValueAxisParams
|
|
92
|
+
StackedValueAxis: StackedValueAxisParams
|
|
93
|
+
CategoryZoom: CategoryZoomParams
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// -- layer params --
|
|
97
|
+
export interface LinesParams {
|
|
98
|
+
lineCurve: string
|
|
99
|
+
lineWidth: number
|
|
100
|
+
// labelFn: (d: ComputedDatumSeries) => string
|
|
101
|
+
// labelPositionFn: (d: ComputedDatumSeries) => 'top' | 'bottom' | 'left' | 'right' | 'center'
|
|
102
|
+
// labelStyleFn: (d: ComputedDatumSeries) => string
|
|
103
|
+
// labelFontSizeFn: (d: ComputedDatumSeries) => number
|
|
104
|
+
// labelColorFn: (d: ComputedDatumSeries) => string
|
|
105
|
+
// labelPadding: number
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export interface LineAreasParams {
|
|
109
|
+
lineCurve: string
|
|
110
|
+
linearGradientOpacity: [number, number]
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export interface DotsParams {
|
|
114
|
+
radius: number
|
|
115
|
+
fillColorType: ColorType
|
|
116
|
+
strokeColorType: ColorType
|
|
117
|
+
strokeWidth: number
|
|
118
|
+
// strokeWidthWhileHighlight: number
|
|
119
|
+
onlyShowHighlighted: boolean
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export interface CategoryAuxParams {
|
|
123
|
+
showLine: boolean
|
|
124
|
+
showLabel: boolean
|
|
125
|
+
lineDashArray: string
|
|
126
|
+
lineColorType: ColorType
|
|
127
|
+
labelColorType: ColorType
|
|
128
|
+
labelTextColorType: ColorType
|
|
129
|
+
labelTextFormat: string | ((text: any) => string)
|
|
130
|
+
labelPadding: number
|
|
131
|
+
labelRotate: number
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export interface BarsParams {
|
|
135
|
+
// barType: BarType
|
|
136
|
+
barWidth: number
|
|
137
|
+
barPadding: number
|
|
138
|
+
barGroupPadding: number // 群組和群組間的間隔
|
|
139
|
+
barRadius: number | boolean
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
export interface BarsPNParams extends BarsParams {}
|
|
143
|
+
|
|
144
|
+
export interface StackedBarsParams {
|
|
145
|
+
barWidth: number
|
|
146
|
+
barGroupPadding: number
|
|
147
|
+
barRadius: number | boolean
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
export interface BarsTriangleParams {
|
|
151
|
+
barWidth: number
|
|
152
|
+
barPadding: number
|
|
153
|
+
barGroupPadding: number // 群組和群組間的間隔
|
|
154
|
+
linearGradientOpacity: [number, number]
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
export interface CategoryAxisParams {
|
|
158
|
+
// xLabel: string
|
|
159
|
+
// labelAnchor: 'start' | 'end'
|
|
160
|
+
labelOffset: [number, number]
|
|
161
|
+
labelColorType: ColorType
|
|
162
|
+
axisLineVisible: boolean
|
|
163
|
+
axisLineColorType: ColorType
|
|
164
|
+
ticks: number | null | 'all'
|
|
165
|
+
tickFormat: string | ((text: any) => string | d3.NumberValue)
|
|
166
|
+
tickLineVisible: boolean
|
|
167
|
+
tickPadding: number
|
|
168
|
+
tickFullLine: boolean
|
|
169
|
+
tickFullLineDasharray: string
|
|
170
|
+
tickColorType: ColorType
|
|
171
|
+
// axisLineColor: string
|
|
172
|
+
// axisLabelColor: string
|
|
173
|
+
tickTextRotate: number
|
|
174
|
+
tickTextColorType: ColorType
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
export interface ValueAxisParams {
|
|
178
|
+
// xLabel: string
|
|
179
|
+
// labelAnchor: 'start' | 'end'
|
|
180
|
+
labelOffset: [number, number]
|
|
181
|
+
labelColorType: ColorType
|
|
182
|
+
axisLineVisible: boolean
|
|
183
|
+
axisLineColorType: ColorType
|
|
184
|
+
ticks: number | null
|
|
185
|
+
tickFormat: string | ((text: d3.NumberValue) => string | d3.NumberValue)
|
|
186
|
+
tickLineVisible: boolean
|
|
187
|
+
tickPadding: number
|
|
188
|
+
tickFullLine: boolean
|
|
189
|
+
tickFullLineDasharray: string
|
|
190
|
+
tickColorType: ColorType
|
|
191
|
+
// axisLineColor: string
|
|
192
|
+
// axisLabelColor: string
|
|
193
|
+
tickTextRotate: number
|
|
194
|
+
tickTextColorType: ColorType
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
export interface StackedValueAxisParams extends ValueAxisParams {}
|
|
198
|
+
|
|
199
|
+
export interface CategoryZoomParams {
|
|
200
|
+
|
|
201
|
+
}
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import {
|
|
2
|
+
shareReplay,
|
|
3
|
+
map,
|
|
4
|
+
combineLatest,
|
|
5
|
+
debounceTime} from 'rxjs'
|
|
6
|
+
|
|
7
|
+
import type { TooltipExtendContext, TooltipPluginParams, TooltipAllLayerParams } from './types'
|
|
8
|
+
import { defineSVGPlugin } from '@orbcharts/core'
|
|
9
|
+
import { validateObject } from '@orbcharts/core'
|
|
10
|
+
import { DEFAULT_SERIES_TOOLTIP_PLUGIN_PARAMS } from './defaults'
|
|
11
|
+
import {
|
|
12
|
+
layoutObservable,
|
|
13
|
+
fontSizePxObservable,
|
|
14
|
+
seriesDataMapObservable,
|
|
15
|
+
categoryDataMapObservable
|
|
16
|
+
} from '../../utils/observables'
|
|
17
|
+
import {
|
|
18
|
+
seriesComputedDataObservable,
|
|
19
|
+
} from './contextObservables'
|
|
20
|
+
import { Tooltip as TooltipLayer } from './layers/Tooltip'
|
|
21
|
+
|
|
22
|
+
const seriesTooltip = new TooltipLayer()
|
|
23
|
+
|
|
24
|
+
export const Tooltip = defineSVGPlugin<
|
|
25
|
+
TooltipExtendContext,
|
|
26
|
+
TooltipPluginParams,
|
|
27
|
+
TooltipAllLayerParams
|
|
28
|
+
>({
|
|
29
|
+
name: 'Tooltip',
|
|
30
|
+
defaultParams: DEFAULT_SERIES_TOOLTIP_PLUGIN_PARAMS,
|
|
31
|
+
layers: [seriesTooltip],
|
|
32
|
+
setup: (props) => {
|
|
33
|
+
|
|
34
|
+
const selectedSeriesData$ = combineLatest({
|
|
35
|
+
seriesData: props.context.seriesData$,
|
|
36
|
+
datasetIndex: props.pluginParams$.pipe(
|
|
37
|
+
map(pluginParams => pluginParams.datasetIndex)
|
|
38
|
+
)
|
|
39
|
+
}).pipe(
|
|
40
|
+
debounceTime(0),
|
|
41
|
+
map(({ seriesData, datasetIndex }) => seriesData[datasetIndex]),
|
|
42
|
+
shareReplay(1)
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
const layout$ = layoutObservable({
|
|
46
|
+
size$: props.context.size$,
|
|
47
|
+
padding$: props.pluginParams$.pipe(
|
|
48
|
+
map(pluginParams => pluginParams.styles.padding)
|
|
49
|
+
)
|
|
50
|
+
}).pipe(
|
|
51
|
+
shareReplay(1)
|
|
52
|
+
)
|
|
53
|
+
|
|
54
|
+
// const layoutSubscription = layout$.subscribe(layout => {
|
|
55
|
+
// props.svg.setAttribute('transform', `translate(${layout.left}, ${layout.top})`)
|
|
56
|
+
// })
|
|
57
|
+
|
|
58
|
+
const computedData$ = seriesComputedDataObservable({
|
|
59
|
+
selectedSeriesData$,
|
|
60
|
+
pluginParams$: props.pluginParams$
|
|
61
|
+
}).pipe(
|
|
62
|
+
shareReplay(1)
|
|
63
|
+
)
|
|
64
|
+
|
|
65
|
+
const fontSizePx$ = fontSizePxObservable(props.context.theme$).pipe(
|
|
66
|
+
shareReplay(1)
|
|
67
|
+
)
|
|
68
|
+
|
|
69
|
+
const datumList$ = computedData$.pipe(
|
|
70
|
+
map(d => d.flat())
|
|
71
|
+
).pipe(
|
|
72
|
+
shareReplay(1)
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
const SeriesDataMap$ = seriesDataMapObservable({
|
|
76
|
+
datumList$
|
|
77
|
+
}).pipe(
|
|
78
|
+
shareReplay(1)
|
|
79
|
+
)
|
|
80
|
+
|
|
81
|
+
const CategoryDataMap$ = categoryDataMapObservable({
|
|
82
|
+
datumList$: datumList$
|
|
83
|
+
}).pipe(
|
|
84
|
+
shareReplay(1)
|
|
85
|
+
)
|
|
86
|
+
|
|
87
|
+
const extendsContext: TooltipExtendContext = {
|
|
88
|
+
layout$,
|
|
89
|
+
fontSizePx$,
|
|
90
|
+
SeriesDataMap$,
|
|
91
|
+
CategoryDataMap$,
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
props.context = {
|
|
95
|
+
...props.context,
|
|
96
|
+
...extendsContext,
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
return () => {
|
|
100
|
+
// layoutSubscription.unsubscribe()
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
validator: (params: TooltipPluginParams) => {
|
|
104
|
+
const result = validateObject(params, {
|
|
105
|
+
styles: {
|
|
106
|
+
toBeTypes: ['object'],
|
|
107
|
+
},
|
|
108
|
+
datasetIndex: {
|
|
109
|
+
toBeTypes: ['number']
|
|
110
|
+
}
|
|
111
|
+
})
|
|
112
|
+
if (params.styles) {
|
|
113
|
+
const stylesResult = validateObject(params.styles, {
|
|
114
|
+
padding: {
|
|
115
|
+
toBeTypes: ['object']
|
|
116
|
+
},
|
|
117
|
+
highlightTarget: {
|
|
118
|
+
toBeTypes: ['string']
|
|
119
|
+
},
|
|
120
|
+
highlightDefault: {
|
|
121
|
+
toBeTypes: ['string', 'null']
|
|
122
|
+
},
|
|
123
|
+
unhighlightedOpacity: {
|
|
124
|
+
toBeTypes: ['number']
|
|
125
|
+
},
|
|
126
|
+
transitionDuration: {
|
|
127
|
+
toBeTypes: ['number']
|
|
128
|
+
},
|
|
129
|
+
transitionEase: {
|
|
130
|
+
toBeTypes: ['string']
|
|
131
|
+
}
|
|
132
|
+
})
|
|
133
|
+
if (stylesResult.status === 'error') {
|
|
134
|
+
return stylesResult
|
|
135
|
+
}
|
|
136
|
+
if (params.styles.padding) {
|
|
137
|
+
const paddingResult = validateObject(params.styles.padding, {
|
|
138
|
+
top: {
|
|
139
|
+
toBeTypes: ['number']
|
|
140
|
+
},
|
|
141
|
+
right: {
|
|
142
|
+
toBeTypes: ['number']
|
|
143
|
+
},
|
|
144
|
+
bottom: {
|
|
145
|
+
toBeTypes: ['number']
|
|
146
|
+
},
|
|
147
|
+
left: {
|
|
148
|
+
toBeTypes: ['number']
|
|
149
|
+
}
|
|
150
|
+
})
|
|
151
|
+
if (paddingResult.status === 'error') {
|
|
152
|
+
return paddingResult
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
return result
|
|
158
|
+
},
|
|
159
|
+
})
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import {
|
|
2
|
+
combineLatest,
|
|
3
|
+
distinctUntilChanged,
|
|
4
|
+
debounceTime,
|
|
5
|
+
filter,
|
|
6
|
+
map,
|
|
7
|
+
merge,
|
|
8
|
+
takeUntil,
|
|
9
|
+
shareReplay,
|
|
10
|
+
switchMap,
|
|
11
|
+
Subject,
|
|
12
|
+
Observable
|
|
13
|
+
} from 'rxjs'
|
|
14
|
+
import type {
|
|
15
|
+
ModelDataSeries,
|
|
16
|
+
} from '@orbcharts/core'
|
|
17
|
+
import type { TooltipPluginParams } from './types'
|
|
18
|
+
import type { ComputedDatumSeries } from '../../types/ComputedData'
|
|
19
|
+
|
|
20
|
+
export const seriesComputedDataObservable = ({ selectedSeriesData$, pluginParams$ }: {
|
|
21
|
+
selectedSeriesData$: Observable<ModelDataSeries>
|
|
22
|
+
pluginParams$: Observable<TooltipPluginParams>
|
|
23
|
+
}): Observable<ComputedDatumSeries[][]> => {
|
|
24
|
+
return combineLatest({
|
|
25
|
+
selectedSeriesData: selectedSeriesData$,
|
|
26
|
+
pluginParams: pluginParams$
|
|
27
|
+
}).pipe(
|
|
28
|
+
debounceTime(0),
|
|
29
|
+
map(({ selectedSeriesData, pluginParams }) => {
|
|
30
|
+
return selectedSeriesData
|
|
31
|
+
// 攤為一維陣列
|
|
32
|
+
.flat()
|
|
33
|
+
// 排序後給 seq
|
|
34
|
+
.sort(pluginParams.sort ?? undefined)
|
|
35
|
+
.map((datum, index) => {
|
|
36
|
+
const visibleFilter = pluginParams.visibleFilter
|
|
37
|
+
return {
|
|
38
|
+
...datum,
|
|
39
|
+
visible: visibleFilter ? visibleFilter(datum) : true,
|
|
40
|
+
seq: index
|
|
41
|
+
}
|
|
42
|
+
})
|
|
43
|
+
// 恢復原排序
|
|
44
|
+
.sort((a, b) => a.index - b.index)
|
|
45
|
+
// 依seriesIndex分組(二維陣列)
|
|
46
|
+
.reduce((acc, datum) => {
|
|
47
|
+
if (!acc[datum.seriesIndex]) {
|
|
48
|
+
acc[datum.seriesIndex] = []
|
|
49
|
+
}
|
|
50
|
+
acc[datum.seriesIndex].push(datum)
|
|
51
|
+
return acc
|
|
52
|
+
}, [])
|
|
53
|
+
})
|
|
54
|
+
)
|
|
55
|
+
}
|