@orbcharts/core 3.0.0-alpha.32 → 3.0.0-alpha.33

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.
@@ -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 gridAxesOppositeTransformObservable: ({ gridAxesTransform$ }: {
16
+ export declare const gridGraphicReverseScaleObservable: ({ gridContainer$, gridAxesTransform$, gridGraphicTransform$ }: {
17
+ gridContainer$: Observable<ContainerPosition[]>;
14
18
  gridAxesTransform$: Observable<TransformData>;
15
- }) => Observable<TransformData>;
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, TransformData } from '../types';
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,19 +7,7 @@ export declare const multiGridEachDetailObservable: ({ fullDataFormatter$, compu
7
7
  layout$: Observable<Layout>;
8
8
  fullChartParams$: Observable<ChartParams>;
9
9
  event$: Subject<EventMultiGrid>;
10
- }) => 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
- }[]>;
10
+ }) => Observable<ContextObserverGridDetail[]>;
23
11
  export declare const multiGridContainerObservable: ({ computedData$, fullDataFormatter$, fullChartParams$, layout$ }: {
24
12
  computedData$: Observable<ComputedDataTypeMap<"multiGrid">>;
25
13
  fullDataFormatter$: Observable<DataFormatterTypeMap<"multiGrid">>;
@@ -31,4 +19,4 @@ export declare const multiGridContainerObservable: ({ computedData$, fullDataFor
31
19
  columnIndex: number;
32
20
  translate: [number, number];
33
21
  scale: [number, number];
34
- }[]>;
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
- gridAxesOppositeTransform$: Observable<TransformData>;
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,29 +1,8 @@
1
1
  import { Observable } from 'rxjs';
2
2
  import { ContextObserverBase } from './ContextObserver';
3
- import { ComputedDataGrid, ComputedDatumGrid } from './ComputedDataGrid';
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<MultiGridObservableAll[]>;
8
- multiGridContainer$: Observable<GridContainerBox[]>;
9
- }
10
- export interface MultiGridObservableAll {
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, ComputedDatumGrid[]>>;
20
- GroupDataMap$: Observable<Map<string, ComputedDatumGrid[]>>;
21
- visibleComputedData$: Observable<ComputedDataGrid>;
22
- }
23
- export interface GridContainerBox {
24
- slotIndex: number;
25
- rowIndex: number;
26
- columnIndex: number;
27
- translate: [number, number];
28
- scale: [number, number];
6
+ multiGridEachDetail$: Observable<ContextObserverGridDetail[]>;
7
+ multiGridContainer$: Observable<ContainerPosition[][]>;
29
8
  }
@@ -1,19 +1,37 @@
1
1
  import { DataFormatterBase, DataFormatterBasePartial, DataFormatterValueAxis, DataFormatterGroupAxis, VisibleFilter } from './DataFormatter';
2
2
 
3
- export type SeriesType = 'row' | 'column';
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 DataFormatterGridPartial extends DataFormatterBasePartial<'grid'> {
11
- grid?: Partial<DataFormatterGridGrid>;
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 DataFormatterGridGrid {
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 { DataFormatterGrid } from './DataFormatterGrid';
2
+ import { DataFormatterGridGrid, DataFormatterGridGridPartial, DataFormatterGridContainer } from './DataFormatterGrid';
3
3
 
4
4
  export interface DataFormatterMultiGrid extends DataFormatterBase<'multiGrid'> {
5
5
  visibleFilter: VisibleFilter<'multiGrid'>;
6
- multiGrid: Array<DataFormatterMultiGridMultiGrid>;
6
+ gridList: Array<DataFormatterGridGrid>;
7
7
  container: DataFormatterMultiGridContainer;
8
8
  }
9
9
  export interface DataFormatterMultiGridPartial extends DataFormatterBasePartial<'multiGrid'> {
10
- multiGrid?: Array<Partial<DataFormatterMultiGridMultiGrid>>;
10
+ visibleFilter?: VisibleFilter<'multiGrid'>;
11
+ gridList?: Array<DataFormatterGridGridPartial>;
12
+ container?: Partial<DataFormatterMultiGridContainer>;
11
13
  }
12
- export interface DataFormatterMultiGridMultiGrid extends DataFormatterGrid {
13
- slotIndex: number;
14
+ export interface DataFormatterMultiGridGrid extends DataFormatterGridGrid {
14
15
  }
15
- export interface DataFormatterMultiGridContainer {
16
- gap: number;
17
- rowAmount: number;
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 { SeriesType, DataFormatterGrid } from '../types/DataFormatterGrid';
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>(seriesType: SeriesType, data: T[][]): 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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@orbcharts/core",
3
- "version": "3.0.0-alpha.32",
3
+ "version": "3.0.0-alpha.33",
4
4
  "description": "OrbCharts is an open source chart library based on d3.js and rx.js",
5
5
  "author": "Blue Planet Inc.",
6
6
  "license": "Apache-2.0",
@@ -149,10 +149,10 @@ export const createBaseChart: CreateBaseChart = <T extends ChartType>({ defaultD
149
149
  map((dataFormatter) => {
150
150
  const mergedData = mergeOptionsWithDefault(dataFormatter, mergedPresetWithDefault.dataFormatter)
151
151
 
152
- if (chartType === 'multiGrid' && (dataFormatter as DataFormatterPartialTypeMap<'multiGrid'>).multiGrid != null) {
152
+ if (chartType === 'multiGrid' && (dataFormatter as DataFormatterPartialTypeMap<'multiGrid'>).gridList != null) {
153
153
  // multiGrid欄位為陣列,需要各別來merge預設值
154
- (mergedData as DataFormatterTypeMap<'multiGrid'>).multiGrid = (dataFormatter as DataFormatterPartialTypeMap<'multiGrid'>).multiGrid.map(d => {
155
- return mergeOptionsWithDefault(d, (mergedPresetWithDefault.dataFormatter as DataFormatterTypeMap<'multiGrid'>).multiGrid[0])
154
+ (mergedData as DataFormatterTypeMap<'multiGrid'>).gridList = (dataFormatter as DataFormatterPartialTypeMap<'multiGrid'>).gridList.map(d => {
155
+ return mergeOptionsWithDefault(d, (mergedPresetWithDefault.dataFormatter as DataFormatterTypeMap<'multiGrid'>).gridList[0])
156
156
  })
157
157
  }
158
158
  return mergedData
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, DataFormatterMultiGridMultiGrid } from './types/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 DATA_FORMATTER_GRID_DEFAULT: DataFormatterGrid = {
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
- grid: {
166
- // rowUnitLabel: '',
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.seriesType === 'row' ? rowIndex : columnIndex
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
- ...DATA_FORMATTER_GRID_DEFAULT,
185
- slotIndex: 0,
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
- multiGrid: [
205
+ gridList: [
192
206
  {
193
- ...DATA_FORMATTER_MULTI_GRID_MULTI_GRID_DEFAULT
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
- // 依seriesType轉置資料矩陣
89
- const transposedDataGrid = transposeData(dataFormatter.grid.seriesType, dataGrid)
88
+ // 依seriesDirection轉置資料矩陣
89
+ const transposedDataGrid = transposeData(dataFormatter.grid.gridData.seriesDirection, dataGrid)
90
90
 
91
91
  // -- groupScale --
92
- const groupAxisWidth = (dataFormatter.groupAxis.position === 'top' || dataFormatter.groupAxis.position === 'bottom')
93
- ? layout.width
94
- : layout.height
95
- const groupEndIndex = transposedDataGrid[0] ? transposedDataGrid[0].length - 1 : 0
96
- const groupScale: d3.ScaleLinear<number, number> = createAxisLinearScale({
97
- maxValue: groupEndIndex,
98
- minValue: 0,
99
- axisWidth: groupAxisWidth,
100
- scaleDomain: [0, groupEndIndex], // 不使用dataFormatter設定
101
- scaleRange: [0, 1] // 不使用dataFormatter設定
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
- const valueScale: d3.ScaleLinear<number, number> = createAxisLinearScale({
146
- maxValue,
147
- minValue,
148
- axisWidth: valueAxisWidth,
149
- scaleDomain: [minValue, maxValue], // 不使用dataFormatter設定
150
- scaleRange: [0, 1] // 不使用dataFormatter設定
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
- const zeroY = valueScale(0)
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
- gridAxesOppositeTransformObservable,
11
+ gridGraphicReverseScaleObservable,
11
12
  gridAxesSizeObservable,
12
- gridVisibleComputedDataObservable } from './gridObservables'
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 gridAxesOppositeTransform$ = gridAxesOppositeTransformObservable({
32
- gridAxesTransform$
33
- }).pipe(
34
- shareReplay(1)
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
- gridAxesOppositeTransform$,
116
+ gridGraphicReverseScale$,
85
117
  gridAxesSize$,
86
118
  gridHighlight$,
119
+ existedSeriesLabels$,
87
120
  SeriesDataMap$,
88
121
  GroupDataMap$,
89
- visibleComputedData$
122
+ visibleComputedData$,
90
123
  }
91
124
  }