@orbcharts/core 3.0.0-alpha.30 → 3.0.0-alpha.32
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 +997 -961
- package/dist/orbcharts-core.umd.js +2 -2
- package/dist/src/defaults.d.ts +2 -1
- package/dist/src/multiGrid/multiGridObservables.d.ts +13 -1
- package/dist/src/types/ContextObserverMultiGrid.d.ts +9 -1
- package/dist/src/types/DataFormatterMultiGrid.d.ts +11 -2
- package/package.json +1 -1
- package/src/base/createBaseChart.ts +10 -5
- package/src/defaults.ts +12 -11
- package/src/multiGrid/createMultiGridContextObserver.ts +11 -3
- package/src/multiGrid/multiGridObservables.ts +59 -1
- package/src/types/ContextObserverMultiGrid.ts +10 -1
- package/src/types/DataFormatterMultiGrid.ts +15 -2
|
@@ -3,8 +3,17 @@ import { DataFormatterGrid } from './DataFormatterGrid';
|
|
|
3
3
|
|
|
4
4
|
export interface DataFormatterMultiGrid extends DataFormatterBase<'multiGrid'> {
|
|
5
5
|
visibleFilter: VisibleFilter<'multiGrid'>;
|
|
6
|
-
multiGrid: Array<
|
|
6
|
+
multiGrid: Array<DataFormatterMultiGridMultiGrid>;
|
|
7
|
+
container: DataFormatterMultiGridContainer;
|
|
7
8
|
}
|
|
8
9
|
export interface DataFormatterMultiGridPartial extends DataFormatterBasePartial<'multiGrid'> {
|
|
9
|
-
multiGrid?: Array<Partial<
|
|
10
|
+
multiGrid?: Array<Partial<DataFormatterMultiGridMultiGrid>>;
|
|
11
|
+
}
|
|
12
|
+
export interface DataFormatterMultiGridMultiGrid extends DataFormatterGrid {
|
|
13
|
+
slotIndex: number;
|
|
14
|
+
}
|
|
15
|
+
export interface DataFormatterMultiGridContainer {
|
|
16
|
+
gap: number;
|
|
17
|
+
rowAmount: number;
|
|
18
|
+
columnAmount: number;
|
|
10
19
|
}
|
package/package.json
CHANGED
|
@@ -140,8 +140,6 @@ export const createBaseChart: CreateBaseChart = <T extends ChartType>({ defaultD
|
|
|
140
140
|
description: preset.description ?? ''
|
|
141
141
|
}
|
|
142
142
|
})(options)
|
|
143
|
-
|
|
144
|
-
|
|
145
143
|
|
|
146
144
|
const sharedData$ = chartSubject.data$.pipe(shareReplay(1))
|
|
147
145
|
const shareAndMergedDataFormatter$ = chartSubject.dataFormatter$
|
|
@@ -165,7 +163,9 @@ export const createBaseChart: CreateBaseChart = <T extends ChartType>({ defaultD
|
|
|
165
163
|
.pipe(
|
|
166
164
|
takeUntil(destroy$),
|
|
167
165
|
startWith({}),
|
|
168
|
-
map((d) =>
|
|
166
|
+
map((d) => {
|
|
167
|
+
return mergeOptionsWithDefault(d, mergedPresetWithDefault.chartParams)
|
|
168
|
+
}),
|
|
169
169
|
shareReplay(1)
|
|
170
170
|
)
|
|
171
171
|
|
|
@@ -175,7 +175,9 @@ export const createBaseChart: CreateBaseChart = <T extends ChartType>({ defaultD
|
|
|
175
175
|
.pipe(
|
|
176
176
|
takeUntil(destroy$),
|
|
177
177
|
startWith({}),
|
|
178
|
-
map((d: any) =>
|
|
178
|
+
map((d: any) => {
|
|
179
|
+
return mergeOptionsWithDefault(d.padding ?? {}, PADDING_DEFAULT)
|
|
180
|
+
})
|
|
179
181
|
)
|
|
180
182
|
mergedPadding$
|
|
181
183
|
.pipe(
|
|
@@ -262,13 +264,16 @@ export const createBaseChart: CreateBaseChart = <T extends ChartType>({ defaultD
|
|
|
262
264
|
} catch (e) {
|
|
263
265
|
console.error(e)
|
|
264
266
|
throw new Error(e)
|
|
265
|
-
}
|
|
267
|
+
}
|
|
266
268
|
}),
|
|
267
269
|
catchError(() => EMPTY)
|
|
268
270
|
)
|
|
269
271
|
}),
|
|
270
272
|
shareReplay(1)
|
|
271
273
|
)
|
|
274
|
+
|
|
275
|
+
// subscribe - computedData組合了所有的chart參數,所以訂閱computedData可以一次訂閱所有的資料流
|
|
276
|
+
computedData$.subscribe()
|
|
272
277
|
|
|
273
278
|
// -- plugins --
|
|
274
279
|
const pluginEntityMap: any = {} // 用於destroy
|
package/src/defaults.ts
CHANGED
|
@@ -10,7 +10,7 @@ import type { DataRelationship } from './types/DataRelationship'
|
|
|
10
10
|
import type { DataFormatterBase, DataFormatterValueAxis, DataFormatterGroupAxis } from './types/DataFormatter'
|
|
11
11
|
import type { DataFormatterSeries } from './types/DataFormatterSeries'
|
|
12
12
|
import type { DataFormatterGrid } from './types/DataFormatterGrid'
|
|
13
|
-
import type { DataFormatterMultiGrid } from './types/DataFormatterMultiGrid'
|
|
13
|
+
import type { DataFormatterMultiGrid, DataFormatterMultiGridMultiGrid } from './types/DataFormatterMultiGrid'
|
|
14
14
|
import type { DataFormatterMultiValue } from './types/DataFormatterMultiValue'
|
|
15
15
|
import type { DataFormatterTree } from './types/DataFormatterTree'
|
|
16
16
|
import type { DataFormatterRelationship } from './types/DataFormatterRelationship'
|
|
@@ -180,24 +180,25 @@ export const DATA_FORMATTER_GRID_DEFAULT: DataFormatterGrid = {
|
|
|
180
180
|
// },
|
|
181
181
|
}
|
|
182
182
|
|
|
183
|
+
export const DATA_FORMATTER_MULTI_GRID_MULTI_GRID_DEFAULT: DataFormatterMultiGridMultiGrid = {
|
|
184
|
+
...DATA_FORMATTER_GRID_DEFAULT,
|
|
185
|
+
slotIndex: 0,
|
|
186
|
+
}
|
|
187
|
+
|
|
183
188
|
export const DATA_FORMATTER_MULTI_GRID_DEFAULT: DataFormatterMultiGrid = {
|
|
184
189
|
type: 'multiGrid',
|
|
185
190
|
visibleFilter: (datum, rowIndex, columnIndex, context) => true,
|
|
186
191
|
multiGrid: [
|
|
187
192
|
{
|
|
188
|
-
...
|
|
193
|
+
...DATA_FORMATTER_MULTI_GRID_MULTI_GRID_DEFAULT
|
|
189
194
|
},
|
|
190
|
-
// // @Q@ 暫時性的邏輯,之後colorsPredicate移除掉後,這邊也要移除(但colors使用的seriesIndex要接續前一組grid)
|
|
191
|
-
// {
|
|
192
|
-
// ...DATA_FORMATTER_GRID_DEFAULT,
|
|
193
|
-
// colorsPredicate: (datum, rowIndex, columnIndex, { data, chartParams, dataFormatter }) => {
|
|
194
|
-
// const seriesIndex = dataFormatter.grid.seriesType === 'row' ? rowIndex : columnIndex
|
|
195
|
-
// const reverseIndex = chartParams.colors[chartParams.colorScheme].series.length - 1 - seriesIndex
|
|
196
|
-
// return chartParams.colors[chartParams.colorScheme].series[reverseIndex]
|
|
197
|
-
// },
|
|
198
|
-
// }
|
|
199
195
|
],
|
|
200
196
|
// visibleGroupRange: null,
|
|
197
|
+
container: {
|
|
198
|
+
gap: 120,
|
|
199
|
+
rowAmount: 1,
|
|
200
|
+
columnAmount: 1
|
|
201
|
+
}
|
|
201
202
|
}
|
|
202
203
|
|
|
203
204
|
export const DATA_FORMATTER_MULTI_VALUE_DEFAULT: DataFormatterMultiValue = {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
shareReplay } from 'rxjs'
|
|
3
3
|
import type { ContextObserverFn } from '../types'
|
|
4
|
-
import {
|
|
4
|
+
import { multiGridEachDetailObservable, multiGridContainerObservable } from './multiGridObservables'
|
|
5
5
|
|
|
6
6
|
export const createMultiGridContextObserver: ContextObserverFn<'multiGrid'> = ({ subject, observer }) => {
|
|
7
7
|
|
|
8
|
-
const
|
|
8
|
+
const multiGridEachDetail$ = multiGridEachDetailObservable({
|
|
9
9
|
fullDataFormatter$: observer.fullDataFormatter$,
|
|
10
10
|
computedData$: observer.computedData$,
|
|
11
11
|
layout$: observer.layout$,
|
|
@@ -15,12 +15,20 @@ export const createMultiGridContextObserver: ContextObserverFn<'multiGrid'> = ({
|
|
|
15
15
|
shareReplay(1)
|
|
16
16
|
)
|
|
17
17
|
|
|
18
|
+
const multiGridContainer$ = multiGridContainerObservable({
|
|
19
|
+
computedData$: observer.computedData$,
|
|
20
|
+
fullDataFormatter$: observer.fullDataFormatter$,
|
|
21
|
+
fullChartParams$: observer.fullChartParams$,
|
|
22
|
+
layout$: observer.layout$,
|
|
23
|
+
})
|
|
24
|
+
|
|
18
25
|
return {
|
|
19
26
|
fullParams$: observer.fullParams$,
|
|
20
27
|
fullChartParams$: observer.fullChartParams$,
|
|
21
28
|
fullDataFormatter$: observer.fullDataFormatter$,
|
|
22
29
|
computedData$: observer.computedData$,
|
|
23
30
|
layout$: observer.layout$,
|
|
24
|
-
|
|
31
|
+
multiGridEachDetail$,
|
|
32
|
+
multiGridContainer$
|
|
25
33
|
}
|
|
26
34
|
}
|
|
@@ -24,6 +24,7 @@ import type {
|
|
|
24
24
|
DataFormatterContext,
|
|
25
25
|
DataFormatterValueAxis,
|
|
26
26
|
DataFormatterGroupAxis,
|
|
27
|
+
DataFormatterMultiGridContainer,
|
|
27
28
|
EventMultiGrid,
|
|
28
29
|
HighlightTarget,
|
|
29
30
|
Layout,
|
|
@@ -40,8 +41,9 @@ import {
|
|
|
40
41
|
gridAxesOppositeTransformObservable,
|
|
41
42
|
gridAxesSizeObservable,
|
|
42
43
|
gridVisibleComputedDataObservable } from '../grid/gridObservables'
|
|
44
|
+
import { DATA_FORMATTER_MULTI_GRID_MULTI_GRID_DEFAULT } from '../defaults'
|
|
43
45
|
|
|
44
|
-
export const
|
|
46
|
+
export const multiGridEachDetailObservable = ({ fullDataFormatter$, computedData$, layout$, fullChartParams$, event$ }: {
|
|
45
47
|
fullDataFormatter$: Observable<DataFormatterTypeMap<'multiGrid'>>
|
|
46
48
|
computedData$: Observable<ComputedDataTypeMap<'multiGrid'>>
|
|
47
49
|
layout$: Observable<Layout>
|
|
@@ -151,4 +153,60 @@ export const multiGridObservable = ({ fullDataFormatter$, computedData$, layout$
|
|
|
151
153
|
})
|
|
152
154
|
})
|
|
153
155
|
)
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
// 每一個grid的container位置
|
|
161
|
+
export const multiGridContainerObservable = ({ computedData$, fullDataFormatter$, fullChartParams$, layout$ }: {
|
|
162
|
+
computedData$: Observable<ComputedDataTypeMap<'multiGrid'>>
|
|
163
|
+
fullDataFormatter$: Observable<DataFormatterTypeMap<'multiGrid'>>
|
|
164
|
+
fullChartParams$: Observable<ChartParams>
|
|
165
|
+
layout$: Observable<Layout>
|
|
166
|
+
}) => {
|
|
167
|
+
function calcBox (layout: Layout, container: DataFormatterMultiGridContainer, rowIndex: number, columnIndex: number) {
|
|
168
|
+
const { gap, rowAmount, columnAmount } = container
|
|
169
|
+
const width = (layout.width - (gap * (columnAmount - 1))) / columnAmount
|
|
170
|
+
const height = (layout.height - (gap * (rowAmount - 1))) / rowAmount
|
|
171
|
+
const x = columnIndex * width + (columnIndex * gap)
|
|
172
|
+
const y = rowIndex * height + (rowIndex * gap)
|
|
173
|
+
const translate: [number, number] = [x, y]
|
|
174
|
+
const scale: [number, number] = [width / layout.width, height / layout.height]
|
|
175
|
+
|
|
176
|
+
return {
|
|
177
|
+
translate,
|
|
178
|
+
scale
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
const multiGridContainer$ = combineLatest({
|
|
183
|
+
computedData: computedData$,
|
|
184
|
+
fullDataFormatter: fullDataFormatter$,
|
|
185
|
+
fullChartParams: fullChartParams$,
|
|
186
|
+
layout: layout$,
|
|
187
|
+
}).pipe(
|
|
188
|
+
switchMap(async (d) => d),
|
|
189
|
+
map(data => {
|
|
190
|
+
|
|
191
|
+
const defaultGrid = data.fullDataFormatter.multiGrid[0] ?? DATA_FORMATTER_MULTI_GRID_MULTI_GRID_DEFAULT
|
|
192
|
+
|
|
193
|
+
const boxArr = data.computedData.map((gridData, gridIndex) => {
|
|
194
|
+
const grid = data.fullDataFormatter.multiGrid[gridIndex] ?? defaultGrid
|
|
195
|
+
const columnIndex = grid.slotIndex % data.fullDataFormatter.container.columnAmount
|
|
196
|
+
const rowIndex = Math.floor(grid.slotIndex / data.fullDataFormatter.container.columnAmount)
|
|
197
|
+
const { translate, scale } = calcBox(data.layout, data.fullDataFormatter.container, rowIndex, columnIndex)
|
|
198
|
+
|
|
199
|
+
return {
|
|
200
|
+
slotIndex: grid.slotIndex,
|
|
201
|
+
rowIndex,
|
|
202
|
+
columnIndex,
|
|
203
|
+
translate,
|
|
204
|
+
scale,
|
|
205
|
+
}
|
|
206
|
+
})
|
|
207
|
+
return boxArr
|
|
208
|
+
}),
|
|
209
|
+
)
|
|
210
|
+
|
|
211
|
+
return multiGridContainer$
|
|
154
212
|
}
|
|
@@ -4,7 +4,8 @@ import type { ComputedDataGrid, ComputedDatumGrid } from './ComputedDataGrid'
|
|
|
4
4
|
import type { TransformData } from './TransformData'
|
|
5
5
|
|
|
6
6
|
export interface ContextObserverMultiGrid<PluginParams> extends ContextObserverBase<'multiGrid', PluginParams> {
|
|
7
|
-
|
|
7
|
+
multiGridEachDetail$: Observable<MultiGridObservableAll[]>
|
|
8
|
+
multiGridContainer$: Observable<GridContainerBox[]>
|
|
8
9
|
}
|
|
9
10
|
|
|
10
11
|
export interface MultiGridObservableAll {
|
|
@@ -16,4 +17,12 @@ export interface MultiGridObservableAll {
|
|
|
16
17
|
SeriesDataMap$: Observable<Map<string, ComputedDatumGrid[]>>
|
|
17
18
|
GroupDataMap$: Observable<Map<string, ComputedDatumGrid[]>>
|
|
18
19
|
visibleComputedData$: Observable<ComputedDataGrid>
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface GridContainerBox {
|
|
23
|
+
slotIndex: number
|
|
24
|
+
rowIndex: number
|
|
25
|
+
columnIndex: number
|
|
26
|
+
translate: [number, number]
|
|
27
|
+
scale: [number, number]
|
|
19
28
|
}
|
|
@@ -10,12 +10,25 @@ import type { AxisPosition } from './Axis'
|
|
|
10
10
|
|
|
11
11
|
export interface DataFormatterMultiGrid extends DataFormatterBase<'multiGrid'> {
|
|
12
12
|
visibleFilter: VisibleFilter<'multiGrid'>
|
|
13
|
-
multiGrid: Array<
|
|
13
|
+
multiGrid: Array<DataFormatterMultiGridMultiGrid>
|
|
14
14
|
// visibleGroupRange: [number, number] | null
|
|
15
|
+
container: DataFormatterMultiGridContainer
|
|
15
16
|
}
|
|
16
17
|
|
|
17
18
|
export interface DataFormatterMultiGridPartial extends DataFormatterBasePartial<'multiGrid'> {
|
|
18
|
-
multiGrid?: Array<Partial<
|
|
19
|
+
multiGrid?: Array<Partial<DataFormatterMultiGridMultiGrid>>
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// 比grid還多出來的額外參數
|
|
23
|
+
export interface DataFormatterMultiGridMultiGrid extends DataFormatterGrid {
|
|
24
|
+
slotIndex: number
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// container
|
|
28
|
+
export interface DataFormatterMultiGridContainer {
|
|
29
|
+
gap: number
|
|
30
|
+
rowAmount: number
|
|
31
|
+
columnAmount: number
|
|
19
32
|
}
|
|
20
33
|
|
|
21
34
|
// multiGrid欄位
|