@orbcharts/core 3.0.0-alpha.32 → 3.0.0-alpha.33
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/orbcharts-core.es.js +1572 -1414
- 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/orbchartsUtils.d.ts +7 -2
- package/package.json +1 -1
- package/src/base/createBaseChart.ts +3 -3
- package/src/defaults.ts +31 -18
- 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/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/orbchartsUtils.ts +26 -10
@@ -3,14 +3,32 @@ import type { ContextObserverBase } from './ContextObserver'
|
|
3
3
|
import type { ComputedDataGrid, ComputedDatumGrid } from './ComputedDataGrid'
|
4
4
|
import type { TransformData } from './TransformData'
|
5
5
|
|
6
|
-
export interface ContextObserverGrid<PluginParams>
|
6
|
+
export interface ContextObserverGrid<PluginParams>
|
7
|
+
extends
|
8
|
+
ContextObserverBase<'grid', PluginParams>,
|
9
|
+
ContextObserverGridDetail {
|
10
|
+
|
11
|
+
}
|
12
|
+
|
13
|
+
export interface ContextObserverGridDetail {
|
14
|
+
gridContainer$: Observable<ContainerPosition[]>
|
7
15
|
gridAxesTransform$: Observable<TransformData>
|
16
|
+
gridAxesReverseTransform$: Observable<TransformData>
|
8
17
|
gridGraphicTransform$: Observable<TransformData>
|
9
|
-
|
18
|
+
gridGraphicReverseScale$: Observable<[number, number][]>
|
10
19
|
gridAxesSize$: Observable<{ width: number; height: number; }>
|
11
20
|
gridHighlight$: Observable<string[]>
|
21
|
+
existedSeriesLabels$: Observable<string[]>
|
12
22
|
SeriesDataMap$: Observable<Map<string, ComputedDatumGrid[]>>
|
13
23
|
GroupDataMap$: Observable<Map<string, ComputedDatumGrid[]>>
|
14
24
|
visibleComputedData$: Observable<ComputedDataGrid>
|
25
|
+
isSeriesPositionSeprate$: Observable<boolean>
|
15
26
|
}
|
16
27
|
|
28
|
+
export interface ContainerPosition {
|
29
|
+
slotIndex: number
|
30
|
+
rowIndex: number
|
31
|
+
columnIndex: number
|
32
|
+
translate: [number, number]
|
33
|
+
scale: [number, number]
|
34
|
+
}
|
@@ -1,28 +1,27 @@
|
|
1
1
|
import { Observable } from 'rxjs'
|
2
2
|
import type { ContextObserverBase } from './ContextObserver'
|
3
3
|
import type { ComputedDataGrid, ComputedDatumGrid } from './ComputedDataGrid'
|
4
|
+
import type { ContainerPosition } from './ContextObserverGrid'
|
4
5
|
import type { TransformData } from './TransformData'
|
6
|
+
import type { ContextObserverGridDetail } from './ContextObserverGrid'
|
5
7
|
|
6
8
|
export interface ContextObserverMultiGrid<PluginParams> extends ContextObserverBase<'multiGrid', PluginParams> {
|
7
|
-
multiGridEachDetail$: Observable<
|
8
|
-
multiGridContainer$: Observable<
|
9
|
+
multiGridEachDetail$: Observable<ContextObserverGridDetail[]>
|
10
|
+
multiGridContainer$: Observable<ContainerPosition[][]>
|
9
11
|
}
|
10
12
|
|
11
|
-
export interface MultiGridObservableAll {
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
13
|
+
// export interface MultiGridObservableAll {
|
14
|
+
// isSeriesPositionSeprate$: Observable<boolean>
|
15
|
+
// gridContainer$: Observable<ContainerPosition[]>
|
16
|
+
// gridAxesTransform$: Observable<TransformData>
|
17
|
+
// gridAxesReverseTransform$: Observable<TransformData>
|
18
|
+
// gridGraphicTransform$: Observable<TransformData>
|
19
|
+
// gridGraphicReverseScale$: Observable<[number, number][]>
|
20
|
+
// gridAxesSize$: Observable<{ width: number; height: number; }>
|
21
|
+
// gridHighlight$: Observable<string[]>
|
22
|
+
// existedSeriesLabels$: Observable<string[]>
|
23
|
+
// SeriesDataMap$: Observable<Map<string, ComputedDatumGrid[]>>
|
24
|
+
// GroupDataMap$: Observable<Map<string, ComputedDatumGrid[]>>
|
25
|
+
// visibleComputedData$: Observable<ComputedDataGrid>
|
26
|
+
// }
|
21
27
|
|
22
|
-
export interface GridContainerBox {
|
23
|
-
slotIndex: number
|
24
|
-
rowIndex: number
|
25
|
-
columnIndex: number
|
26
|
-
translate: [number, number]
|
27
|
-
scale: [number, number]
|
28
|
-
}
|
@@ -2,34 +2,49 @@ import type { DataGridDatum, DataGridValue } from './DataGrid'
|
|
2
2
|
import type { DataFormatterBase, DataFormatterBasePartial, DataFormatterValueAxis, DataFormatterGroupAxis, VisibleFilter } from './DataFormatter'
|
3
3
|
// import type { AxisPosition } from './Axis'
|
4
4
|
|
5
|
-
export type
|
5
|
+
export type SeriesDirection = 'row' | 'column' // default: 'row'
|
6
6
|
|
7
7
|
export interface DataFormatterGrid extends DataFormatterBase<'grid'> {
|
8
|
-
visibleFilter: VisibleFilter<'grid'>
|
9
8
|
grid: DataFormatterGridGrid
|
10
|
-
|
11
|
-
groupAxis: DataFormatterGroupAxis
|
9
|
+
container: DataFormatterGridContainer
|
12
10
|
// visibleGroupRange: [number, number] | null
|
13
11
|
// colorsPredicate: (datum: DataGridDatum | DataGridValue, rowIndex: number, columnIndex: number, context: DataFormatterContext<'grid'>) => string
|
14
12
|
}
|
15
13
|
|
16
14
|
export interface DataFormatterGridPartial extends DataFormatterBasePartial<'grid'> {
|
17
|
-
grid?:
|
15
|
+
grid?: DataFormatterGridGridPartial
|
16
|
+
container?: Partial<DataFormatterGridContainer>
|
17
|
+
}
|
18
|
+
|
19
|
+
export interface DataFormatterGridGrid {
|
20
|
+
visibleFilter: VisibleFilter<'grid'>
|
21
|
+
gridData: DataFormatterGridGridData
|
22
|
+
valueAxis: DataFormatterValueAxis
|
23
|
+
groupAxis: DataFormatterGroupAxis
|
24
|
+
slotIndex: number | null
|
25
|
+
seriesSlotIndexes: number[] | null
|
26
|
+
}
|
27
|
+
|
28
|
+
export interface DataFormatterGridGridPartial {
|
29
|
+
visibleFilter?: VisibleFilter<'grid'>
|
30
|
+
gridData?: Partial<DataFormatterGridGridData>
|
18
31
|
valueAxis?: Partial<DataFormatterValueAxis>
|
19
32
|
groupAxis?: Partial<DataFormatterGroupAxis>
|
20
|
-
|
33
|
+
slotIndex?: number | null
|
34
|
+
seriesSlotIndexes?: number[] | null
|
35
|
+
}
|
36
|
+
|
37
|
+
export interface DataFormatterGridContainer {
|
38
|
+
gap: number
|
39
|
+
rowAmount: number
|
40
|
+
columnAmount: number
|
21
41
|
}
|
22
42
|
|
23
43
|
// grid欄位
|
24
|
-
export interface
|
25
|
-
|
26
|
-
// rowUnitLabel: string
|
44
|
+
export interface DataFormatterGridGridData {
|
45
|
+
seriesDirection: SeriesDirection
|
27
46
|
rowLabels: string[]
|
28
|
-
// rowLabelFormat: string | ((text: any) => string)
|
29
|
-
// columnUnitLabel: string
|
30
47
|
columnLabels: string[]
|
31
|
-
// columnLabelFormat: string | ((text: any) => string)
|
32
|
-
seriesType: SeriesType
|
33
48
|
}
|
34
49
|
|
35
50
|
// const test: DataFormatterGridPartial = {
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import type { VisibleFilter } from './DataFormatter'
|
2
|
-
import type {
|
2
|
+
import type { DataFormatterGridGrid, DataFormatterGridGridPartial, DataFormatterGridContainer } from './DataFormatterGrid'
|
3
3
|
import type {
|
4
4
|
DataFormatterBase,
|
5
5
|
DataFormatterBasePartial,
|
@@ -10,30 +10,32 @@ import type { AxisPosition } from './Axis'
|
|
10
10
|
|
11
11
|
export interface DataFormatterMultiGrid extends DataFormatterBase<'multiGrid'> {
|
12
12
|
visibleFilter: VisibleFilter<'multiGrid'>
|
13
|
-
|
14
|
-
// visibleGroupRange: [number, number] | null
|
13
|
+
gridList: Array<DataFormatterGridGrid>
|
15
14
|
container: DataFormatterMultiGridContainer
|
16
15
|
}
|
17
16
|
|
18
17
|
export interface DataFormatterMultiGridPartial extends DataFormatterBasePartial<'multiGrid'> {
|
19
|
-
|
18
|
+
visibleFilter?: VisibleFilter<'multiGrid'>
|
19
|
+
gridList?: Array<DataFormatterGridGridPartial>
|
20
|
+
container?: Partial<DataFormatterMultiGridContainer>
|
20
21
|
}
|
21
22
|
|
22
|
-
|
23
|
-
|
24
|
-
|
23
|
+
export interface DataFormatterMultiGridGrid extends DataFormatterGridGrid {
|
24
|
+
|
25
|
+
}
|
26
|
+
|
27
|
+
export interface DataFormatterMultiGridGridPartial extends DataFormatterGridGridPartial {
|
28
|
+
|
25
29
|
}
|
26
30
|
|
27
31
|
// container
|
28
|
-
export interface DataFormatterMultiGridContainer {
|
29
|
-
|
30
|
-
rowAmount: number
|
31
|
-
columnAmount: number
|
32
|
+
export interface DataFormatterMultiGridContainer extends DataFormatterGridContainer {
|
33
|
+
|
32
34
|
}
|
33
35
|
|
34
36
|
// multiGrid欄位
|
35
37
|
// export interface DataFormatterMultiGridMultiGrid {
|
36
|
-
// grid:
|
38
|
+
// grid: DataFormatterGridGridData
|
37
39
|
// valueAxis: DataFormatterValueAxis // default: 'left'
|
38
40
|
// groupAxis: DataFormatterGroupAxis // default: 'bottom'
|
39
41
|
// colorsPredicate: (datum: DataGridDatum | DataGridValue, rowIndex: number, columnIndex: number, context: DataFormatterContext<'grid'>) => string
|
@@ -6,11 +6,12 @@ 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
16
|
import { isObject } from './commonUtils'
|
16
17
|
|
@@ -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]
|
@@ -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
|