@orbcharts/core 3.0.0-alpha.31 → 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 +1668 -1473
- 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 +8 -21
- package/dist/src/types/ContextObserverGrid.d.ts +15 -2
- package/dist/src/types/ContextObserverMultiGrid.d.ts +3 -16
- 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 +13 -8
- 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/createMultiGridContextObserver.ts +10 -2
- package/src/multiGrid/multiGridObservables.ts +196 -122
- package/src/types/ContextObserverGrid.ts +20 -2
- package/src/types/ContextObserverMultiGrid.ts +19 -11
- package/src/types/DataFormatterGrid.ts +28 -13
- package/src/types/DataFormatterMultiGrid.ts +14 -12
- package/src/utils/orbchartsUtils.ts +26 -10
@@ -1,18 +1,23 @@
|
|
1
1
|
import { Observable } from 'rxjs';
|
2
|
-
import { ComputedDataTypeMap, DataFormatterTypeMap, DataFormatterGrid, Layout, TransformData } from '../types';
|
2
|
+
import { ChartParams, ComputedDataTypeMap, DataFormatterTypeMap, DataFormatterGrid, ContainerPosition, Layout, TransformData } from '../types';
|
3
3
|
|
4
4
|
export declare const gridAxesTransformObservable: ({ fullDataFormatter$, layout$ }: {
|
5
5
|
fullDataFormatter$: Observable<DataFormatterTypeMap<"grid">>;
|
6
6
|
layout$: Observable<Layout>;
|
7
7
|
}) => Observable<TransformData>;
|
8
|
+
export declare const gridAxesReverseTransformObservable: ({ gridAxesTransform$ }: {
|
9
|
+
gridAxesTransform$: Observable<TransformData>;
|
10
|
+
}) => Observable<TransformData>;
|
8
11
|
export declare const gridGraphicTransformObservable: ({ computedData$, fullDataFormatter$, layout$ }: {
|
9
12
|
computedData$: Observable<ComputedDataTypeMap<"grid">>;
|
10
13
|
fullDataFormatter$: Observable<DataFormatterTypeMap<"grid">>;
|
11
14
|
layout$: Observable<Layout>;
|
12
15
|
}) => Observable<TransformData>;
|
13
|
-
export declare const
|
16
|
+
export declare const gridGraphicReverseScaleObservable: ({ gridContainer$, gridAxesTransform$, gridGraphicTransform$ }: {
|
17
|
+
gridContainer$: Observable<ContainerPosition[]>;
|
14
18
|
gridAxesTransform$: Observable<TransformData>;
|
15
|
-
|
19
|
+
gridGraphicTransform$: Observable<TransformData>;
|
20
|
+
}) => Observable<[number, number][]>;
|
16
21
|
export declare const gridAxesSizeObservable: ({ fullDataFormatter$, layout$ }: {
|
17
22
|
fullDataFormatter$: Observable<DataFormatterGrid>;
|
18
23
|
layout$: Observable<Layout>;
|
@@ -20,6 +25,25 @@ export declare const gridAxesSizeObservable: ({ fullDataFormatter$, layout$ }: {
|
|
20
25
|
width: number;
|
21
26
|
height: number;
|
22
27
|
}>;
|
28
|
+
export declare const existedSeriesLabelsObservable: ({ computedData$ }: {
|
29
|
+
computedData$: Observable<ComputedDataTypeMap<"grid">>;
|
30
|
+
}) => Observable<string[]>;
|
23
31
|
export declare const gridVisibleComputedDataObservable: ({ computedData$ }: {
|
24
32
|
computedData$: Observable<ComputedDataTypeMap<"grid">>;
|
25
33
|
}) => Observable<import('../types').ComputedDatumGrid[][]>;
|
34
|
+
export declare const isSeriesPositionSeprateObservable: ({ computedData$, fullDataFormatter$ }: {
|
35
|
+
computedData$: Observable<ComputedDataTypeMap<"grid">>;
|
36
|
+
fullDataFormatter$: Observable<DataFormatterTypeMap<"grid">>;
|
37
|
+
}) => Observable<boolean>;
|
38
|
+
export declare const gridContainerObservable: ({ computedData$, fullDataFormatter$, fullChartParams$, layout$ }: {
|
39
|
+
computedData$: Observable<ComputedDataTypeMap<"grid">>;
|
40
|
+
fullDataFormatter$: Observable<DataFormatterTypeMap<"grid">>;
|
41
|
+
fullChartParams$: Observable<ChartParams>;
|
42
|
+
layout$: Observable<Layout>;
|
43
|
+
}) => Observable<{
|
44
|
+
slotIndex: number;
|
45
|
+
rowIndex: number;
|
46
|
+
columnIndex: number;
|
47
|
+
translate: [number, number];
|
48
|
+
scale: [number, number];
|
49
|
+
}[]>;
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { Subject, Observable } from 'rxjs';
|
2
|
-
import { ChartParams, ComputedDataTypeMap, DataFormatterTypeMap, EventMultiGrid, Layout,
|
2
|
+
import { ChartParams, ComputedDataTypeMap, DataFormatterTypeMap, EventMultiGrid, Layout, ContextObserverGridDetail } from '../types';
|
3
3
|
|
4
4
|
export declare const multiGridEachDetailObservable: ({ fullDataFormatter$, computedData$, layout$, fullChartParams$, event$ }: {
|
5
5
|
fullDataFormatter$: Observable<DataFormatterTypeMap<"multiGrid">>;
|
@@ -7,29 +7,16 @@ export declare const multiGridEachDetailObservable: ({ fullDataFormatter$, compu
|
|
7
7
|
layout$: Observable<Layout>;
|
8
8
|
fullChartParams$: Observable<ChartParams>;
|
9
9
|
event$: Subject<EventMultiGrid>;
|
10
|
+
}) => Observable<ContextObserverGridDetail[]>;
|
11
|
+
export declare const multiGridContainerObservable: ({ computedData$, fullDataFormatter$, fullChartParams$, layout$ }: {
|
12
|
+
computedData$: Observable<ComputedDataTypeMap<"multiGrid">>;
|
13
|
+
fullDataFormatter$: Observable<DataFormatterTypeMap<"multiGrid">>;
|
14
|
+
fullChartParams$: Observable<ChartParams>;
|
15
|
+
layout$: Observable<Layout>;
|
10
16
|
}) => Observable<{
|
11
|
-
gridAxesTransform$: Observable<TransformData>;
|
12
|
-
gridGraphicTransform$: Observable<TransformData>;
|
13
|
-
gridAxesOppositeTransform$: Observable<TransformData>;
|
14
|
-
gridAxesSize$: Observable<{
|
15
|
-
width: number;
|
16
|
-
height: number;
|
17
|
-
}>;
|
18
|
-
gridHighlight$: Observable<string[]>;
|
19
|
-
SeriesDataMap$: Observable<Map<string, import('../types').ComputedDatumGrid[]>>;
|
20
|
-
GroupDataMap$: Observable<Map<string, import('../types').ComputedDatumGrid[]>>;
|
21
|
-
visibleComputedData$: Observable<import('../types').ComputedDatumGrid[][]>;
|
22
|
-
}[]>;
|
23
|
-
interface GridContainerBox {
|
24
17
|
slotIndex: number;
|
25
18
|
rowIndex: number;
|
26
19
|
columnIndex: number;
|
27
20
|
translate: [number, number];
|
28
21
|
scale: [number, number];
|
29
|
-
}
|
30
|
-
export declare const multiGridContainerObservable: ({ fullDataFormatter$, layout$, fullChartParams$ }: {
|
31
|
-
fullDataFormatter$: Observable<DataFormatterTypeMap<"multiGrid">>;
|
32
|
-
layout$: Observable<Layout>;
|
33
|
-
fullChartParams$: Observable<ChartParams>;
|
34
|
-
}) => Observable<GridContainerBox[]>;
|
35
|
-
export {};
|
22
|
+
}[][]>;
|
@@ -3,16 +3,29 @@ import { ContextObserverBase } from './ContextObserver';
|
|
3
3
|
import { ComputedDataGrid, ComputedDatumGrid } from './ComputedDataGrid';
|
4
4
|
import { TransformData } from './TransformData';
|
5
5
|
|
6
|
-
export interface ContextObserverGrid<PluginParams> extends ContextObserverBase<'grid', PluginParams
|
6
|
+
export interface ContextObserverGrid<PluginParams> extends ContextObserverBase<'grid', PluginParams>, ContextObserverGridDetail {
|
7
|
+
}
|
8
|
+
export interface ContextObserverGridDetail {
|
9
|
+
gridContainer$: Observable<ContainerPosition[]>;
|
7
10
|
gridAxesTransform$: Observable<TransformData>;
|
11
|
+
gridAxesReverseTransform$: Observable<TransformData>;
|
8
12
|
gridGraphicTransform$: Observable<TransformData>;
|
9
|
-
|
13
|
+
gridGraphicReverseScale$: Observable<[number, number][]>;
|
10
14
|
gridAxesSize$: Observable<{
|
11
15
|
width: number;
|
12
16
|
height: number;
|
13
17
|
}>;
|
14
18
|
gridHighlight$: Observable<string[]>;
|
19
|
+
existedSeriesLabels$: Observable<string[]>;
|
15
20
|
SeriesDataMap$: Observable<Map<string, ComputedDatumGrid[]>>;
|
16
21
|
GroupDataMap$: Observable<Map<string, ComputedDatumGrid[]>>;
|
17
22
|
visibleComputedData$: Observable<ComputedDataGrid>;
|
23
|
+
isSeriesPositionSeprate$: Observable<boolean>;
|
24
|
+
}
|
25
|
+
export interface ContainerPosition {
|
26
|
+
slotIndex: number;
|
27
|
+
rowIndex: number;
|
28
|
+
columnIndex: number;
|
29
|
+
translate: [number, number];
|
30
|
+
scale: [number, number];
|
18
31
|
}
|
@@ -1,21 +1,8 @@
|
|
1
1
|
import { Observable } from 'rxjs';
|
2
2
|
import { ContextObserverBase } from './ContextObserver';
|
3
|
-
import {
|
4
|
-
import { TransformData } from './TransformData';
|
3
|
+
import { ContainerPosition, ContextObserverGridDetail } from './ContextObserverGrid';
|
5
4
|
|
6
5
|
export interface ContextObserverMultiGrid<PluginParams> extends ContextObserverBase<'multiGrid', PluginParams> {
|
7
|
-
multiGridEachDetail$: Observable<
|
8
|
-
|
9
|
-
export interface MultiGridObservableAll {
|
10
|
-
gridAxesTransform$: Observable<TransformData>;
|
11
|
-
gridGraphicTransform$: Observable<TransformData>;
|
12
|
-
gridAxesOppositeTransform$: Observable<TransformData>;
|
13
|
-
gridAxesSize$: Observable<{
|
14
|
-
width: number;
|
15
|
-
height: number;
|
16
|
-
}>;
|
17
|
-
gridHighlight$: Observable<string[]>;
|
18
|
-
SeriesDataMap$: Observable<Map<string, ComputedDatumGrid[]>>;
|
19
|
-
GroupDataMap$: Observable<Map<string, ComputedDatumGrid[]>>;
|
20
|
-
visibleComputedData$: Observable<ComputedDataGrid>;
|
6
|
+
multiGridEachDetail$: Observable<ContextObserverGridDetail[]>;
|
7
|
+
multiGridContainer$: Observable<ContainerPosition[][]>;
|
21
8
|
}
|
@@ -1,19 +1,37 @@
|
|
1
1
|
import { DataFormatterBase, DataFormatterBasePartial, DataFormatterValueAxis, DataFormatterGroupAxis, VisibleFilter } from './DataFormatter';
|
2
2
|
|
3
|
-
export type
|
3
|
+
export type SeriesDirection = 'row' | 'column';
|
4
4
|
export interface DataFormatterGrid extends DataFormatterBase<'grid'> {
|
5
|
-
visibleFilter: VisibleFilter<'grid'>;
|
6
5
|
grid: DataFormatterGridGrid;
|
6
|
+
container: DataFormatterGridContainer;
|
7
|
+
}
|
8
|
+
export interface DataFormatterGridPartial extends DataFormatterBasePartial<'grid'> {
|
9
|
+
grid?: DataFormatterGridGridPartial;
|
10
|
+
container?: Partial<DataFormatterGridContainer>;
|
11
|
+
}
|
12
|
+
export interface DataFormatterGridGrid {
|
13
|
+
visibleFilter: VisibleFilter<'grid'>;
|
14
|
+
gridData: DataFormatterGridGridData;
|
7
15
|
valueAxis: DataFormatterValueAxis;
|
8
16
|
groupAxis: DataFormatterGroupAxis;
|
17
|
+
slotIndex: number | null;
|
18
|
+
seriesSlotIndexes: number[] | null;
|
9
19
|
}
|
10
|
-
export interface
|
11
|
-
|
20
|
+
export interface DataFormatterGridGridPartial {
|
21
|
+
visibleFilter?: VisibleFilter<'grid'>;
|
22
|
+
gridData?: Partial<DataFormatterGridGridData>;
|
12
23
|
valueAxis?: Partial<DataFormatterValueAxis>;
|
13
24
|
groupAxis?: Partial<DataFormatterGroupAxis>;
|
25
|
+
slotIndex?: number | null;
|
26
|
+
seriesSlotIndexes?: number[] | null;
|
14
27
|
}
|
15
|
-
export interface
|
28
|
+
export interface DataFormatterGridContainer {
|
29
|
+
gap: number;
|
30
|
+
rowAmount: number;
|
31
|
+
columnAmount: number;
|
32
|
+
}
|
33
|
+
export interface DataFormatterGridGridData {
|
34
|
+
seriesDirection: SeriesDirection;
|
16
35
|
rowLabels: string[];
|
17
36
|
columnLabels: string[];
|
18
|
-
seriesType: SeriesType;
|
19
37
|
}
|
@@ -1,19 +1,19 @@
|
|
1
1
|
import { VisibleFilter, DataFormatterBase, DataFormatterBasePartial } from './DataFormatter';
|
2
|
-
import {
|
2
|
+
import { DataFormatterGridGrid, DataFormatterGridGridPartial, DataFormatterGridContainer } from './DataFormatterGrid';
|
3
3
|
|
4
4
|
export interface DataFormatterMultiGrid extends DataFormatterBase<'multiGrid'> {
|
5
5
|
visibleFilter: VisibleFilter<'multiGrid'>;
|
6
|
-
|
6
|
+
gridList: Array<DataFormatterGridGrid>;
|
7
7
|
container: DataFormatterMultiGridContainer;
|
8
8
|
}
|
9
9
|
export interface DataFormatterMultiGridPartial extends DataFormatterBasePartial<'multiGrid'> {
|
10
|
-
|
10
|
+
visibleFilter?: VisibleFilter<'multiGrid'>;
|
11
|
+
gridList?: Array<DataFormatterGridGridPartial>;
|
12
|
+
container?: Partial<DataFormatterMultiGridContainer>;
|
11
13
|
}
|
12
|
-
export interface
|
13
|
-
slotIndex: number;
|
14
|
+
export interface DataFormatterMultiGridGrid extends DataFormatterGridGrid {
|
14
15
|
}
|
15
|
-
export interface
|
16
|
-
|
17
|
-
|
18
|
-
columnAmount: number;
|
16
|
+
export interface DataFormatterMultiGridGridPartial extends DataFormatterGridGridPartial {
|
17
|
+
}
|
18
|
+
export interface DataFormatterMultiGridContainer extends DataFormatterGridContainer {
|
19
19
|
}
|
@@ -5,7 +5,8 @@ import { DataSeries } from '../types/DataSeries';
|
|
5
5
|
import { DataGrid, DataGridDatum } from '../types/DataGrid';
|
6
6
|
import { DataMultiGrid } from '../types/DataMultiGrid';
|
7
7
|
import { DataMultiValue } from '../types/DataMultiValue';
|
8
|
-
import {
|
8
|
+
import { SeriesDirection, DataFormatterGrid, DataFormatterGridContainer } from '../types/DataFormatterGrid';
|
9
|
+
import { Layout } from '../types/Layout';
|
9
10
|
import * as d3 from 'd3';
|
10
11
|
export declare function formatValueToLabel(value: any, valueFormatter: string | ((text: d3.NumberValue) => string)): string;
|
11
12
|
export declare function createDefaultDatumId(chartTypeOrPrefix: string, levelOneIndex: number, levelTwoIndex: number, levelThreeIndex?: number): string;
|
@@ -29,5 +30,9 @@ export declare function getMinAndMaxSeries(data: DataSeries): [number, number];
|
|
29
30
|
export declare function getMinAndMaxGrid(data: DataGrid): [number, number];
|
30
31
|
export declare function getMinAndMaxMultiGrid(data: DataMultiGrid): [number, number];
|
31
32
|
export declare function getMinAndMaxMultiValue(data: DataMultiValue, valueIndex?: number): [number, number];
|
32
|
-
export declare function transposeData<T>(
|
33
|
+
export declare function transposeData<T>(seriesDirection: SeriesDirection, data: T[][]): T[][];
|
33
34
|
export declare function seriesColorPredicate(seriesIndex: number, chartParams: ChartParams): string;
|
35
|
+
export declare function calcGridContainerPosition(layout: Layout, container: DataFormatterGridContainer, rowIndex: number, columnIndex: number): {
|
36
|
+
translate: [number, number];
|
37
|
+
scale: [number, number];
|
38
|
+
};
|
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$
|
@@ -151,10 +149,10 @@ export const createBaseChart: CreateBaseChart = <T extends ChartType>({ defaultD
|
|
151
149
|
map((dataFormatter) => {
|
152
150
|
const mergedData = mergeOptionsWithDefault(dataFormatter, mergedPresetWithDefault.dataFormatter)
|
153
151
|
|
154
|
-
if (chartType === 'multiGrid' && (dataFormatter as DataFormatterPartialTypeMap<'multiGrid'>).
|
152
|
+
if (chartType === 'multiGrid' && (dataFormatter as DataFormatterPartialTypeMap<'multiGrid'>).gridList != null) {
|
155
153
|
// multiGrid欄位為陣列,需要各別來merge預設值
|
156
|
-
(mergedData as DataFormatterTypeMap<'multiGrid'>).
|
157
|
-
return mergeOptionsWithDefault(d, (mergedPresetWithDefault.dataFormatter as DataFormatterTypeMap<'multiGrid'>).
|
154
|
+
(mergedData as DataFormatterTypeMap<'multiGrid'>).gridList = (dataFormatter as DataFormatterPartialTypeMap<'multiGrid'>).gridList.map(d => {
|
155
|
+
return mergeOptionsWithDefault(d, (mergedPresetWithDefault.dataFormatter as DataFormatterTypeMap<'multiGrid'>).gridList[0])
|
158
156
|
})
|
159
157
|
}
|
160
158
|
return mergedData
|
@@ -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
@@ -9,8 +9,8 @@ import type { DataTree } from './types/DataTree'
|
|
9
9
|
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
|
-
import type { DataFormatterGrid } from './types/DataFormatterGrid'
|
13
|
-
import type { DataFormatterMultiGrid,
|
12
|
+
import type { DataFormatterGrid, DataFormatterGridGrid } from './types/DataFormatterGrid'
|
13
|
+
import type { DataFormatterMultiGrid, DataFormatterMultiGridGrid } 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'
|
@@ -158,42 +158,55 @@ export const DATA_FORMATTER_SERIES_DEFAULT: DataFormatterSeries = {
|
|
158
158
|
sort: null,
|
159
159
|
}
|
160
160
|
|
161
|
-
export const
|
162
|
-
// ...DATA_FORMATTER_WITH_VALUE,
|
163
|
-
type: 'grid',
|
161
|
+
export const DATA_FORMATTER_GRID_GRID_DEFAULT: DataFormatterGridGrid = {
|
164
162
|
visibleFilter: (datum, rowIndex, columnIndex, context) => true,
|
165
|
-
|
166
|
-
|
163
|
+
gridData: {
|
164
|
+
seriesDirection: 'row',
|
167
165
|
rowLabels: [],
|
168
|
-
// rowLabelFormat: label => label,
|
169
|
-
// columnUnitLabel: '',
|
170
166
|
columnLabels: [],
|
171
|
-
// columnLabelFormat: label => label,
|
172
|
-
seriesType: 'row'
|
173
167
|
},
|
174
168
|
valueAxis: { ...DATA_FORMATTER_VALUE_AXIS },
|
175
169
|
groupAxis: { ...DATA_FORMATTER_GROUP_AXIS, },
|
170
|
+
slotIndex: 0,
|
171
|
+
seriesSlotIndexes: null
|
172
|
+
}
|
173
|
+
|
174
|
+
export const DATA_FORMATTER_GRID_DEFAULT: DataFormatterGrid = {
|
175
|
+
// ...DATA_FORMATTER_WITH_VALUE,
|
176
|
+
type: 'grid',
|
177
|
+
grid: {
|
178
|
+
...DATA_FORMATTER_GRID_GRID_DEFAULT
|
179
|
+
},
|
180
|
+
container: {
|
181
|
+
gap: 120,
|
182
|
+
rowAmount: 1,
|
183
|
+
columnAmount: 1
|
184
|
+
}
|
176
185
|
// visibleGroupRange: null,
|
177
186
|
// colorsPredicate: (datum, rowIndex, columnIndex, { chartParams, dataFormatter }) => {
|
178
|
-
// const seriesIndex = dataFormatter.grid.
|
187
|
+
// const seriesIndex = dataFormatter.grid.seriesDirection === 'row' ? rowIndex : columnIndex
|
179
188
|
// return chartParams.colors[chartParams.colorScheme].series[seriesIndex]
|
180
189
|
// },
|
181
190
|
}
|
182
191
|
|
183
|
-
export const DATA_FORMATTER_MULTI_GRID_MULTI_GRID_DEFAULT: DataFormatterMultiGridMultiGrid = {
|
184
|
-
|
185
|
-
|
192
|
+
// export const DATA_FORMATTER_MULTI_GRID_MULTI_GRID_DEFAULT: DataFormatterMultiGridMultiGrid = {
|
193
|
+
// ...DATA_FORMATTER_GRID_DEFAULT,
|
194
|
+
// slotIndex: 0,
|
195
|
+
// seriesSlotIndexes: null
|
196
|
+
// }
|
197
|
+
|
198
|
+
export const DATA_FORMATTER_MULTI_GRID_GRID_DEFAULT: DataFormatterMultiGridGrid = {
|
199
|
+
...DATA_FORMATTER_GRID_GRID_DEFAULT
|
186
200
|
}
|
187
201
|
|
188
202
|
export const DATA_FORMATTER_MULTI_GRID_DEFAULT: DataFormatterMultiGrid = {
|
189
203
|
type: 'multiGrid',
|
190
204
|
visibleFilter: (datum, rowIndex, columnIndex, context) => true,
|
191
|
-
|
205
|
+
gridList: [
|
192
206
|
{
|
193
|
-
...
|
207
|
+
...DATA_FORMATTER_MULTI_GRID_GRID_DEFAULT
|
194
208
|
},
|
195
209
|
],
|
196
|
-
// visibleGroupRange: null,
|
197
210
|
container: {
|
198
211
|
gap: 120,
|
199
212
|
rowAmount: 1,
|
@@ -49,7 +49,7 @@ export const computeBaseGridData = (context: DataFormatterContext<'grid'>, chart
|
|
49
49
|
return d.map((_d, _i) => {
|
50
50
|
|
51
51
|
// const _color = dataFormatter.colorsPredicate(_d, i, _i, context)
|
52
|
-
const _visible = dataFormatter.visibleFilter(_d, i, _i, context)
|
52
|
+
const _visible = dataFormatter.grid.visibleFilter(_d, i, _i, context)
|
53
53
|
|
54
54
|
const datum: DataGridDatumTemp = _d == null
|
55
55
|
? {
|
@@ -85,21 +85,26 @@ export const computeBaseGridData = (context: DataFormatterContext<'grid'>, chart
|
|
85
85
|
})
|
86
86
|
})
|
87
87
|
|
88
|
-
// 依
|
89
|
-
const transposedDataGrid = transposeData(dataFormatter.grid.
|
88
|
+
// 依seriesDirection轉置資料矩陣
|
89
|
+
const transposedDataGrid = transposeData(dataFormatter.grid.gridData.seriesDirection, dataGrid)
|
90
90
|
|
91
91
|
// -- groupScale --
|
92
|
-
const
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
92
|
+
const { groupScale } = (() => {
|
93
|
+
const groupAxisWidth = (dataFormatter.grid.groupAxis.position === 'top' || dataFormatter.grid.groupAxis.position === 'bottom')
|
94
|
+
? layout.width
|
95
|
+
: layout.height
|
96
|
+
const groupEndIndex = transposedDataGrid[0] ? transposedDataGrid[0].length - 1 : 0
|
97
|
+
const groupScale: d3.ScaleLinear<number, number> = createAxisLinearScale({
|
98
|
+
maxValue: groupEndIndex,
|
99
|
+
minValue: 0,
|
100
|
+
axisWidth: groupAxisWidth,
|
101
|
+
scaleDomain: [0, groupEndIndex], // 不使用dataFormatter設定
|
102
|
+
scaleRange: [0, 1] // 不使用dataFormatter設定
|
103
|
+
})
|
104
|
+
return { groupScale }
|
105
|
+
})()
|
106
|
+
|
107
|
+
|
103
108
|
|
104
109
|
// const seriesColors = chartParams.colors[chartParams.colorScheme].series
|
105
110
|
|
@@ -131,26 +136,76 @@ export const computeBaseGridData = (context: DataFormatterContext<'grid'>, chart
|
|
131
136
|
// })
|
132
137
|
// })
|
133
138
|
|
134
|
-
// -- valueScale --
|
135
|
-
const visibleData = transposedDataGrid.flat().filter(d => d._visible != false)
|
136
|
-
const [minValue, maxValue] = getMinAndMaxValue(visibleData)
|
137
|
-
|
138
|
-
const valueAxisWidth = (dataFormatter.valueAxis.position === 'left' || dataFormatter.valueAxis.position === 'right')
|
139
|
-
? layout.height
|
140
|
-
: layout.width
|
141
|
-
|
142
139
|
const seriesLabels = createGridSeriesLabels({ transposedDataGrid, dataFormatter, chartType, gridIndex })
|
143
140
|
const groupLabels = createGridGroupLabels({ transposedDataGrid, dataFormatter, chartType, gridIndex })
|
144
141
|
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
142
|
+
// 每一個series的valueScale
|
143
|
+
const seriesValueScaleArr = (() => {
|
144
|
+
const valueAxisWidth = (dataFormatter.grid.valueAxis.position === 'left' || dataFormatter.grid.valueAxis.position === 'right')
|
145
|
+
? layout.height
|
146
|
+
: layout.width
|
147
|
+
|
148
|
+
// // 每一個series的 [minValue, maxValue]
|
149
|
+
// const minAndMaxValueArr = (() => {
|
150
|
+
// // 有設定series定位,各別series計算各自的最大最小值
|
151
|
+
// if (dataFormatter.grid.seriesSlotIndexes
|
152
|
+
// && dataFormatter.grid.seriesSlotIndexes.length === transposedDataGrid.length
|
153
|
+
// ) {
|
154
|
+
// return transposedDataGrid
|
155
|
+
// .map(series => {
|
156
|
+
// const visibleData = series.filter(d => d._visible != false)
|
157
|
+
// return getMinAndMaxValue(visibleData)
|
158
|
+
// })
|
159
|
+
// } else {
|
160
|
+
// // 沒有設定series定位,全部資料一起計算最大值最小值
|
161
|
+
// const visibleData = transposedDataGrid.flat().filter(d => d._visible != false)
|
162
|
+
// const [minValue, maxValue] = getMinAndMaxValue(visibleData)
|
163
|
+
// return transposedDataGrid
|
164
|
+
// .map(series => {
|
165
|
+
// return [minValue, maxValue]
|
166
|
+
// })
|
167
|
+
// }
|
168
|
+
// })()
|
152
169
|
|
153
|
-
|
170
|
+
const visibleData = transposedDataGrid.flat().filter(d => d._visible != false)
|
171
|
+
const [minValue, maxValue] = getMinAndMaxValue(visibleData)
|
172
|
+
|
173
|
+
return transposedDataGrid.map((seriesData, seriesIndex) => {
|
174
|
+
// const minValue = minAndMaxValueArr[seriesIndex][0]
|
175
|
+
// const maxValue = minAndMaxValueArr[seriesIndex][1]
|
176
|
+
const valueScale: d3.ScaleLinear<number, number> = createAxisLinearScale({
|
177
|
+
maxValue,
|
178
|
+
minValue,
|
179
|
+
axisWidth: valueAxisWidth,
|
180
|
+
scaleDomain: [minValue, maxValue], // 不使用dataFormatter設定
|
181
|
+
scaleRange: [0, 1] // 不使用dataFormatter設定
|
182
|
+
})
|
183
|
+
return valueScale
|
184
|
+
})
|
185
|
+
})()
|
186
|
+
|
187
|
+
// const { valueScale } = (() => {
|
188
|
+
|
189
|
+
// const visibleData = transposedDataGrid.flat().filter(d => d._visible != false)
|
190
|
+
// const [minValue, maxValue] = getMinAndMaxValue(visibleData)
|
191
|
+
|
192
|
+
// const valueAxisWidth = (dataFormatter.grid.valueAxis.position === 'left' || dataFormatter.grid.valueAxis.position === 'right')
|
193
|
+
// ? layout.height
|
194
|
+
// : layout.width
|
195
|
+
|
196
|
+
// const valueScale: d3.ScaleLinear<number, number> = createAxisLinearScale({
|
197
|
+
// maxValue,
|
198
|
+
// minValue,
|
199
|
+
// axisWidth: valueAxisWidth,
|
200
|
+
// scaleDomain: [minValue, maxValue], // 不使用dataFormatter設定
|
201
|
+
// scaleRange: [0, 1] // 不使用dataFormatter設定
|
202
|
+
// })
|
203
|
+
// return { valueScale }
|
204
|
+
// })()
|
205
|
+
|
206
|
+
const zeroYArr = transposedDataGrid.map((series, seriesIndex) => {
|
207
|
+
return seriesValueScaleArr[seriesIndex]!(0)
|
208
|
+
})
|
154
209
|
|
155
210
|
let _index = 0
|
156
211
|
computedDataGrid = transposedDataGrid.map((seriesData, seriesIndex) => {
|
@@ -159,7 +214,9 @@ export const computeBaseGridData = (context: DataFormatterContext<'grid'>, chart
|
|
159
214
|
const defaultId = createDefaultDatumId(chartType, gridIndex, seriesIndex, groupIndex)
|
160
215
|
// const visible = visibleFilter(groupDatum, seriesIndex, groupIndex, context)
|
161
216
|
const groupLabel = groupLabels[groupIndex]
|
217
|
+
const valueScale = seriesValueScaleArr[seriesIndex]
|
162
218
|
const axisY = valueScale(groupDatum.value ?? 0)
|
219
|
+
const zeroY = zeroYArr[seriesIndex]
|
163
220
|
|
164
221
|
const computedDatum: ComputedDatumGrid = {
|
165
222
|
id: groupDatum.id ? groupDatum.id : defaultId,
|
@@ -6,13 +6,31 @@ import {
|
|
6
6
|
groupDataMapObservable } from '../utils/observables'
|
7
7
|
import {
|
8
8
|
gridAxesTransformObservable,
|
9
|
+
gridAxesReverseTransformObservable,
|
9
10
|
gridGraphicTransformObservable,
|
10
|
-
|
11
|
+
gridGraphicReverseScaleObservable,
|
11
12
|
gridAxesSizeObservable,
|
12
|
-
|
13
|
+
existedSeriesLabelsObservable,
|
14
|
+
gridVisibleComputedDataObservable,
|
15
|
+
isSeriesPositionSeprateObservable,
|
16
|
+
gridContainerObservable } from './gridObservables'
|
13
17
|
|
14
18
|
export const createGridContextObserver: ContextObserverFn<'grid'> = ({ subject, observer }) => {
|
15
19
|
|
20
|
+
const isSeriesPositionSeprate$ = isSeriesPositionSeprateObservable({
|
21
|
+
computedData$: observer.computedData$,
|
22
|
+
fullDataFormatter$: observer.fullDataFormatter$
|
23
|
+
}).pipe(
|
24
|
+
shareReplay(1)
|
25
|
+
)
|
26
|
+
|
27
|
+
const gridContainer$ = gridContainerObservable({
|
28
|
+
computedData$: observer.computedData$,
|
29
|
+
fullDataFormatter$: observer.fullDataFormatter$,
|
30
|
+
fullChartParams$: observer.fullChartParams$,
|
31
|
+
layout$: observer.layout$,
|
32
|
+
})
|
33
|
+
|
16
34
|
const gridAxesTransform$ = gridAxesTransformObservable({
|
17
35
|
fullDataFormatter$: observer.fullDataFormatter$,
|
18
36
|
layout$: observer.layout$
|
@@ -20,6 +38,12 @@ export const createGridContextObserver: ContextObserverFn<'grid'> = ({ subject,
|
|
20
38
|
shareReplay(1)
|
21
39
|
)
|
22
40
|
|
41
|
+
const gridAxesReverseTransform$ = gridAxesReverseTransformObservable({
|
42
|
+
gridAxesTransform$
|
43
|
+
}).pipe(
|
44
|
+
shareReplay(1)
|
45
|
+
)
|
46
|
+
|
23
47
|
const gridGraphicTransform$ = gridGraphicTransformObservable({
|
24
48
|
computedData$: observer.computedData$,
|
25
49
|
fullDataFormatter$: observer.fullDataFormatter$,
|
@@ -28,11 +52,11 @@ export const createGridContextObserver: ContextObserverFn<'grid'> = ({ subject,
|
|
28
52
|
shareReplay(1)
|
29
53
|
)
|
30
54
|
|
31
|
-
const
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
)
|
55
|
+
const gridGraphicReverseScale$ = gridGraphicReverseScaleObservable({
|
56
|
+
gridContainer$: gridContainer$,
|
57
|
+
gridAxesTransform$: gridAxesTransform$,
|
58
|
+
gridGraphicTransform$: gridGraphicTransform$,
|
59
|
+
})
|
36
60
|
|
37
61
|
const gridAxesSize$ = gridAxesSizeObservable({
|
38
62
|
fullDataFormatter$: observer.fullDataFormatter$,
|
@@ -55,6 +79,10 @@ export const createGridContextObserver: ContextObserverFn<'grid'> = ({ subject,
|
|
55
79
|
shareReplay(1)
|
56
80
|
)
|
57
81
|
|
82
|
+
const existedSeriesLabels$ = existedSeriesLabelsObservable({
|
83
|
+
computedData$: observer.computedData$,
|
84
|
+
})
|
85
|
+
|
58
86
|
const SeriesDataMap$ = seriesDataMapObservable({
|
59
87
|
datumList$: datumList$
|
60
88
|
}).pipe(
|
@@ -73,19 +101,24 @@ export const createGridContextObserver: ContextObserverFn<'grid'> = ({ subject,
|
|
73
101
|
shareReplay(1)
|
74
102
|
)
|
75
103
|
|
104
|
+
|
76
105
|
return {
|
77
106
|
fullParams$: observer.fullParams$,
|
78
107
|
fullChartParams$: observer.fullChartParams$,
|
79
108
|
fullDataFormatter$: observer.fullDataFormatter$,
|
80
109
|
computedData$: observer.computedData$,
|
81
110
|
layout$: observer.layout$,
|
111
|
+
isSeriesPositionSeprate$,
|
112
|
+
gridContainer$,
|
82
113
|
gridAxesTransform$,
|
114
|
+
gridAxesReverseTransform$,
|
83
115
|
gridGraphicTransform$,
|
84
|
-
|
116
|
+
gridGraphicReverseScale$,
|
85
117
|
gridAxesSize$,
|
86
118
|
gridHighlight$,
|
119
|
+
existedSeriesLabels$,
|
87
120
|
SeriesDataMap$,
|
88
121
|
GroupDataMap$,
|
89
|
-
visibleComputedData
|
122
|
+
visibleComputedData$,
|
90
123
|
}
|
91
124
|
}
|