@orbcharts/core 3.0.0-alpha.32 → 3.0.0-alpha.34
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/orbcharts-core.es.js +1673 -1512
- package/dist/orbcharts-core.umd.js +2 -2
- package/dist/src/defaults.d.ts +4 -3
- package/dist/src/grid/gridObservables.d.ts +27 -3
- package/dist/src/multiGrid/multiGridObservables.d.ts +3 -15
- package/dist/src/types/ContextObserverGrid.d.ts +15 -2
- package/dist/src/types/ContextObserverMultiGrid.d.ts +3 -24
- package/dist/src/types/DataFormatterGrid.d.ts +24 -6
- package/dist/src/types/DataFormatterMultiGrid.d.ts +9 -9
- package/dist/src/utils/commonUtils.d.ts +1 -1
- package/dist/src/utils/orbchartsUtils.d.ts +7 -2
- package/package.json +1 -1
- package/src/base/createBaseChart.ts +24 -9
- package/src/defaults.ts +31 -19
- package/src/grid/computeGridData.ts +87 -30
- package/src/grid/createGridContextObserver.ts +42 -9
- package/src/grid/gridObservables.ts +155 -28
- package/src/multiGrid/computeMultiGridData.ts +16 -12
- package/src/multiGrid/multiGridObservables.ts +188 -114
- package/src/multiValue/computeMultiValueData.ts +1 -0
- package/src/tree/computeTreeData.ts +2 -2
- package/src/types/ContextObserverGrid.ts +20 -2
- package/src/types/ContextObserverMultiGrid.ts +18 -19
- package/src/types/DataFormatterGrid.ts +28 -13
- package/src/types/DataFormatterMultiGrid.ts +14 -12
- package/src/utils/commonUtils.ts +6 -6
- package/src/utils/orbchartsUtils.ts +31 -15
|
@@ -6,13 +6,14 @@ import type { DataSeries, DataSeriesDatum, DataSeriesValue } from '../types/Data
|
|
|
6
6
|
import type { DataGrid, DataGridDatum, DataGridValue } from '../types/DataGrid'
|
|
7
7
|
import type { DataMultiGrid } from '../types/DataMultiGrid'
|
|
8
8
|
import type { DataMultiValue, DataMultiValueDatum, DataMultiValueValue } from '../types/DataMultiValue'
|
|
9
|
-
import type {
|
|
9
|
+
import type { SeriesDirection, DataFormatterGrid, DataFormatterGridContainer } from '../types/DataFormatterGrid'
|
|
10
10
|
import type { ComputedDatumSeriesValue } from '../types/ComputedData'
|
|
11
11
|
import type { ComputedDatumSeries } from '../types/ComputedDataSeries'
|
|
12
12
|
import type { ComputedDatumGrid, ComputedDataGrid } from '../types/ComputedDataGrid'
|
|
13
13
|
import type { ComputedDataMultiGrid } from '../types/ComputedDataMultiGrid'
|
|
14
|
+
import type { Layout } from '../types/Layout'
|
|
14
15
|
// import type { ComputedDatumMultiGrid } from '../types/ComputedDataMultiGrid'
|
|
15
|
-
import {
|
|
16
|
+
import { isPlainObject } from './commonUtils'
|
|
16
17
|
|
|
17
18
|
export function formatValueToLabel (value: any, valueFormatter: string | ((text: d3.NumberValue) => string)) {
|
|
18
19
|
if (valueFormatter! instanceof Function == true) {
|
|
@@ -43,9 +44,9 @@ export function createGridSeriesLabels ({ transposedDataGrid, dataFormatter, cha
|
|
|
43
44
|
chartType?: ChartType
|
|
44
45
|
gridIndex?: number
|
|
45
46
|
}) {
|
|
46
|
-
const labels = dataFormatter.grid.
|
|
47
|
-
? dataFormatter.grid.rowLabels
|
|
48
|
-
: dataFormatter.grid.columnLabels
|
|
47
|
+
const labels = dataFormatter.grid.gridData.seriesDirection === 'row'
|
|
48
|
+
? dataFormatter.grid.gridData.rowLabels
|
|
49
|
+
: dataFormatter.grid.gridData.columnLabels
|
|
49
50
|
return transposedDataGrid.map((_, rowIndex) => {
|
|
50
51
|
return labels[rowIndex] != null
|
|
51
52
|
? labels[rowIndex]
|
|
@@ -62,9 +63,9 @@ export function createGridGroupLabels ({ transposedDataGrid, dataFormatter, char
|
|
|
62
63
|
if (transposedDataGrid[0] == null) {
|
|
63
64
|
return []
|
|
64
65
|
}
|
|
65
|
-
const labels = dataFormatter.grid.
|
|
66
|
-
? dataFormatter.grid.columnLabels
|
|
67
|
-
: dataFormatter.grid.rowLabels
|
|
66
|
+
const labels = dataFormatter.grid.gridData.seriesDirection === 'row'
|
|
67
|
+
? dataFormatter.grid.gridData.columnLabels
|
|
68
|
+
: dataFormatter.grid.gridData.rowLabels
|
|
68
69
|
return transposedDataGrid[0].map((_, columnLabels) => {
|
|
69
70
|
return labels[columnLabels] != null
|
|
70
71
|
? labels[columnLabels]
|
|
@@ -102,7 +103,7 @@ export function getMinAndMaxSeries (data: DataSeries): [number, number] {
|
|
|
102
103
|
? data.flat()
|
|
103
104
|
: data as (DataSeriesValue | DataSeriesDatum)[]
|
|
104
105
|
const arr = flatData
|
|
105
|
-
.filter(d => (d == null || (
|
|
106
|
+
.filter(d => (d == null || (isPlainObject(d) && (d as DataSeriesDatum).value == null)) === false) // 過濾掉null &
|
|
106
107
|
.map(d => typeof d === 'number' ? d : d.value )
|
|
107
108
|
return getMinAndMax(arr)
|
|
108
109
|
}
|
|
@@ -111,7 +112,7 @@ export function getMinAndMaxSeries (data: DataSeries): [number, number] {
|
|
|
111
112
|
export function getMinAndMaxGrid (data: DataGrid): [number, number] {
|
|
112
113
|
const flatData: (DataGridValue | DataGridDatum)[] = data.flat()
|
|
113
114
|
const arr = flatData
|
|
114
|
-
.filter(d => (d == null || (
|
|
115
|
+
.filter(d => (d == null || (isPlainObject(d) && (d as DataGridDatum).value == null)) === false) // 過濾掉null
|
|
115
116
|
.map(d => typeof d === 'number' ? d : d.value )
|
|
116
117
|
return getMinAndMax(arr)
|
|
117
118
|
}
|
|
@@ -120,7 +121,7 @@ export function getMinAndMaxGrid (data: DataGrid): [number, number] {
|
|
|
120
121
|
export function getMinAndMaxMultiGrid (data: DataMultiGrid): [number, number] {
|
|
121
122
|
const flatData: (DataGridValue | DataGridDatum)[] = data.flat().flat()
|
|
122
123
|
const arr = flatData
|
|
123
|
-
.filter(d => (d == null || (
|
|
124
|
+
.filter(d => (d == null || (isPlainObject(d) && (d as DataGridDatum).value == null)) === false) // 過濾掉null
|
|
124
125
|
.map(d => typeof d === 'number' ? d : d.value )
|
|
125
126
|
return getMinAndMax(arr)
|
|
126
127
|
}
|
|
@@ -129,7 +130,7 @@ export function getMinAndMaxMultiGrid (data: DataMultiGrid): [number, number] {
|
|
|
129
130
|
export function getMinAndMaxMultiValue (data: DataMultiValue, valueIndex: number = 2): [number, number] {
|
|
130
131
|
const flatData: (DataMultiValueDatum | DataMultiValueValue)[] = data.flat().filter((d, i) => i == valueIndex)
|
|
131
132
|
const arr = flatData
|
|
132
|
-
.filter(d => (d == null || (
|
|
133
|
+
.filter(d => (d == null || (isPlainObject(d) && (d as DataMultiValueDatum).value == null)) === false) // 過濾掉null
|
|
133
134
|
.map(d => typeof d === 'number' ? d : d.value )
|
|
134
135
|
return getMinAndMax(arr)
|
|
135
136
|
}
|
|
@@ -146,9 +147,9 @@ export function getMinAndMaxMultiValue (data: DataMultiValue, valueIndex: number
|
|
|
146
147
|
|
|
147
148
|
// }
|
|
148
149
|
|
|
149
|
-
// 轉置成
|
|
150
|
-
export function transposeData<T> (
|
|
151
|
-
if (
|
|
150
|
+
// 轉置成seriesDirection為main的陣列格式
|
|
151
|
+
export function transposeData<T> (seriesDirection: SeriesDirection, data: T[][]): T[][] {
|
|
152
|
+
if (seriesDirection === 'row') {
|
|
152
153
|
return Object.assign([], data)
|
|
153
154
|
}
|
|
154
155
|
// 取得原始陣列的維度
|
|
@@ -179,6 +180,21 @@ export function seriesColorPredicate (seriesIndex: number, chartParams: ChartPar
|
|
|
179
180
|
]
|
|
180
181
|
}
|
|
181
182
|
|
|
183
|
+
export function calcGridContainerPosition (layout: Layout, container: DataFormatterGridContainer, rowIndex: number, columnIndex: number) {
|
|
184
|
+
const { gap, rowAmount, columnAmount } = container
|
|
185
|
+
const width = (layout.width - (gap * (columnAmount - 1))) / columnAmount
|
|
186
|
+
const height = (layout.height - (gap * (rowAmount - 1))) / rowAmount
|
|
187
|
+
const x = columnIndex * width + (columnIndex * gap)
|
|
188
|
+
const y = rowIndex * height + (rowIndex * gap)
|
|
189
|
+
const translate: [number, number] = [x, y]
|
|
190
|
+
const scale: [number, number] = [width / layout.width, height / layout.height]
|
|
191
|
+
|
|
192
|
+
return {
|
|
193
|
+
translate,
|
|
194
|
+
scale
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
|
|
182
198
|
// // multiGrid datum color
|
|
183
199
|
// export function multiGridColorPredicate ({ seriesIndex, groupIndex, data, chartParams }: {
|
|
184
200
|
// seriesIndex: number
|