@orbcharts/core 3.0.0-alpha.31 → 3.0.0-alpha.32
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/orbcharts-core.es.js +593 -556
- package/dist/orbcharts-core.umd.js +2 -2
- package/dist/src/multiGrid/multiGridObservables.d.ts +7 -8
- package/dist/src/types/ContextObserverMultiGrid.d.ts +8 -0
- package/package.json +1 -1
- package/src/base/createBaseChart.ts +10 -5
- package/src/multiGrid/createMultiGridContextObserver.ts +10 -2
- package/src/multiGrid/multiGridObservables.ts +15 -15
- package/src/types/ContextObserverMultiGrid.ts +9 -0
@@ -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
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import {
|
2
2
|
shareReplay } from 'rxjs'
|
3
3
|
import type { ContextObserverFn } from '../types'
|
4
|
-
import { multiGridEachDetailObservable } from './multiGridObservables'
|
4
|
+
import { multiGridEachDetailObservable, multiGridContainerObservable } from './multiGridObservables'
|
5
5
|
|
6
6
|
export const createMultiGridContextObserver: ContextObserverFn<'multiGrid'> = ({ subject, observer }) => {
|
7
7
|
|
@@ -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
|
-
multiGridEachDetail
|
31
|
+
multiGridEachDetail$,
|
32
|
+
multiGridContainer$
|
25
33
|
}
|
26
34
|
}
|
@@ -41,6 +41,7 @@ import {
|
|
41
41
|
gridAxesOppositeTransformObservable,
|
42
42
|
gridAxesSizeObservable,
|
43
43
|
gridVisibleComputedDataObservable } from '../grid/gridObservables'
|
44
|
+
import { DATA_FORMATTER_MULTI_GRID_MULTI_GRID_DEFAULT } from '../defaults'
|
44
45
|
|
45
46
|
export const multiGridEachDetailObservable = ({ fullDataFormatter$, computedData$, layout$, fullChartParams$, event$ }: {
|
46
47
|
fullDataFormatter$: Observable<DataFormatterTypeMap<'multiGrid'>>
|
@@ -154,26 +155,21 @@ export const multiGridEachDetailObservable = ({ fullDataFormatter$, computedData
|
|
154
155
|
)
|
155
156
|
}
|
156
157
|
|
157
|
-
|
158
|
-
slotIndex: number
|
159
|
-
rowIndex: number
|
160
|
-
columnIndex: number
|
161
|
-
translate: [number, number]
|
162
|
-
scale: [number, number]
|
163
|
-
}
|
158
|
+
|
164
159
|
|
165
160
|
// 每一個grid的container位置
|
166
|
-
export const multiGridContainerObservable = ({ fullDataFormatter$,
|
161
|
+
export const multiGridContainerObservable = ({ computedData$, fullDataFormatter$, fullChartParams$, layout$ }: {
|
162
|
+
computedData$: Observable<ComputedDataTypeMap<'multiGrid'>>
|
167
163
|
fullDataFormatter$: Observable<DataFormatterTypeMap<'multiGrid'>>
|
168
|
-
layout$: Observable<Layout>
|
169
164
|
fullChartParams$: Observable<ChartParams>
|
165
|
+
layout$: Observable<Layout>
|
170
166
|
}) => {
|
171
167
|
function calcBox (layout: Layout, container: DataFormatterMultiGridContainer, rowIndex: number, columnIndex: number) {
|
172
168
|
const { gap, rowAmount, columnAmount } = container
|
173
|
-
const width = (layout.width
|
174
|
-
const height = (layout.height
|
169
|
+
const width = (layout.width - (gap * (columnAmount - 1))) / columnAmount
|
170
|
+
const height = (layout.height - (gap * (rowAmount - 1))) / rowAmount
|
175
171
|
const x = columnIndex * width + (columnIndex * gap)
|
176
|
-
const y = rowIndex * height + (
|
172
|
+
const y = rowIndex * height + (rowIndex * gap)
|
177
173
|
const translate: [number, number] = [x, y]
|
178
174
|
const scale: [number, number] = [width / layout.width, height / layout.height]
|
179
175
|
|
@@ -184,14 +180,18 @@ export const multiGridContainerObservable = ({ fullDataFormatter$, layout$, full
|
|
184
180
|
}
|
185
181
|
|
186
182
|
const multiGridContainer$ = combineLatest({
|
183
|
+
computedData: computedData$,
|
187
184
|
fullDataFormatter: fullDataFormatter$,
|
185
|
+
fullChartParams: fullChartParams$,
|
188
186
|
layout: layout$,
|
189
|
-
fullChartParams: fullChartParams$
|
190
187
|
}).pipe(
|
191
188
|
switchMap(async (d) => d),
|
192
189
|
map(data => {
|
193
|
-
|
194
|
-
const
|
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
195
|
const columnIndex = grid.slotIndex % data.fullDataFormatter.container.columnAmount
|
196
196
|
const rowIndex = Math.floor(grid.slotIndex / data.fullDataFormatter.container.columnAmount)
|
197
197
|
const { translate, scale } = calcBox(data.layout, data.fullDataFormatter.container, rowIndex, columnIndex)
|
@@ -5,6 +5,7 @@ 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
|
}
|