@orbcharts/core 3.0.0-alpha.33 → 3.0.0-alpha.35
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 +1852 -1776
- package/dist/orbcharts-core.umd.js +2 -2
- package/dist/src/grid/computeGridData.d.ts +10 -3
- package/dist/src/types/ComputedDataGrid.d.ts +0 -1
- package/dist/src/utils/commonUtils.d.ts +1 -1
- package/dist/src/utils/orbchartsUtils.d.ts +12 -2
- package/package.json +1 -1
- package/src/base/createBaseChart.ts +26 -9
- package/src/defaults.ts +0 -1
- package/src/grid/computeGridData.ts +67 -119
- package/src/multiGrid/computeMultiGridData.ts +142 -31
- package/src/multiValue/computeMultiValueData.ts +1 -0
- package/src/tree/computeTreeData.ts +2 -2
- package/src/types/ComputedDataGrid.ts +1 -1
- package/src/utils/commonUtils.ts +6 -6
- package/src/utils/orbchartsUtils.ts +41 -7
|
@@ -7,13 +7,14 @@ 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
9
|
import type { SeriesDirection, DataFormatterGrid, DataFormatterGridContainer } from '../types/DataFormatterGrid'
|
|
10
|
+
import type { DataFormatterMultiGrid } from '../types/DataFormatterMultiGrid'
|
|
10
11
|
import type { ComputedDatumSeriesValue } from '../types/ComputedData'
|
|
11
12
|
import type { ComputedDatumSeries } from '../types/ComputedDataSeries'
|
|
12
13
|
import type { ComputedDatumGrid, ComputedDataGrid } from '../types/ComputedDataGrid'
|
|
13
14
|
import type { ComputedDataMultiGrid } from '../types/ComputedDataMultiGrid'
|
|
14
15
|
import type { Layout } from '../types/Layout'
|
|
15
16
|
// import type { ComputedDatumMultiGrid } from '../types/ComputedDataMultiGrid'
|
|
16
|
-
import {
|
|
17
|
+
import { isPlainObject } from './commonUtils'
|
|
17
18
|
|
|
18
19
|
export function formatValueToLabel (value: any, valueFormatter: string | ((text: d3.NumberValue) => string)) {
|
|
19
20
|
if (valueFormatter! instanceof Function == true) {
|
|
@@ -38,7 +39,22 @@ export function createDefaultGroupLabel (chartTypeOrPrefix: string, groupIndex:
|
|
|
38
39
|
return `${chartTypeOrPrefix}_group${groupIndex}`
|
|
39
40
|
}
|
|
40
41
|
|
|
41
|
-
export function createGridSeriesLabels ({ transposedDataGrid, dataFormatter, chartType = 'grid'
|
|
42
|
+
export function createGridSeriesLabels ({ transposedDataGrid, dataFormatter, chartType = 'grid' }: {
|
|
43
|
+
transposedDataGrid: DataGridDatum[][],
|
|
44
|
+
dataFormatter: DataFormatterGrid
|
|
45
|
+
chartType?: ChartType
|
|
46
|
+
}) {
|
|
47
|
+
const labels = dataFormatter.grid.gridData.seriesDirection === 'row'
|
|
48
|
+
? dataFormatter.grid.gridData.rowLabels
|
|
49
|
+
: dataFormatter.grid.gridData.columnLabels
|
|
50
|
+
return transposedDataGrid.map((_, rowIndex) => {
|
|
51
|
+
return labels[rowIndex] != null
|
|
52
|
+
? labels[rowIndex]
|
|
53
|
+
: createDefaultSeriesLabel(chartType, rowIndex)
|
|
54
|
+
})
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export function createMultiGridSeriesLabels ({ transposedDataGrid, dataFormatter, chartType = 'multiGrid', gridIndex = 0 }: {
|
|
42
58
|
transposedDataGrid: DataGridDatum[][],
|
|
43
59
|
dataFormatter: DataFormatterGrid
|
|
44
60
|
chartType?: ChartType
|
|
@@ -54,7 +70,25 @@ export function createGridSeriesLabels ({ transposedDataGrid, dataFormatter, cha
|
|
|
54
70
|
})
|
|
55
71
|
}
|
|
56
72
|
|
|
57
|
-
export function createGridGroupLabels ({ transposedDataGrid, dataFormatter, chartType = 'grid'
|
|
73
|
+
export function createGridGroupLabels ({ transposedDataGrid, dataFormatter, chartType = 'grid' }: {
|
|
74
|
+
transposedDataGrid: DataGridDatum[][],
|
|
75
|
+
dataFormatter: DataFormatterGrid
|
|
76
|
+
chartType?: ChartType
|
|
77
|
+
}) {
|
|
78
|
+
if (transposedDataGrid[0] == null) {
|
|
79
|
+
return []
|
|
80
|
+
}
|
|
81
|
+
const labels = dataFormatter.grid.gridData.seriesDirection === 'row'
|
|
82
|
+
? dataFormatter.grid.gridData.columnLabels
|
|
83
|
+
: dataFormatter.grid.gridData.rowLabels
|
|
84
|
+
return transposedDataGrid[0].map((_, columnLabels) => {
|
|
85
|
+
return labels[columnLabels] != null
|
|
86
|
+
? labels[columnLabels]
|
|
87
|
+
: createDefaultGroupLabel(chartType, columnLabels)
|
|
88
|
+
})
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export function createMultiGridGroupLabels ({ transposedDataGrid, dataFormatter, chartType = 'multiGrid', gridIndex = 0 }: {
|
|
58
92
|
transposedDataGrid: DataGridDatum[][],
|
|
59
93
|
dataFormatter: DataFormatterGrid
|
|
60
94
|
chartType?: ChartType
|
|
@@ -103,7 +137,7 @@ export function getMinAndMaxSeries (data: DataSeries): [number, number] {
|
|
|
103
137
|
? data.flat()
|
|
104
138
|
: data as (DataSeriesValue | DataSeriesDatum)[]
|
|
105
139
|
const arr = flatData
|
|
106
|
-
.filter(d => (d == null || (
|
|
140
|
+
.filter(d => (d == null || (isPlainObject(d) && (d as DataSeriesDatum).value == null)) === false) // 過濾掉null &
|
|
107
141
|
.map(d => typeof d === 'number' ? d : d.value )
|
|
108
142
|
return getMinAndMax(arr)
|
|
109
143
|
}
|
|
@@ -112,7 +146,7 @@ export function getMinAndMaxSeries (data: DataSeries): [number, number] {
|
|
|
112
146
|
export function getMinAndMaxGrid (data: DataGrid): [number, number] {
|
|
113
147
|
const flatData: (DataGridValue | DataGridDatum)[] = data.flat()
|
|
114
148
|
const arr = flatData
|
|
115
|
-
.filter(d => (d == null || (
|
|
149
|
+
.filter(d => (d == null || (isPlainObject(d) && (d as DataGridDatum).value == null)) === false) // 過濾掉null
|
|
116
150
|
.map(d => typeof d === 'number' ? d : d.value )
|
|
117
151
|
return getMinAndMax(arr)
|
|
118
152
|
}
|
|
@@ -121,7 +155,7 @@ export function getMinAndMaxGrid (data: DataGrid): [number, number] {
|
|
|
121
155
|
export function getMinAndMaxMultiGrid (data: DataMultiGrid): [number, number] {
|
|
122
156
|
const flatData: (DataGridValue | DataGridDatum)[] = data.flat().flat()
|
|
123
157
|
const arr = flatData
|
|
124
|
-
.filter(d => (d == null || (
|
|
158
|
+
.filter(d => (d == null || (isPlainObject(d) && (d as DataGridDatum).value == null)) === false) // 過濾掉null
|
|
125
159
|
.map(d => typeof d === 'number' ? d : d.value )
|
|
126
160
|
return getMinAndMax(arr)
|
|
127
161
|
}
|
|
@@ -130,7 +164,7 @@ export function getMinAndMaxMultiGrid (data: DataMultiGrid): [number, number] {
|
|
|
130
164
|
export function getMinAndMaxMultiValue (data: DataMultiValue, valueIndex: number = 2): [number, number] {
|
|
131
165
|
const flatData: (DataMultiValueDatum | DataMultiValueValue)[] = data.flat().filter((d, i) => i == valueIndex)
|
|
132
166
|
const arr = flatData
|
|
133
|
-
.filter(d => (d == null || (
|
|
167
|
+
.filter(d => (d == null || (isPlainObject(d) && (d as DataMultiValueDatum).value == null)) === false) // 過濾掉null
|
|
134
168
|
.map(d => typeof d === 'number' ? d : d.value )
|
|
135
169
|
return getMinAndMax(arr)
|
|
136
170
|
}
|