@orbcharts/core 3.0.0-alpha.61 → 3.0.0-alpha.63
Sign up to get free protection for your applications and to get access to all the features.
- package/LICENSE +200 -200
- package/dist/lib/core-types.d.ts +1 -0
- package/dist/orbcharts-core.es.js +3418 -2726
- package/dist/orbcharts-core.umd.js +6 -2
- package/dist/src/AbstractChart.d.ts +5 -3
- package/dist/src/GridChart.d.ts +1 -1
- package/dist/src/MultiGridChart.d.ts +1 -1
- package/dist/src/MultiValueChart.d.ts +1 -1
- package/dist/src/RelationshipChart.d.ts +1 -1
- package/dist/src/SeriesChart.d.ts +1 -1
- package/dist/src/TreeChart.d.ts +1 -1
- package/dist/src/base/createBaseChart.d.ts +1 -1
- package/dist/src/base/createBasePlugin.d.ts +1 -1
- package/dist/src/base/validators/chartOptionsValidator.d.ts +3 -0
- package/dist/src/base/validators/chartParamsValidator.d.ts +3 -0
- package/dist/src/base/validators/elementValidator.d.ts +3 -0
- package/dist/src/base/validators/pluginsValidator.d.ts +3 -0
- package/dist/src/defaults.d.ts +1 -16
- package/dist/src/defineGridPlugin.d.ts +1 -1
- package/dist/src/defineMultiGridPlugin.d.ts +1 -1
- package/dist/src/defineMultiValuePlugin.d.ts +1 -1
- package/dist/src/defineNoneDataPlugin.d.ts +1 -1
- package/dist/src/defineRelationshipPlugin.d.ts +1 -1
- package/dist/src/defineSeriesPlugin.d.ts +1 -1
- package/dist/src/defineTreePlugin.d.ts +1 -1
- package/dist/src/grid/computedDataFn.d.ts +4 -0
- package/dist/src/grid/contextObserverCallback.d.ts +3 -0
- package/dist/src/grid/dataFormatterValidator.d.ts +3 -0
- package/dist/src/grid/dataValidator.d.ts +3 -0
- package/dist/src/index.d.ts +1 -1
- package/dist/src/multiGrid/computedDataFn.d.ts +3 -0
- package/dist/src/multiGrid/contextObserverCallback.d.ts +3 -0
- package/dist/src/multiGrid/dataFormatterValidator.d.ts +3 -0
- package/dist/src/multiGrid/dataValidator.d.ts +3 -0
- package/dist/src/multiValue/computedDataFn.d.ts +3 -0
- package/dist/src/multiValue/contextObserverCallback.d.ts +3 -0
- package/dist/src/multiValue/dataFormatterValidator.d.ts +3 -0
- package/dist/src/multiValue/dataValidator.d.ts +3 -0
- package/dist/src/relationship/computedDataFn.d.ts +3 -0
- package/dist/src/relationship/contextObserverCallback.d.ts +3 -0
- package/dist/src/relationship/dataFormatterValidator.d.ts +3 -0
- package/dist/src/relationship/dataValidator.d.ts +3 -0
- package/dist/src/series/computedDataFn.d.ts +3 -0
- package/dist/src/series/contextObserverCallback.d.ts +3 -0
- package/dist/src/series/dataFormatterValidator.d.ts +3 -0
- package/dist/src/series/dataValidator.d.ts +3 -0
- package/dist/src/tree/computedDataFn.d.ts +3 -0
- package/dist/src/tree/contextObserverCallback.d.ts +3 -0
- package/dist/src/tree/dataFormatterValidator.d.ts +3 -0
- package/dist/src/tree/dataValidator.d.ts +3 -0
- package/dist/src/utils/commonUtils.d.ts +1 -0
- package/dist/src/utils/errorMessage.d.ts +14 -0
- package/dist/src/{grid → utils}/gridObservables.d.ts +2 -2
- package/dist/src/utils/index.d.ts +7 -3
- package/dist/src/{multiGrid → utils}/multiGridObservables.d.ts +1 -1
- package/dist/src/utils/observables.d.ts +2 -1
- package/dist/src/utils/orbchartsUtils.d.ts +1 -12
- package/dist/src/{series → utils}/seriesObservables.d.ts +3 -3
- package/dist/src/{tree → utils}/treeObservables.d.ts +1 -1
- package/dist/src/utils/validator.d.ts +3 -0
- package/lib/core-types.ts +7 -0
- package/package.json +42 -41
- package/src/AbstractChart.ts +57 -48
- package/src/GridChart.ts +24 -20
- package/src/MultiGridChart.ts +24 -20
- package/src/MultiValueChart.ts +24 -20
- package/src/RelationshipChart.ts +24 -20
- package/src/SeriesChart.ts +24 -20
- package/src/TreeChart.ts +24 -20
- package/src/base/createBaseChart.ts +500 -388
- package/src/base/createBasePlugin.ts +152 -95
- package/src/base/validators/chartOptionsValidator.ts +24 -0
- package/src/base/validators/chartParamsValidator.ts +134 -0
- package/src/base/validators/elementValidator.ts +14 -0
- package/src/base/validators/pluginsValidator.ts +15 -0
- package/src/defaults.ts +232 -228
- package/src/defineGridPlugin.ts +3 -3
- package/src/defineMultiGridPlugin.ts +3 -3
- package/src/defineMultiValuePlugin.ts +3 -3
- package/src/defineNoneDataPlugin.ts +4 -4
- package/src/defineRelationshipPlugin.ts +3 -3
- package/src/defineSeriesPlugin.ts +3 -3
- package/src/defineTreePlugin.ts +3 -3
- package/src/grid/{computeGridData.ts → computedDataFn.ts} +129 -134
- package/src/grid/{createGridContextObserver.ts → contextObserverCallback.ts} +155 -155
- package/src/grid/dataFormatterValidator.ts +102 -0
- package/src/grid/dataValidator.ts +13 -0
- package/src/index.ts +20 -21
- package/src/multiGrid/{computeMultiGridData.ts → computedDataFn.ts} +123 -130
- package/src/multiGrid/{createMultiGridContextObserver.ts → contextObserverCallback.ts} +41 -41
- package/src/multiGrid/dataFormatterValidator.ts +116 -0
- package/src/multiGrid/dataValidator.ts +13 -0
- package/src/multiValue/{computeMultiValueData.ts → computedDataFn.ts} +176 -179
- package/src/multiValue/{createMultiValueContextObserver.ts → contextObserverCallback.ts} +12 -12
- package/src/multiValue/dataFormatterValidator.ts +10 -0
- package/src/multiValue/dataValidator.ts +10 -0
- package/src/relationship/{computeRelationshipData.ts → computedDataFn.ts} +125 -118
- package/src/relationship/{createRelationshipContextObserver.ts → contextObserverCallback.ts} +12 -12
- package/src/relationship/dataFormatterValidator.ts +10 -0
- package/src/relationship/dataValidator.ts +10 -0
- package/src/series/{computeSeriesData.ts → computedDataFn.ts} +88 -90
- package/src/series/{createSeriesContextObserver.ts → contextObserverCallback.ts} +100 -93
- package/src/series/dataFormatterValidator.ts +42 -0
- package/src/series/dataValidator.ts +13 -0
- package/src/tree/{computeTreeData.ts → computedDataFn.ts} +130 -132
- package/src/tree/{createTreeContextObserver.ts → contextObserverCallback.ts} +61 -61
- package/src/tree/dataFormatterValidator.ts +14 -0
- package/src/tree/dataValidator.ts +14 -0
- package/src/utils/commonUtils.ts +54 -50
- package/src/utils/d3Utils.ts +108 -108
- package/src/utils/errorMessage.ts +43 -0
- package/src/{grid → utils}/gridObservables.ts +611 -614
- package/src/utils/index.ts +10 -4
- package/src/{multiGrid → utils}/multiGridObservables.ts +366 -365
- package/src/utils/observables.ts +219 -202
- package/src/utils/orbchartsUtils.ts +352 -349
- package/src/{series → utils}/seriesObservables.ts +175 -175
- package/src/{tree → utils}/treeObservables.ts +94 -94
- package/src/utils/validator.ts +126 -0
- package/tsconfig.base.json +13 -13
- package/tsconfig.json +2 -2
- package/vite-env.d.ts +7 -0
- package/vite.config.js +22 -22
- package/dist/src/grid/computeGridData.d.ts +0 -6
- package/dist/src/grid/createGridContextObserver.d.ts +0 -3
- package/dist/src/multiGrid/computeMultiGridData.d.ts +0 -3
- package/dist/src/multiGrid/createMultiGridContextObserver.d.ts +0 -3
- package/dist/src/multiValue/computeMultiValueData.d.ts +0 -3
- package/dist/src/multiValue/createMultiValueContextObserver.d.ts +0 -3
- package/dist/src/relationship/computeRelationshipData.d.ts +0 -3
- package/dist/src/relationship/createRelationshipContextObserver.d.ts +0 -3
- package/dist/src/series/computeSeriesData.d.ts +0 -3
- package/dist/src/series/createSeriesContextObserver.d.ts +0 -3
- package/dist/src/tree/computeTreeData.d.ts +0 -3
- package/dist/src/tree/createTreeContextObserver.d.ts +0 -3
- package/dist/src/types/Axis.d.ts +0 -1
- package/dist/src/types/Chart.d.ts +0 -45
- package/dist/src/types/ChartParams.d.ts +0 -36
- package/dist/src/types/ComputedData.d.ts +0 -42
- package/dist/src/types/ComputedDataGrid.d.ts +0 -5
- package/dist/src/types/ComputedDataMultiGrid.d.ts +0 -3
- package/dist/src/types/ComputedDataMultiValue.d.ts +0 -6
- package/dist/src/types/ComputedDataRelationship.d.ts +0 -18
- package/dist/src/types/ComputedDataSeries.d.ts +0 -5
- package/dist/src/types/ComputedDataTree.d.ts +0 -7
- package/dist/src/types/ContextObserver.d.ts +0 -28
- package/dist/src/types/ContextObserverGrid.d.ts +0 -41
- package/dist/src/types/ContextObserverMultiGrid.d.ts +0 -15
- package/dist/src/types/ContextObserverMultiValue.d.ts +0 -4
- package/dist/src/types/ContextObserverRelationship.d.ts +0 -4
- package/dist/src/types/ContextObserverSeries.d.ts +0 -27
- package/dist/src/types/ContextObserverTree.d.ts +0 -11
- package/dist/src/types/ContextSubject.d.ts +0 -15
- package/dist/src/types/Data.d.ts +0 -19
- package/dist/src/types/DataFormatter.d.ts +0 -41
- package/dist/src/types/DataFormatterGrid.d.ts +0 -34
- package/dist/src/types/DataFormatterMultiGrid.d.ts +0 -20
- package/dist/src/types/DataFormatterMultiValue.d.ts +0 -18
- package/dist/src/types/DataFormatterRelationship.d.ts +0 -10
- package/dist/src/types/DataFormatterSeries.d.ts +0 -19
- package/dist/src/types/DataFormatterTree.d.ts +0 -7
- package/dist/src/types/DataGrid.d.ts +0 -6
- package/dist/src/types/DataMultiGrid.d.ts +0 -6
- package/dist/src/types/DataMultiValue.d.ts +0 -7
- package/dist/src/types/DataRelationship.d.ts +0 -21
- package/dist/src/types/DataSeries.d.ts +0 -6
- package/dist/src/types/DataTree.d.ts +0 -15
- package/dist/src/types/Event.d.ts +0 -56
- package/dist/src/types/Layout.d.ts +0 -8
- package/dist/src/types/Padding.d.ts +0 -6
- package/dist/src/types/Plugin.d.ts +0 -37
- package/dist/src/types/TransformData.d.ts +0 -8
- package/dist/src/types/index.d.ts +0 -37
- package/src/types/Axis.ts +0 -1
- package/src/types/Chart.ts +0 -54
- package/src/types/ChartParams.ts +0 -51
- package/src/types/ComputedData.ts +0 -84
- package/src/types/ComputedDataGrid.ts +0 -14
- package/src/types/ComputedDataMultiGrid.ts +0 -3
- package/src/types/ComputedDataMultiValue.ts +0 -9
- package/src/types/ComputedDataRelationship.ts +0 -20
- package/src/types/ComputedDataSeries.ts +0 -8
- package/src/types/ComputedDataTree.ts +0 -20
- package/src/types/ContextObserver.ts +0 -38
- package/src/types/ContextObserverGrid.ts +0 -43
- package/src/types/ContextObserverMultiGrid.ts +0 -17
- package/src/types/ContextObserverMultiValue.ts +0 -5
- package/src/types/ContextObserverRelationship.ts +0 -5
- package/src/types/ContextObserverSeries.ts +0 -29
- package/src/types/ContextObserverTree.ts +0 -11
- package/src/types/ContextSubject.ts +0 -18
- package/src/types/Data.ts +0 -45
- package/src/types/DataFormatter.ts +0 -74
- package/src/types/DataFormatterGrid.ts +0 -68
- package/src/types/DataFormatterMultiGrid.ts +0 -45
- package/src/types/DataFormatterMultiValue.ts +0 -24
- package/src/types/DataFormatterRelationship.ts +0 -26
- package/src/types/DataFormatterSeries.ts +0 -20
- package/src/types/DataFormatterTree.ts +0 -12
- package/src/types/DataGrid.ts +0 -11
- package/src/types/DataMultiGrid.ts +0 -7
- package/src/types/DataMultiValue.ts +0 -12
- package/src/types/DataRelationship.ts +0 -28
- package/src/types/DataSeries.ts +0 -11
- package/src/types/DataTree.ts +0 -20
- package/src/types/Event.ts +0 -153
- package/src/types/Layout.ts +0 -12
- package/src/types/Padding.ts +0 -6
- package/src/types/Plugin.ts +0 -60
- package/src/types/TransformData.ts +0 -8
- package/src/types/index.ts +0 -37
- /package/dist/src/{multiValue → utils}/multiValueObservables.d.ts +0 -0
- /package/dist/src/{relationship → utils}/relationshipObservables.d.ts +0 -0
- /package/src/{multiValue → utils}/multiValueObservables.ts +0 -0
- /package/src/{relationship → utils}/relationshipObservables.ts +0 -0
@@ -1,134 +1,129 @@
|
|
1
|
-
import * as d3 from 'd3'
|
2
|
-
import type { ComputedDataFn } from '
|
3
|
-
import
|
4
|
-
import
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
//
|
19
|
-
const
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
return
|
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
|
-
const
|
87
|
-
transposedDataGrid,
|
88
|
-
dataFormatterGrid: dataFormatter.grid,
|
89
|
-
chartType: 'grid'
|
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
|
-
throw Error(e)
|
131
|
-
}
|
132
|
-
|
133
|
-
return computedDataGrid
|
134
|
-
}
|
1
|
+
// import * as d3 from 'd3'
|
2
|
+
import type { ComputedDataFn, DataGrid, DataGridDatum, DataFormatterGridGrid, ComputedDatumGrid } from '../../lib/core-types'
|
3
|
+
import { formatValueToLabel, createDefaultDatumId, createDefaultSeriesLabel, createDefaultGroupLabel } from '../utils/orbchartsUtils'
|
4
|
+
import { getMinAndMaxValue, transposeData, createGridSeriesLabels, createGridGroupLabels, seriesColorPredicate } from '../utils/orbchartsUtils'
|
5
|
+
|
6
|
+
// 統一 DataGrid 格式、並欄列資料轉置為一致方式
|
7
|
+
export function createTransposedDataGrid (data: DataGrid, dataFormatterGrid: DataFormatterGridGrid): DataGridDatum[][] {
|
8
|
+
// const { data = [], dataFormatter, chartParams } = context
|
9
|
+
if (!data.length) {
|
10
|
+
return []
|
11
|
+
}
|
12
|
+
try {
|
13
|
+
// 最多的array length
|
14
|
+
const maxArrayLength = data.reduce((prev, current) => {
|
15
|
+
return current.length > prev ? current.length : prev
|
16
|
+
}, 0)
|
17
|
+
|
18
|
+
// 補齊短少資料
|
19
|
+
const fullData = data.map((d, i) => {
|
20
|
+
if (d.length === maxArrayLength) {
|
21
|
+
return d
|
22
|
+
}
|
23
|
+
const newD = Object.assign([], d)
|
24
|
+
for (let _i = newD.length; _i < maxArrayLength; _i++) {
|
25
|
+
newD[_i] = null
|
26
|
+
}
|
27
|
+
return newD
|
28
|
+
})
|
29
|
+
|
30
|
+
// 完整的資料格式
|
31
|
+
const dataGrid: DataGridDatum[][] = fullData.map((d, i) => {
|
32
|
+
return d.map((_d, _i) => {
|
33
|
+
|
34
|
+
const datum: DataGridDatum = _d == null
|
35
|
+
? {
|
36
|
+
id: '',
|
37
|
+
label: '',
|
38
|
+
data: {},
|
39
|
+
value: null,
|
40
|
+
}
|
41
|
+
: typeof _d === 'number'
|
42
|
+
? {
|
43
|
+
id: '',
|
44
|
+
label: '',
|
45
|
+
data: {},
|
46
|
+
value: _d,
|
47
|
+
}
|
48
|
+
: {
|
49
|
+
id: _d.id ?? '',
|
50
|
+
label: _d.label ?? '',
|
51
|
+
data: _d.data ?? {},
|
52
|
+
value: _d.value,
|
53
|
+
}
|
54
|
+
|
55
|
+
return datum
|
56
|
+
})
|
57
|
+
})
|
58
|
+
|
59
|
+
// 依seriesDirection轉置資料矩陣
|
60
|
+
const transposedDataGrid = transposeData(dataFormatterGrid.seriesDirection, dataGrid)
|
61
|
+
|
62
|
+
return transposedDataGrid
|
63
|
+
} catch (e) {
|
64
|
+
return []
|
65
|
+
}
|
66
|
+
}
|
67
|
+
|
68
|
+
export const computedDataFn: ComputedDataFn<'grid'> = (context) => {
|
69
|
+
const { data = [], dataFormatter, chartParams } = context
|
70
|
+
if (!data.length) {
|
71
|
+
return []
|
72
|
+
}
|
73
|
+
|
74
|
+
let computedDataGrid: ComputedDatumGrid[][]
|
75
|
+
|
76
|
+
try {
|
77
|
+
|
78
|
+
// 依seriesDirection轉置資料矩陣
|
79
|
+
const transposedDataGrid = createTransposedDataGrid(data, dataFormatter.grid)
|
80
|
+
|
81
|
+
const seriesLabels = createGridSeriesLabels({
|
82
|
+
transposedDataGrid,
|
83
|
+
dataFormatterGrid: dataFormatter.grid,
|
84
|
+
chartType: 'grid'
|
85
|
+
})
|
86
|
+
const groupLabels = createGridGroupLabels({
|
87
|
+
transposedDataGrid,
|
88
|
+
dataFormatterGrid: dataFormatter.grid,
|
89
|
+
chartType: 'grid'
|
90
|
+
})
|
91
|
+
|
92
|
+
let _index = 0
|
93
|
+
computedDataGrid = transposedDataGrid.map((seriesData, seriesIndex) => {
|
94
|
+
return seriesData.map((groupDatum, groupIndex) => {
|
95
|
+
|
96
|
+
const defaultId = createDefaultDatumId('grid', 0, seriesIndex, groupIndex)
|
97
|
+
const groupLabel = groupLabels[groupIndex]
|
98
|
+
|
99
|
+
const computedDatum: ComputedDatumGrid = {
|
100
|
+
id: groupDatum.id ? groupDatum.id : defaultId,
|
101
|
+
index: _index,
|
102
|
+
label: groupDatum.label ? groupDatum.label : defaultId,
|
103
|
+
description: groupDatum.description ?? '',
|
104
|
+
data: groupDatum.data,
|
105
|
+
value: groupDatum.value,
|
106
|
+
gridIndex: 0,
|
107
|
+
seriesIndex,
|
108
|
+
seriesLabel: seriesLabels[seriesIndex],
|
109
|
+
groupIndex,
|
110
|
+
groupLabel,
|
111
|
+
color: seriesColorPredicate(seriesIndex, chartParams),
|
112
|
+
visible: true // 先給一個預設值
|
113
|
+
}
|
114
|
+
|
115
|
+
// 先建立物件再計算visible欄位
|
116
|
+
computedDatum.visible = dataFormatter.visibleFilter(computedDatum, context)
|
117
|
+
|
118
|
+
_index ++
|
119
|
+
|
120
|
+
return computedDatum
|
121
|
+
})
|
122
|
+
})
|
123
|
+
|
124
|
+
} catch (e) {
|
125
|
+
throw Error(e)
|
126
|
+
}
|
127
|
+
|
128
|
+
return computedDataGrid
|
129
|
+
}
|
@@ -1,155 +1,155 @@
|
|
1
|
-
import { map, shareReplay, distinctUntilChanged } from 'rxjs'
|
2
|
-
import type {
|
3
|
-
import {
|
4
|
-
highlightObservable,
|
5
|
-
seriesDataMapObservable,
|
6
|
-
groupDataMapObservable,
|
7
|
-
textSizePxObservable } from '../utils/observables'
|
8
|
-
import {
|
9
|
-
gridComputedLayoutDataObservable,
|
10
|
-
gridAxesTransformObservable,
|
11
|
-
gridAxesReverseTransformObservable,
|
12
|
-
gridGraphicTransformObservable,
|
13
|
-
gridGraphicReverseScaleObservable,
|
14
|
-
gridAxesSizeObservable,
|
15
|
-
|
16
|
-
gridVisibleComputedDataObservable,
|
17
|
-
gridVisibleComputedLayoutDataObservable,
|
18
|
-
// isSeriesSeprateObservable,
|
19
|
-
gridContainerPositionObservable,
|
20
|
-
computedStackedDataObservables } from '
|
21
|
-
|
22
|
-
export const
|
23
|
-
|
24
|
-
const textSizePx$ = textSizePxObservable(observer.fullChartParams$).pipe(
|
25
|
-
shareReplay(1)
|
26
|
-
)
|
27
|
-
|
28
|
-
const isSeriesSeprate$ = observer.fullDataFormatter$.pipe(
|
29
|
-
map(d => d.grid.separateSeries),
|
30
|
-
distinctUntilChanged(),
|
31
|
-
shareReplay(1)
|
32
|
-
)
|
33
|
-
|
34
|
-
const gridContainerPosition$ = gridContainerPositionObservable({
|
35
|
-
computedData$: observer.computedData$,
|
36
|
-
fullDataFormatter$: observer.fullDataFormatter$,
|
37
|
-
layout$: observer.layout$,
|
38
|
-
})
|
39
|
-
|
40
|
-
const gridAxesTransform$ = gridAxesTransformObservable({
|
41
|
-
fullDataFormatter$: observer.fullDataFormatter$,
|
42
|
-
layout$: observer.layout$
|
43
|
-
}).pipe(
|
44
|
-
shareReplay(1)
|
45
|
-
)
|
46
|
-
|
47
|
-
const gridAxesReverseTransform$ = gridAxesReverseTransformObservable({
|
48
|
-
gridAxesTransform$
|
49
|
-
}).pipe(
|
50
|
-
shareReplay(1)
|
51
|
-
)
|
52
|
-
|
53
|
-
const gridGraphicTransform$ = gridGraphicTransformObservable({
|
54
|
-
computedData$: observer.computedData$,
|
55
|
-
fullDataFormatter$: observer.fullDataFormatter$,
|
56
|
-
layout$: observer.layout$
|
57
|
-
}).pipe(
|
58
|
-
shareReplay(1)
|
59
|
-
)
|
60
|
-
|
61
|
-
const gridGraphicReverseScale$ = gridGraphicReverseScaleObservable({
|
62
|
-
gridContainerPosition$: gridContainerPosition$,
|
63
|
-
gridAxesTransform$: gridAxesTransform$,
|
64
|
-
gridGraphicTransform$: gridGraphicTransform$,
|
65
|
-
})
|
66
|
-
|
67
|
-
const gridAxesSize$ = gridAxesSizeObservable({
|
68
|
-
fullDataFormatter$: observer.fullDataFormatter$,
|
69
|
-
layout$: observer.layout$
|
70
|
-
}).pipe(
|
71
|
-
shareReplay(1)
|
72
|
-
)
|
73
|
-
|
74
|
-
const datumList$ = observer.computedData$.pipe(
|
75
|
-
map(d => d.flat())
|
76
|
-
).pipe(
|
77
|
-
shareReplay(1)
|
78
|
-
)
|
79
|
-
|
80
|
-
const gridHighlight$ = highlightObservable({
|
81
|
-
datumList$,
|
82
|
-
fullChartParams$: observer.fullChartParams$,
|
83
|
-
event$: subject.event$
|
84
|
-
}).pipe(
|
85
|
-
shareReplay(1)
|
86
|
-
)
|
87
|
-
|
88
|
-
const seriesLabels$ =
|
89
|
-
computedData$: observer.computedData$,
|
90
|
-
})
|
91
|
-
|
92
|
-
const SeriesDataMap$ = seriesDataMapObservable({
|
93
|
-
datumList$: datumList$
|
94
|
-
}).pipe(
|
95
|
-
shareReplay(1)
|
96
|
-
)
|
97
|
-
|
98
|
-
const GroupDataMap$ = groupDataMapObservable({
|
99
|
-
datumList$: datumList$
|
100
|
-
}).pipe(
|
101
|
-
shareReplay(1)
|
102
|
-
)
|
103
|
-
|
104
|
-
const computedLayoutData$ = gridComputedLayoutDataObservable({
|
105
|
-
computedData$: observer.computedData$,
|
106
|
-
fullDataFormatter$: observer.fullDataFormatter$,
|
107
|
-
layout$: observer.layout$,
|
108
|
-
}).pipe(
|
109
|
-
shareReplay(1)
|
110
|
-
)
|
111
|
-
|
112
|
-
const visibleComputedData$ = gridVisibleComputedDataObservable({
|
113
|
-
computedData$: observer.computedData$,
|
114
|
-
}).pipe(
|
115
|
-
shareReplay(1)
|
116
|
-
)
|
117
|
-
|
118
|
-
const visibleComputedLayoutData$ = gridVisibleComputedLayoutDataObservable({
|
119
|
-
computedLayoutData$: computedLayoutData$,
|
120
|
-
}).pipe(
|
121
|
-
shareReplay(1)
|
122
|
-
)
|
123
|
-
|
124
|
-
const computedStackedData$ = computedStackedDataObservables({
|
125
|
-
computedData$: observer.computedData$,
|
126
|
-
isSeriesSeprate$: isSeriesSeprate$
|
127
|
-
}).pipe(
|
128
|
-
shareReplay(1)
|
129
|
-
)
|
130
|
-
|
131
|
-
|
132
|
-
return {
|
133
|
-
fullParams$: observer.fullParams$,
|
134
|
-
fullChartParams$: observer.fullChartParams$,
|
135
|
-
fullDataFormatter$: observer.fullDataFormatter$,
|
136
|
-
computedData$: observer.computedData$,
|
137
|
-
layout$: observer.layout$,
|
138
|
-
textSizePx$,
|
139
|
-
isSeriesSeprate$,
|
140
|
-
gridContainerPosition$,
|
141
|
-
gridAxesTransform$,
|
142
|
-
gridAxesReverseTransform$,
|
143
|
-
gridGraphicTransform$,
|
144
|
-
gridGraphicReverseScale$,
|
145
|
-
gridAxesSize$,
|
146
|
-
gridHighlight$,
|
147
|
-
seriesLabels$,
|
148
|
-
SeriesDataMap$,
|
149
|
-
GroupDataMap$,
|
150
|
-
computedLayoutData$,
|
151
|
-
visibleComputedData$,
|
152
|
-
visibleComputedLayoutData$,
|
153
|
-
computedStackedData$,
|
154
|
-
}
|
155
|
-
}
|
1
|
+
import { map, shareReplay, distinctUntilChanged } from 'rxjs'
|
2
|
+
import type { ContextObserverCallback } from '../../lib/core-types'
|
3
|
+
import {
|
4
|
+
highlightObservable,
|
5
|
+
seriesDataMapObservable,
|
6
|
+
groupDataMapObservable,
|
7
|
+
textSizePxObservable } from '../utils/observables'
|
8
|
+
import {
|
9
|
+
gridComputedLayoutDataObservable,
|
10
|
+
gridAxesTransformObservable,
|
11
|
+
gridAxesReverseTransformObservable,
|
12
|
+
gridGraphicTransformObservable,
|
13
|
+
gridGraphicReverseScaleObservable,
|
14
|
+
gridAxesSizeObservable,
|
15
|
+
gridSeriesLabelsObservable,
|
16
|
+
gridVisibleComputedDataObservable,
|
17
|
+
gridVisibleComputedLayoutDataObservable,
|
18
|
+
// isSeriesSeprateObservable,
|
19
|
+
gridContainerPositionObservable,
|
20
|
+
computedStackedDataObservables } from '../utils/gridObservables'
|
21
|
+
|
22
|
+
export const contextObserverCallback: ContextObserverCallback<'grid'> = ({ subject, observer }) => {
|
23
|
+
|
24
|
+
const textSizePx$ = textSizePxObservable(observer.fullChartParams$).pipe(
|
25
|
+
shareReplay(1)
|
26
|
+
)
|
27
|
+
|
28
|
+
const isSeriesSeprate$ = observer.fullDataFormatter$.pipe(
|
29
|
+
map(d => d.grid.separateSeries),
|
30
|
+
distinctUntilChanged(),
|
31
|
+
shareReplay(1)
|
32
|
+
)
|
33
|
+
|
34
|
+
const gridContainerPosition$ = gridContainerPositionObservable({
|
35
|
+
computedData$: observer.computedData$,
|
36
|
+
fullDataFormatter$: observer.fullDataFormatter$,
|
37
|
+
layout$: observer.layout$,
|
38
|
+
})
|
39
|
+
|
40
|
+
const gridAxesTransform$ = gridAxesTransformObservable({
|
41
|
+
fullDataFormatter$: observer.fullDataFormatter$,
|
42
|
+
layout$: observer.layout$
|
43
|
+
}).pipe(
|
44
|
+
shareReplay(1)
|
45
|
+
)
|
46
|
+
|
47
|
+
const gridAxesReverseTransform$ = gridAxesReverseTransformObservable({
|
48
|
+
gridAxesTransform$
|
49
|
+
}).pipe(
|
50
|
+
shareReplay(1)
|
51
|
+
)
|
52
|
+
|
53
|
+
const gridGraphicTransform$ = gridGraphicTransformObservable({
|
54
|
+
computedData$: observer.computedData$,
|
55
|
+
fullDataFormatter$: observer.fullDataFormatter$,
|
56
|
+
layout$: observer.layout$
|
57
|
+
}).pipe(
|
58
|
+
shareReplay(1)
|
59
|
+
)
|
60
|
+
|
61
|
+
const gridGraphicReverseScale$ = gridGraphicReverseScaleObservable({
|
62
|
+
gridContainerPosition$: gridContainerPosition$,
|
63
|
+
gridAxesTransform$: gridAxesTransform$,
|
64
|
+
gridGraphicTransform$: gridGraphicTransform$,
|
65
|
+
})
|
66
|
+
|
67
|
+
const gridAxesSize$ = gridAxesSizeObservable({
|
68
|
+
fullDataFormatter$: observer.fullDataFormatter$,
|
69
|
+
layout$: observer.layout$
|
70
|
+
}).pipe(
|
71
|
+
shareReplay(1)
|
72
|
+
)
|
73
|
+
|
74
|
+
const datumList$ = observer.computedData$.pipe(
|
75
|
+
map(d => d.flat())
|
76
|
+
).pipe(
|
77
|
+
shareReplay(1)
|
78
|
+
)
|
79
|
+
|
80
|
+
const gridHighlight$ = highlightObservable({
|
81
|
+
datumList$,
|
82
|
+
fullChartParams$: observer.fullChartParams$,
|
83
|
+
event$: subject.event$
|
84
|
+
}).pipe(
|
85
|
+
shareReplay(1)
|
86
|
+
)
|
87
|
+
|
88
|
+
const seriesLabels$ = gridSeriesLabelsObservable({
|
89
|
+
computedData$: observer.computedData$,
|
90
|
+
})
|
91
|
+
|
92
|
+
const SeriesDataMap$ = seriesDataMapObservable({
|
93
|
+
datumList$: datumList$
|
94
|
+
}).pipe(
|
95
|
+
shareReplay(1)
|
96
|
+
)
|
97
|
+
|
98
|
+
const GroupDataMap$ = groupDataMapObservable({
|
99
|
+
datumList$: datumList$
|
100
|
+
}).pipe(
|
101
|
+
shareReplay(1)
|
102
|
+
)
|
103
|
+
|
104
|
+
const computedLayoutData$ = gridComputedLayoutDataObservable({
|
105
|
+
computedData$: observer.computedData$,
|
106
|
+
fullDataFormatter$: observer.fullDataFormatter$,
|
107
|
+
layout$: observer.layout$,
|
108
|
+
}).pipe(
|
109
|
+
shareReplay(1)
|
110
|
+
)
|
111
|
+
|
112
|
+
const visibleComputedData$ = gridVisibleComputedDataObservable({
|
113
|
+
computedData$: observer.computedData$,
|
114
|
+
}).pipe(
|
115
|
+
shareReplay(1)
|
116
|
+
)
|
117
|
+
|
118
|
+
const visibleComputedLayoutData$ = gridVisibleComputedLayoutDataObservable({
|
119
|
+
computedLayoutData$: computedLayoutData$,
|
120
|
+
}).pipe(
|
121
|
+
shareReplay(1)
|
122
|
+
)
|
123
|
+
|
124
|
+
const computedStackedData$ = computedStackedDataObservables({
|
125
|
+
computedData$: observer.computedData$,
|
126
|
+
isSeriesSeprate$: isSeriesSeprate$
|
127
|
+
}).pipe(
|
128
|
+
shareReplay(1)
|
129
|
+
)
|
130
|
+
|
131
|
+
|
132
|
+
return {
|
133
|
+
fullParams$: observer.fullParams$,
|
134
|
+
fullChartParams$: observer.fullChartParams$,
|
135
|
+
fullDataFormatter$: observer.fullDataFormatter$,
|
136
|
+
computedData$: observer.computedData$,
|
137
|
+
layout$: observer.layout$,
|
138
|
+
textSizePx$,
|
139
|
+
isSeriesSeprate$,
|
140
|
+
gridContainerPosition$,
|
141
|
+
gridAxesTransform$,
|
142
|
+
gridAxesReverseTransform$,
|
143
|
+
gridGraphicTransform$,
|
144
|
+
gridGraphicReverseScale$,
|
145
|
+
gridAxesSize$,
|
146
|
+
gridHighlight$,
|
147
|
+
seriesLabels$,
|
148
|
+
SeriesDataMap$,
|
149
|
+
GroupDataMap$,
|
150
|
+
computedLayoutData$,
|
151
|
+
visibleComputedData$,
|
152
|
+
visibleComputedLayoutData$,
|
153
|
+
computedStackedData$,
|
154
|
+
}
|
155
|
+
}
|