This is an automated email from the ASF dual-hosted git repository.
shenyi pushed a commit to branch aggregate-transform
in repository https://gitbox.apache.org/repos/asf/echarts.git
The following commit(s) were added to refs/heads/aggregate-transform by this
push:
new 72e29af refact(dataset): rename seriesLayoutBy to sourceLayout
72e29af is described below
commit 72e29af15d322777b2441bfb730a93f6ebb28849
Author: pissang <[email protected]>
AuthorDate: Thu Mar 24 13:57:32 2022 +0800
refact(dataset): rename seriesLayoutBy to sourceLayout
---
src/chart/pie/PieView.ts | 2 +-
src/component/dataset/install.ts | 14 +++++--
src/component/transform/aggregateTransform.ts | 14 ++++---
src/data/Source.ts | 57 ++++++++++++---------------
src/data/helper/SeriesDataSchema.ts | 4 +-
src/data/helper/dataProvider.ts | 44 ++++++++++-----------
src/data/helper/sourceHelper.ts | 12 +++---
src/data/helper/sourceManager.ts | 52 ++++++++++++------------
src/data/helper/transform.ts | 18 ++++-----
src/util/types.ts | 22 +++++------
10 files changed, 122 insertions(+), 117 deletions(-)
diff --git a/src/chart/pie/PieView.ts b/src/chart/pie/PieView.ts
index 9118f92..900c104 100644
--- a/src/chart/pie/PieView.ts
+++ b/src/chart/pie/PieView.ts
@@ -95,7 +95,7 @@ class PiePiece extends graphic.Sector {
}
}, seriesModel, idx);
}
- // Expansion
+ // Expansion.
else {
if (startAngle != null) {
sector.setShape({ startAngle, endAngle: startAngle });
diff --git a/src/component/dataset/install.ts b/src/component/dataset/install.ts
index 2e5d7be..65c52e7 100644
--- a/src/component/dataset/install.ts
+++ b/src/component/dataset/install.ts
@@ -29,8 +29,8 @@
import ComponentModel from '../../model/Component';
import ComponentView from '../../view/Component';
import {
- SERIES_LAYOUT_BY_COLUMN, ComponentOption, SeriesEncodeOptionMixin,
- OptionSourceData, SeriesLayoutBy, OptionSourceHeader
+ SOURCE_LAYOUT_BY_COLUMN, ComponentOption, SeriesEncodeOptionMixin,
+ OptionSourceData, SourceLayout, OptionSourceHeader
} from '../../util/types';
import { DataTransformOption, PipedDataTransformOption } from
'../../data/helper/transform';
import GlobalModel from '../../model/Global';
@@ -44,10 +44,16 @@ export interface DatasetOption extends
Pick<SeriesEncodeOptionMixin, 'dimensions'> {
mainType?: 'dataset';
- seriesLayoutBy?: SeriesLayoutBy;
+ sourceLayout?: SourceLayout;
sourceHeader?: OptionSourceHeader;
source?: OptionSourceData;
+ /**
+ * @deprecated
+ * Use sourceLayout instead
+ */
+ seriesLayoutBy?: SourceLayout
+
fromDatasetIndex?: number;
fromDatasetId?: string;
transform?: DataTransformOption | PipedDataTransformOption;
@@ -63,7 +69,7 @@ export class DatasetModel<Opts extends DatasetOption =
DatasetOption> extends Co
static type = 'dataset';
static defaultOption: DatasetOption = {
- seriesLayoutBy: SERIES_LAYOUT_BY_COLUMN
+ sourceLayout: SOURCE_LAYOUT_BY_COLUMN
};
private _sourceManager: SourceManager;
diff --git a/src/component/transform/aggregateTransform.ts
b/src/component/transform/aggregateTransform.ts
index cd32c77..51b16c6 100644
--- a/src/component/transform/aggregateTransform.ts
+++ b/src/component/transform/aggregateTransform.ts
@@ -23,6 +23,7 @@ import {
ExternalDimensionDefinition,
ExternalSource
} from '../../data/helper/transform';
+import { warn } from '../../util/log';
import { asc, quantile } from '../../util/number';
import { DimensionLoose, DimensionName, OptionDataValue } from
'../../util/types';
@@ -211,12 +212,12 @@ function prepare(
const dimInfoInUpstream =
upstream.getDimensionInfo(resultDimInfoConfig.from);
if (__DEV__) {
assert(dimInfoInUpstream, 'Can not find dimension by `from`: ' +
resultDimInfoConfig.from);
- each(groupByDims, (gbDim) => {
- assert(
- gbDim.index !== dimInfoInUpstream.index ||
resultDimInfoConfig.method == null,
- `Dimension ${dimInfoInUpstream.name} is the "groupBy"
dimension, must not have any "method".`
- );
- });
+
+ if (resultDimInfoConfig.method != null
+ && find(groupByDims, gbDim => gbDim.index ===
dimInfoInUpstream.index)
+ ) {
+ warn(`Dimension ${dimInfoInUpstream.name} is used as "groupBy"
dimension, "method" will be ignored.`);
+ }
}
const methodName = (resultDimInfoConfig.method || '').toUpperCase() as
AggregateMethodInternal
@@ -226,6 +227,7 @@ function prepare(
assert(method, `Illegal method ${methodName}.`);
}
+
const name = retrieve2(resultDimInfoConfig.name,
dimInfoInUpstream.name);
const indexInUpStream = dimInfoInUpstream.index;
diff --git a/src/data/Source.ts b/src/data/Source.ts
index a530a50..12588ab 100644
--- a/src/data/Source.ts
+++ b/src/data/Source.ts
@@ -22,10 +22,10 @@ import {
hasOwn, assert, each, map, isNumber, isString
} from 'zrender/src/core/util';
import {
- SourceFormat, SeriesLayoutBy, DimensionDefinition,
+ SourceFormat, SourceLayout as SourceLayout, DimensionDefinition,
OptionEncodeValue, OptionSourceData,
SOURCE_FORMAT_ORIGINAL,
- SERIES_LAYOUT_BY_COLUMN,
+ SOURCE_LAYOUT_BY_COLUMN,
SOURCE_FORMAT_UNKNOWN,
SOURCE_FORMAT_KEYED_COLUMNS,
SOURCE_FORMAT_TYPED_ARRAY,
@@ -38,7 +38,7 @@ import {
OptionSourceDataObjectRows,
OptionDataValue,
OptionSourceDataArrayRows,
- SERIES_LAYOUT_BY_ROW,
+ SOURCE_LAYOUT_BY_ROW,
OptionSourceDataOriginal,
OptionSourceDataKeyedColumns
} from '../util/types';
@@ -83,7 +83,7 @@ import { BE_ORDINAL, guessOrdinal } from
'./helper/sourceHelper';
*/
export interface SourceMetaRawOption {
- seriesLayoutBy: SeriesLayoutBy;
+ sourceLayout: SourceLayout;
sourceHeader: OptionSourceHeader;
dimensions: DimensionDefinitionLoose[];
}
@@ -108,7 +108,7 @@ class SourceImpl {
* 'row' or 'column'
* Not null/undefined.
*/
- readonly seriesLayoutBy: SeriesLayoutBy;
+ readonly layout: SourceLayout;
/**
* dimensions definition from:
@@ -145,7 +145,7 @@ class SourceImpl {
sourceFormat: SourceFormat, // default: SOURCE_FORMAT_UNKNOWN
// Visit config are optional:
- seriesLayoutBy?: SeriesLayoutBy, // default: 'column'
+ layout?: SourceLayout, // default: 'column'
dimensionsDefine?: DimensionDefinition[],
startIndex?: number, // default: 0
dimensionsDetectedCount?: number,
@@ -165,23 +165,18 @@ class SourceImpl {
this.sourceFormat = fields.sourceFormat || SOURCE_FORMAT_UNKNOWN;
// Visit config
- this.seriesLayoutBy = fields.seriesLayoutBy || SERIES_LAYOUT_BY_COLUMN;
+ this.layout = fields.layout || SOURCE_LAYOUT_BY_COLUMN;
this.startIndex = fields.startIndex || 0;
this.dimensionsDetectedCount = fields.dimensionsDetectedCount;
this.metaRawOption = fields.metaRawOption;
- const dimensionsDefine = this.dimensionsDefine =
fields.dimensionsDefine;
-
- if (dimensionsDefine) {
- for (let i = 0; i < dimensionsDefine.length; i++) {
- const dim = dimensionsDefine[i];
- if (dim.type == null) {
- if (guessOrdinal(this, i) === BE_ORDINAL.Must) {
- dim.type = 'ordinal';
- }
+ each(this.dimensionsDefine = fields.dimensionsDefine, (dim, i) => {
+ if (dim.type == null) {
+ if (guessOrdinal(this, i) === BE_ORDINAL.Must) {
+ dim.type = 'ordinal';
}
}
- }
+ });
}
}
@@ -201,11 +196,11 @@ export function createSource(
sourceFormat: SourceFormat
): Source {
sourceFormat = sourceFormat || detectSourceFormat(sourceData);
- const seriesLayoutBy = thisMetaRawOption.seriesLayoutBy;
+ const layout = thisMetaRawOption.sourceLayout;
const determined = determineSourceDimensions(
sourceData,
sourceFormat,
- seriesLayoutBy,
+ layout,
thisMetaRawOption.sourceHeader,
thisMetaRawOption.dimensions
);
@@ -213,7 +208,7 @@ export function createSource(
data: sourceData,
sourceFormat: sourceFormat,
- seriesLayoutBy: seriesLayoutBy,
+ layout: layout,
dimensionsDefine: determined.dimensionsDefine,
startIndex: determined.startIndex,
dimensionsDetectedCount: determined.dimensionsDetectedCount,
@@ -243,7 +238,7 @@ export function cloneSourceShallow(source: Source): Source {
data: source.data,
sourceFormat: source.sourceFormat,
- seriesLayoutBy: source.seriesLayoutBy,
+ layout: source.layout,
dimensionsDefine: clone(source.dimensionsDefine),
startIndex: source.startIndex,
dimensionsDetectedCount: source.dimensionsDetectedCount
@@ -300,7 +295,7 @@ export function detectSourceFormat(data:
DatasetOption['source']): SourceFormat
function determineSourceDimensions(
data: OptionSourceData,
sourceFormat: SourceFormat,
- seriesLayoutBy: SeriesLayoutBy,
+ layout: SourceLayout,
sourceHeader: OptionSourceHeader,
// standalone raw dimensions definition, like:
// {
@@ -349,7 +344,7 @@ function determineSourceDimensions(
}
}
// 10 is an experience number, avoid long loop.
- }, seriesLayoutBy, dataArrayRows, 10);
+ }, layout, dataArrayRows, 10);
}
else {
startIndex = isNumber(sourceHeader) ? sourceHeader : sourceHeader
? 1 : 0;
@@ -359,16 +354,16 @@ function determineSourceDimensions(
dimensionsDefine = [];
arrayRowsTravelFirst(function (val, index) {
dimensionsDefine[index] = (val != null ? val + '' : '') as
DimensionName;
- }, seriesLayoutBy, dataArrayRows, Infinity);
+ }, layout, dataArrayRows, Infinity);
}
dimensionsDetectedCount = dimensionsDefine
? dimensionsDefine.length
- : seriesLayoutBy === SERIES_LAYOUT_BY_ROW
- ? dataArrayRows.length
- : dataArrayRows[0]
- ? dataArrayRows[0].length
- : null;
+ : layout === SOURCE_LAYOUT_BY_ROW
+ ? dataArrayRows.length
+ : dataArrayRows[0]
+ ? dataArrayRows[0].length
+ : null;
}
else if (sourceFormat === SOURCE_FORMAT_OBJECT_ROWS) {
if (!dimensionsDefine) {
@@ -463,11 +458,11 @@ function normalizeDimensionsOption(dimensionsDefine:
DimensionDefinitionLoose[])
function arrayRowsTravelFirst(
cb: (val: OptionDataValue, idx: number) => void,
- seriesLayoutBy: SeriesLayoutBy,
+ layout: SourceLayout,
data: OptionSourceDataArrayRows,
maxLoop: number
): void {
- if (seriesLayoutBy === SERIES_LAYOUT_BY_ROW) {
+ if (layout === SOURCE_LAYOUT_BY_ROW) {
for (let i = 0; i < data.length && i < maxLoop; i++) {
cb(data[i] ? data[i][0] : null, i);
}
diff --git a/src/data/helper/SeriesDataSchema.ts
b/src/data/helper/SeriesDataSchema.ts
index 67e9f1f..ac18d6c 100644
--- a/src/data/helper/SeriesDataSchema.ts
+++ b/src/data/helper/SeriesDataSchema.ts
@@ -185,11 +185,11 @@ export class SeriesDataSchema {
}
// Source from endpoint(usually series) will be read differently
- // when seriesLayoutBy or startIndex(which is affected by
sourceHeader) are different.
+ // when layout or startIndex(which is affected by sourceHeader) are
different.
// So we use this three props as key.
const source = this.source;
const hash = [
- source.seriesLayoutBy,
+ source.layout,
source.startIndex,
dimHash
].join('$$');
diff --git a/src/data/helper/dataProvider.ts b/src/data/helper/dataProvider.ts
index 37247ed..dbd98aa 100644
--- a/src/data/helper/dataProvider.ts
+++ b/src/data/helper/dataProvider.ts
@@ -31,10 +31,10 @@ import {
SOURCE_FORMAT_KEYED_COLUMNS,
SOURCE_FORMAT_TYPED_ARRAY,
SOURCE_FORMAT_ARRAY_ROWS,
- SERIES_LAYOUT_BY_COLUMN,
- SERIES_LAYOUT_BY_ROW,
+ SOURCE_LAYOUT_BY_COLUMN,
+ SOURCE_LAYOUT_BY_ROW,
DimensionName, DimensionIndex, OptionSourceData,
- OptionDataItem, OptionDataValue, SourceFormat, SeriesLayoutBy,
ParsedValue, DimensionLoose, NullUndefined
+ OptionDataItem, OptionDataValue, SourceFormat, SourceLayout, ParsedValue,
DimensionLoose, NullUndefined
} from '../../util/types';
import SeriesData from '../SeriesData';
@@ -150,11 +150,11 @@ export class DefaultDataProvider implements DataProvider {
mountMethods = function (provider, data, source) {
const sourceFormat = source.sourceFormat;
- const seriesLayoutBy = source.seriesLayoutBy;
+ const sourceLayout = source.layout;
const startIndex = source.startIndex;
const dimsDef = source.dimensionsDefine;
- const methods = providerMethods[getMethodMapKey(sourceFormat,
seriesLayoutBy)];
+ const methods = providerMethods[getMethodMapKey(sourceFormat,
sourceLayout)];
if (__DEV__) {
assert(methods, 'Invalide sourceFormat: ' + sourceFormat);
}
@@ -167,9 +167,9 @@ export class DefaultDataProvider implements DataProvider {
provider.fillStorage = fillStorageForTypedArray;
}
else {
- const rawItemGetter = getRawSourceItemGetter(sourceFormat,
seriesLayoutBy);
+ const rawItemGetter = getRawSourceItemGetter(sourceFormat,
sourceLayout);
provider.getItem = bind(rawItemGetter, null, data, startIndex,
dimsDef);
- const rawCounter = getRawSourceDataCounter(sourceFormat,
seriesLayoutBy);
+ const rawCounter = getRawSourceDataCounter(sourceFormat,
sourceLayout);
provider.count = bind(rawCounter, null, data, startIndex,
dimsDef);
}
};
@@ -220,15 +220,15 @@ export class DefaultDataProvider implements DataProvider {
providerMethods = {
- [SOURCE_FORMAT_ARRAY_ROWS + '_' + SERIES_LAYOUT_BY_COLUMN]: {
+ [SOURCE_FORMAT_ARRAY_ROWS + '_' + SOURCE_LAYOUT_BY_COLUMN]: {
pure: true,
appendData: appendDataSimply
},
- [SOURCE_FORMAT_ARRAY_ROWS + '_' + SERIES_LAYOUT_BY_ROW]: {
+ [SOURCE_FORMAT_ARRAY_ROWS + '_' + SOURCE_LAYOUT_BY_ROW]: {
pure: true,
appendData: function () {
- throw new Error('Do not support appendData when set
seriesLayoutBy: "row".');
+ throw new Error('Do not support appendData when set
sourceLayout: "row".');
}
},
@@ -304,12 +304,12 @@ const getItemSimply: RawSourceItemGetter = function (
};
const rawSourceItemGetterMap: Dictionary<RawSourceItemGetter> = {
- [SOURCE_FORMAT_ARRAY_ROWS + '_' + SERIES_LAYOUT_BY_COLUMN]: function (
+ [SOURCE_FORMAT_ARRAY_ROWS + '_' + SOURCE_LAYOUT_BY_COLUMN]: function (
rawData, startIndex, dimsDef, idx
) {
return (rawData as OptionDataValue[][])[idx + startIndex];
},
- [SOURCE_FORMAT_ARRAY_ROWS + '_' + SERIES_LAYOUT_BY_ROW]: function (
+ [SOURCE_FORMAT_ARRAY_ROWS + '_' + SOURCE_LAYOUT_BY_ROW]: function (
rawData, startIndex, dimsDef, idx, out
) {
idx += startIndex;
@@ -342,11 +342,11 @@ const rawSourceItemGetterMap:
Dictionary<RawSourceItemGetter> = {
};
export function getRawSourceItemGetter(
- sourceFormat: SourceFormat, seriesLayoutBy: SeriesLayoutBy
+ sourceFormat: SourceFormat, sourceLayout: SourceLayout
): RawSourceItemGetter {
- const method = rawSourceItemGetterMap[getMethodMapKey(sourceFormat,
seriesLayoutBy)];
+ const method = rawSourceItemGetterMap[getMethodMapKey(sourceFormat,
sourceLayout)];
if (__DEV__) {
- assert(method, 'Do not support get item on "' + sourceFormat + '", "'
+ seriesLayoutBy + '".');
+ assert(method, 'Do not support get item on "' + sourceFormat + '", "'
+ sourceLayout + '".');
}
return method;
}
@@ -367,12 +367,12 @@ const countSimply: RawSourceDataCounter = function (
};
const rawSourceDataCounterMap: Dictionary<RawSourceDataCounter> = {
- [SOURCE_FORMAT_ARRAY_ROWS + '_' + SERIES_LAYOUT_BY_COLUMN]: function (
+ [SOURCE_FORMAT_ARRAY_ROWS + '_' + SOURCE_LAYOUT_BY_COLUMN]: function (
rawData, startIndex, dimsDef
) {
return Math.max(0, (rawData as OptionDataItem[][]).length -
startIndex);
},
- [SOURCE_FORMAT_ARRAY_ROWS + '_' + SERIES_LAYOUT_BY_ROW]: function (
+ [SOURCE_FORMAT_ARRAY_ROWS + '_' + SOURCE_LAYOUT_BY_ROW]: function (
rawData, startIndex, dimsDef
) {
const row = (rawData as OptionDataValue[][])[0];
@@ -395,11 +395,11 @@ const rawSourceDataCounterMap:
Dictionary<RawSourceDataCounter> = {
};
export function getRawSourceDataCounter(
- sourceFormat: SourceFormat, seriesLayoutBy: SeriesLayoutBy
+ sourceFormat: SourceFormat, sourceLayout: SourceLayout
): RawSourceDataCounter {
- const method = rawSourceDataCounterMap[getMethodMapKey(sourceFormat,
seriesLayoutBy)];
+ const method = rawSourceDataCounterMap[getMethodMapKey(sourceFormat,
sourceLayout)];
if (__DEV__) {
- assert(method, 'Do not suppport count on "' + sourceFormat + '", "' +
seriesLayoutBy + '".');
+ assert(method, 'Do not suppport count on "' + sourceFormat + '", "' +
sourceLayout + '".');
}
return method;
}
@@ -452,9 +452,9 @@ export function getRawSourceValueGetter(sourceFormat:
SourceFormat): RawSourceVa
}
-function getMethodMapKey(sourceFormat: SourceFormat, seriesLayoutBy:
SeriesLayoutBy): string {
+function getMethodMapKey(sourceFormat: SourceFormat, sourceLayout:
SourceLayout): string {
return sourceFormat === SOURCE_FORMAT_ARRAY_ROWS
- ? sourceFormat + '_' + seriesLayoutBy
+ ? sourceFormat + '_' + sourceLayout
: sourceFormat;
}
diff --git a/src/data/helper/sourceHelper.ts b/src/data/helper/sourceHelper.ts
index e0ef9dd..5408f6a 100644
--- a/src/data/helper/sourceHelper.ts
+++ b/src/data/helper/sourceHelper.ts
@@ -34,7 +34,7 @@ import {
SOURCE_FORMAT_ORIGINAL,
SOURCE_FORMAT_ARRAY_ROWS,
SOURCE_FORMAT_OBJECT_ROWS,
- SERIES_LAYOUT_BY_ROW,
+ SOURCE_LAYOUT_BY_ROW,
SOURCE_FORMAT_KEYED_COLUMNS,
DimensionName,
OptionSourceDataArrayRows,
@@ -114,7 +114,7 @@ export function makeSeriesEncodeForAxisCoordSys(
const ecModel = seriesModel.ecModel;
const datasetMap = innerGlobalModel(ecModel).datasetMap;
- const key = datasetModel.uid + '_' + source.seriesLayoutBy;
+ const key = datasetModel.uid + '_' + source.layout;
let baseCategoryDimIndex: number;
let categoryWayValueDimStart;
@@ -225,7 +225,7 @@ export function makeSeriesEncodeForNameBased(
// 5 is an experience value.
for (let i = 0, len = Math.min(5, dimCount); i < len; i++) {
const guessResult = doGuessOrdinal(
- source.data, sourceFormat, source.seriesLayoutBy,
+ source.data, sourceFormat, source.layout,
dimensionsDefine, source.startIndex, i
);
guessRecords.push(guessResult);
@@ -342,7 +342,7 @@ export function guessOrdinal(source: Source, dimIndex:
DimensionIndex): BeOrdina
return doGuessOrdinal(
source.data,
source.sourceFormat,
- source.seriesLayoutBy,
+ source.layout,
source.dimensionsDefine,
source.startIndex,
dimIndex
@@ -354,7 +354,7 @@ export function guessOrdinal(source: Source, dimIndex:
DimensionIndex): BeOrdina
function doGuessOrdinal(
data: Source['data'],
sourceFormat: Source['sourceFormat'],
- seriesLayoutBy: Source['seriesLayoutBy'],
+ layout: Source['layout'],
dimensionsDefine: Source['dimensionsDefine'],
startIndex: Source['startIndex'],
dimIndex: DimensionIndex
@@ -388,7 +388,7 @@ function doGuessOrdinal(
if (sourceFormat === SOURCE_FORMAT_ARRAY_ROWS) {
const dataArrayRows = data as OptionSourceDataArrayRows;
- if (seriesLayoutBy === SERIES_LAYOUT_BY_ROW) {
+ if (layout === SOURCE_LAYOUT_BY_ROW) {
const sample = dataArrayRows[dimIndex];
for (let i = 0; i < (sample || []).length && i < maxLoop; i++) {
if ((result = detectValue(sample[startIndex + i])) != null) {
diff --git a/src/data/helper/sourceManager.ts b/src/data/helper/sourceManager.ts
index 611238a..b34d225 100644
--- a/src/data/helper/sourceManager.ts
+++ b/src/data/helper/sourceManager.ts
@@ -26,7 +26,7 @@ import { SourceMetaRawOption, Source, createSource,
cloneSourceShallow } from '.
import {
SeriesEncodableModel, OptionSourceData,
SOURCE_FORMAT_TYPED_ARRAY, SOURCE_FORMAT_ORIGINAL,
- SourceFormat, SeriesLayoutBy, OptionSourceHeader,
+ SourceFormat, SourceLayout, OptionSourceHeader,
DimensionDefinitionLoose, Dictionary
} from '../../util/types';
import {
@@ -36,12 +36,13 @@ import { applyDataTransform } from './transform';
import DataStore, { DataStoreDimensionDefine } from '../DataStore';
import { DefaultDataProvider } from './dataProvider';
import { SeriesDataSchema } from './SeriesDataSchema';
+import { deprecateReplaceLog } from '../../util/log';
type DataStoreMap = Dictionary<DataStore>;
/**
* [REQUIREMENT_MEMO]:
- * (0) `metaRawOption` means `dimensions`/`sourceHeader`/`seriesLayoutBy` in
raw option.
+ * (0) `metaRawOption` means `dimensions`/`sourceHeader`/`sourceLayout` in raw
option.
* (1) Keep support the feature: `metaRawOption` can be specified both on
`series` and
* `root-dataset`. Them on `series` has higher priority.
* (2) Do not support to set `metaRawOption` on a `non-root-dataset`, because
it might
@@ -85,7 +86,7 @@ type DataStoreMap = Dictionary<DataStore>;
* series: {
* encode: {...},
* dimensions: [...]
- * seriesLayoutBy: 'row',
+ * sourceLayout: 'row',
* data: [[...]]
* }
* ```
@@ -97,7 +98,7 @@ type DataStoreMap = Dictionary<DataStore>;
* // and the dimensions defination in dataset is used
* }, {
* encode: {...},
- * seriesLayoutBy: 'column',
+ * sourceLayout: 'column',
* datasetIndex: 1
* }]
* ```
@@ -228,21 +229,21 @@ export class SourceManager {
// See [REQUIREMENT_MEMO], merge settings on series and parent
dataset if it is root.
const newMetaRawOption = this._getSourceMetaRawOption() || {} as
SourceMetaRawOption;
const upMetaRawOption = upSource && upSource.metaRawOption || {}
as SourceMetaRawOption;
- const seriesLayoutBy = retrieve2(newMetaRawOption.seriesLayoutBy,
upMetaRawOption.seriesLayoutBy) || null;
+ const sourceLayout = retrieve2(newMetaRawOption.sourceLayout,
upMetaRawOption.sourceLayout) || null;
const sourceHeader = retrieve2(newMetaRawOption.sourceHeader,
upMetaRawOption.sourceHeader);
// Note here we should not use `upSource.dimensionsDefine`.
Consider the case:
- // `upSource.dimensionsDefine` is detected by `seriesLayoutBy:
'column'`,
- // but series need `seriesLayoutBy: 'row'`.
+ // `upSource.dimensionsDefine` is detected by `sourceLayout:
'column'`,
+ // but series need `sourceLayout: 'row'`.
const dimensions = retrieve2(newMetaRawOption.dimensions,
upMetaRawOption.dimensions);
// We share source with dataset as much as possible
// to avoid extra memroy cost of high dimensional data.
- const needsCreateSource = seriesLayoutBy !==
upMetaRawOption.seriesLayoutBy
+ const needsCreateSource = sourceLayout !==
upMetaRawOption.sourceLayout
|| !!sourceHeader !== !!upMetaRawOption.sourceHeader
|| dimensions;
resultSourceList = needsCreateSource ? [createSource(
data,
- { seriesLayoutBy, sourceHeader, dimensions },
+ { sourceLayout: sourceLayout, sourceHeader, dimensions },
sourceFormat
)] : [];
}
@@ -274,9 +275,7 @@ export class SourceManager {
this._setLocalSource(resultSourceList, upstreamSignList);
}
- private _applyTransform(
- upMgrList: SourceManager[]
- ): {
+ private _applyTransform(upMgrList: SourceManager[]): {
sourceList: Source[],
upstreamSignList: string[]
} {
@@ -446,22 +445,25 @@ export class SourceManager {
private _getSourceMetaRawOption(): SourceMetaRawOption {
const sourceHost = this._sourceHost;
- let seriesLayoutBy: SeriesLayoutBy;
+ let sourceLayout: SourceLayout;
let sourceHeader: OptionSourceHeader;
let dimensions: DimensionDefinitionLoose[];
- if (isSeries(sourceHost)) {
- seriesLayoutBy = sourceHost.get('seriesLayoutBy', true);
- sourceHeader = sourceHost.get('sourceHeader', true);
- dimensions = sourceHost.get('dimensions', true);
- }
- // See [REQUIREMENT_MEMO], `non-root-dataset` do not support them.
- else if (!this._getUpstreamSourceManagers().length) {
- const model = sourceHost as DatasetModel;
- seriesLayoutBy = model.get('seriesLayoutBy', true);
- sourceHeader = model.get('sourceHeader', true);
- dimensions = model.get('dimensions', true);
+ if (isSeries(sourceHost)
+ // See [REQUIREMENT_MEMO], `non-root-dataset` do not support them.
+ || !this._getUpstreamSourceManagers().length
+ ) {
+ sourceLayout = (sourceHost as DatasetModel).get('sourceLayout',
true);
+ sourceHeader = (sourceHost as DatasetModel).get('sourceHeader',
true);
+ dimensions = (sourceHost as DatasetModel).get('dimensions', true);
+
+ if (sourceLayout == null) {
+ sourceLayout = (sourceHost as
DatasetModel).get('seriesLayoutBy', true);
+ if (__DEV__ && sourceLayout) {
+ deprecateReplaceLog('seriesLayoutBy', 'sourceLayout',
'dataset');
+ }
+ }
}
- return { seriesLayoutBy, sourceHeader, dimensions };
+ return { sourceLayout: sourceLayout, sourceHeader, dimensions };
}
}
diff --git a/src/data/helper/transform.ts b/src/data/helper/transform.ts
index cfb2b18..8a84e5b 100644
--- a/src/data/helper/transform.ts
+++ b/src/data/helper/transform.ts
@@ -21,7 +21,7 @@ import {
Dictionary, DimensionDefinitionLoose,
SourceFormat, DimensionDefinition, DimensionIndex,
OptionDataValue, DimensionLoose, DimensionName, ParsedValue,
- SERIES_LAYOUT_BY_COLUMN, SOURCE_FORMAT_OBJECT_ROWS,
SOURCE_FORMAT_ARRAY_ROWS,
+ SOURCE_LAYOUT_BY_COLUMN, SOURCE_FORMAT_OBJECT_ROWS,
SOURCE_FORMAT_ARRAY_ROWS,
OptionSourceDataObjectRows, OptionSourceDataArrayRows
} from '../../util/types';
import { normalizeToArray } from '../../util/model';
@@ -167,12 +167,12 @@ function createExternalSource(internalSource: Source,
externalTransform: Externa
const sourceHeaderCount = internalSource.startIndex;
let errMsg = '';
- if (internalSource.seriesLayoutBy !== SERIES_LAYOUT_BY_COLUMN) {
+ if (internalSource.layout !== SOURCE_LAYOUT_BY_COLUMN) {
// For the logic simplicity in transformer, only 'culumn' is
// supported in data transform. Otherwise, the `dimensionsDefine`
// might be detected by 'row', which probably confuses users.
if (__DEV__) {
- errMsg = '`seriesLayoutBy` of upstream dataset can only be
"column" in data transform.';
+ errMsg = '`sourceLayout` of upstream dataset can only be "column"
in data transform.';
}
throwError(errMsg);
}
@@ -224,7 +224,7 @@ function createExternalSource(internalSource: Source,
externalTransform: Externa
}
// Implement public methods:
- const rawItemGetter = getRawSourceItemGetter(sourceFormat,
SERIES_LAYOUT_BY_COLUMN);
+ const rawItemGetter = getRawSourceItemGetter(sourceFormat,
SOURCE_LAYOUT_BY_COLUMN);
if (externalTransform.__isBuiltIn) {
extSource.getRawDataItem = function (dataIndex) {
return rawItemGetter(data, sourceHeaderCount, dimensions,
dataIndex) as DataTransformDataItem;
@@ -234,7 +234,7 @@ function createExternalSource(internalSource: Source,
externalTransform: Externa
extSource.cloneRawData = bind(cloneRawData, null, internalSource);
- const rawCounter = getRawSourceDataCounter(sourceFormat,
SERIES_LAYOUT_BY_COLUMN);
+ const rawCounter = getRawSourceDataCounter(sourceFormat,
SOURCE_LAYOUT_BY_COLUMN);
extSource.count = bind(rawCounter, null, data, sourceHeaderCount,
dimensions);
const rawValueGetter = getRawSourceValueGetter(sourceFormat);
@@ -508,8 +508,8 @@ function applySingleDataTransform(
// We copy the header of upstream to the result becuase:
// (1) The returned data always does not contain header line and
can not be used
// as dimension-detection. In this case we can not use "detected
dimensions" of
- // upstream directly, because it might be detected based on
different `seriesLayoutBy`.
- // (2) We should support that the series read the upstream source
in `seriesLayoutBy: 'row'`.
+ // upstream directly, because it might be detected based on
different `sourceLayout`.
+ // (2) We should support that the series read the upstream source
in `sourceLayout: 'row'`.
// So the original detected header should be add to the result,
otherwise they can not be read.
if (startIndex) {
result.data = (firstUpSource.data as []).slice(0, startIndex)
@@ -517,14 +517,14 @@ function applySingleDataTransform(
}
resultMetaRawOption = {
- seriesLayoutBy: SERIES_LAYOUT_BY_COLUMN,
+ sourceLayout: SOURCE_LAYOUT_BY_COLUMN,
sourceHeader: startIndex,
dimensions: firstUpSource.metaRawOption.dimensions
};
}
else {
resultMetaRawOption = {
- seriesLayoutBy: SERIES_LAYOUT_BY_COLUMN,
+ sourceLayout: SOURCE_LAYOUT_BY_COLUMN,
sourceHeader: 0,
dimensions: result.dimensions
};
diff --git a/src/util/types.ts b/src/util/types.ts
index dbaafc8..61a01b8 100644
--- a/src/util/types.ts
+++ b/src/util/types.ts
@@ -467,10 +467,10 @@ export type SourceFormat =
| typeof SOURCE_FORMAT_TYPED_ARRAY
| typeof SOURCE_FORMAT_UNKNOWN;
-export const SERIES_LAYOUT_BY_COLUMN = 'column' as const;
-export const SERIES_LAYOUT_BY_ROW = 'row' as const;
+export const SOURCE_LAYOUT_BY_COLUMN = 'column' as const;
+export const SOURCE_LAYOUT_BY_ROW = 'row' as const;
-export type SeriesLayoutBy = typeof SERIES_LAYOUT_BY_COLUMN | typeof
SERIES_LAYOUT_BY_ROW;
+export type SourceLayout = typeof SOURCE_LAYOUT_BY_COLUMN | typeof
SOURCE_LAYOUT_BY_ROW;
// null/undefined/'auto': auto detect header, see
"src/data/helper/sourceHelper".
// If number, means header lines count, or say, `startIndex`.
// Like `sourceHeader: 2`, means line 0 and line 1 are header, data start from
line 2.
@@ -1592,13 +1592,6 @@ export interface SeriesOption<
hoverLayerThreshold?: number
- /**
- * When dataset is used, seriesLayoutBy specifies whether the column or
the row of dataset is mapped to the series
- * namely, the series is "layout" on columns or rows
- * @default 'column'
- */
- seriesLayoutBy?: 'column' | 'row'
-
labelLine?: LabelLineOption
/**
@@ -1672,8 +1665,15 @@ export interface SeriesSamplingOptionMixin {
export interface SeriesEncodeOptionMixin {
datasetIndex?: number;
datasetId?: string | number;
- seriesLayoutBy?: SeriesLayoutBy;
+ sourceLayout?: SourceLayout;
sourceHeader?: OptionSourceHeader;
+
+ /**
+ * @deprecated
+ * Use sourceLayout instead
+ */
+ seriesLayoutBy?: SourceLayout
+
dimensions?: DimensionDefinitionLoose[];
encode?: OptionEncode
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]