You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by sh...@apache.org on 2021/07/11 14:24:38 UTC

[echarts] branch dataset-perf updated: refact(data): fix several issues in storage sharing

This is an automated email from the ASF dual-hosted git repository.

shenyi pushed a commit to branch dataset-perf
in repository https://gitbox.apache.org/repos/asf/echarts.git


The following commit(s) were added to refs/heads/dataset-perf by this push:
     new 63c4177  refact(data): fix several issues in storage sharing
63c4177 is described below

commit 63c4177455a8c0e02071641ece42d740ffc44b5d
Author: pissang <bm...@gmail.com>
AuthorDate: Sun Jul 11 22:23:05 2021 +0800

    refact(data): fix several issues in storage sharing
    
    ordinalMeta update. encodeDef
---
 src/chart/helper/createGraphFromNodeEdge.ts   |   3 +-
 src/chart/helper/createSeriesDataFromArray.ts |  17 +-
 src/chart/helper/createSeriesDataSimply.ts    |   6 +-
 src/data/DataStorage.ts                       | 835 ++++++++++++++------------
 src/data/SeriesData.ts                        |  68 ++-
 src/data/Source.ts                            |  69 +--
 src/data/helper/completeDimensions.ts         |   2 +-
 src/data/helper/createDimensions.ts           |   3 +-
 src/data/helper/dataProvider.ts               |   4 +-
 src/data/helper/dataValueHelper.ts            |   8 +-
 src/data/helper/sourceManager.ts              |  12 +-
 src/data/helper/transform.ts                  |   1 -
 src/layout/points.ts                          |   2 +-
 src/model/Series.ts                           |  16 +-
 src/util/types.ts                             |   8 +-
 15 files changed, 543 insertions(+), 511 deletions(-)

diff --git a/src/chart/helper/createGraphFromNodeEdge.ts b/src/chart/helper/createGraphFromNodeEdge.ts
index 80a43a3..58da5e6 100644
--- a/src/chart/helper/createGraphFromNodeEdge.ts
+++ b/src/chart/helper/createGraphFromNodeEdge.ts
@@ -84,7 +84,8 @@ export default function createGraphFromNodeEdge(
         }
 
         const dimensionNames = createDimensions(nodes, {
-            coordDimensions: coordDimensions
+            coordDimensions: coordDimensions,
+            encodeDefine: seriesModel.getEncode()
         });
         nodeData = new SeriesData(dimensionNames, seriesModel);
         nodeData.initData(nodes);
diff --git a/src/chart/helper/createSeriesDataFromArray.ts b/src/chart/helper/createSeriesDataFromArray.ts
index 73cb7b1..9dc8479 100644
--- a/src/chart/helper/createSeriesDataFromArray.ts
+++ b/src/chart/helper/createSeriesDataFromArray.ts
@@ -37,12 +37,16 @@ function isDataStorage(val: unknown): val is DataStorage {
     return val instanceof DataStorage;
 }
 
-function createListFromArray(sourceOrStore: Source | OptionSourceData | DataStorage, seriesModel: SeriesModel, opt?: {
-    generateCoord?: string
-    useEncodeDefaulter?: boolean | EncodeDefaulter
-    // By default: auto. If `true`, create inverted indices for all ordinal dimension on coordSys.
-    createInvertedIndices?: boolean
-}): SeriesData {
+function createListFromArray(
+    sourceOrStore: Source | OptionSourceData | DataStorage,
+    seriesModel: SeriesModel,
+    opt?: {
+        generateCoord?: string
+        useEncodeDefaulter?: boolean | EncodeDefaulter
+        // By default: auto. If `true`, create inverted indices for all ordinal dimension on coordSys.
+        createInvertedIndices?: boolean
+    }
+): SeriesData {
     opt = opt || {};
 
     if (!isSourceInstance(sourceOrStore) && !isDataStorage(sourceOrStore)) {
@@ -86,6 +90,7 @@ function createListFromArray(sourceOrStore: Source | OptionSourceData | DataStor
         {
             coordDimensions: coordSysDimDefs,
             generateCoord: opt.generateCoord,
+            encodeDefine: seriesModel.getEncode(),
             encodeDefaulter: zrUtil.isFunction(useEncodeDefaulter)
                 ? useEncodeDefaulter
                 : useEncodeDefaulter
diff --git a/src/chart/helper/createSeriesDataSimply.ts b/src/chart/helper/createSeriesDataSimply.ts
index 3a8c403..f84bb21 100644
--- a/src/chart/helper/createSeriesDataSimply.ts
+++ b/src/chart/helper/createSeriesDataSimply.ts
@@ -37,7 +37,11 @@ export default function createSeriesDataSimply(
     opt: CreateDimensionsParams | CreateDimensionsParams['coordDimensions'],
     nameList?: string[]
 ): SeriesData {
-    opt = isArray(opt) && {coordDimensions: opt} || extend({}, opt);
+    opt = isArray(opt) && {
+        coordDimensions: opt
+    } || extend({
+        encodeDefine: seriesModel.getEncode()
+    }, opt);
 
     const source = seriesModel.getSource();
 
diff --git a/src/data/DataStorage.ts b/src/data/DataStorage.ts
index a7365ab..1a12b75 100644
--- a/src/data/DataStorage.ts
+++ b/src/data/DataStorage.ts
@@ -28,6 +28,7 @@ import {
 } from '../util/types';
 import { DataProvider } from './helper/dataProvider';
 import { parseDataValue } from './helper/dataValueHelper';
+import OrdinalMeta from './OrdinalMeta';
 import { Source } from './Source';
 
 const UNDEFINED = 'undefined';
@@ -82,6 +83,12 @@ export type DimValueGetter = (
 export interface DataStorageDimensionInfo {
     type?: DataStorageDimensionType;  // Default to be float.
     name?: string;
+    /**
+     * When using category axis.
+     * Category strings will be collected and stored in ordinalMeta.categories.
+     * And storage will store the index of categories.
+     */
+    ordinalMeta?: OrdinalMeta
 }
 
 let defaultDimValueGetters: {[sourceFormat: string]: DimValueGetter};
@@ -194,7 +201,8 @@ class DataStorage {
             }
         }
         for (let i = 0; i < dimensions.length; i++) {
-            const name = dimensions[i].name;
+            const dim = dimensions[i];
+            const name = dim.name;
             dimensionsIdxMap[prefix + name] = i;
         }
 
@@ -218,6 +226,47 @@ class DataStorage {
 
     getDimensionIndex: (dim: DimensionName) => number;
 
+    setOrdinalMeta(dimIdx: number, ordinalMeta: OrdinalMeta) {
+        const chunk = this._chunks[dimIdx];
+        const dim = this._dimensions[dimIdx];
+        // Already have value.
+        if (dim.ordinalMeta && dim.ordinalMeta.categories.length > 0) {
+            return;
+        }
+        for (let i = 0; i < chunk.length; i++) {
+            (chunk as any)[i] = ordinalMeta.parseAndCollect(chunk[i]);
+        }
+
+        dim.ordinalMeta = ordinalMeta;
+    }
+
+    getOrdinalMeta(dimIdx: number) {
+        const dimInfo = this._dimensions[dimIdx];
+        const ordinalMeta = dimInfo.ordinalMeta;
+        return ordinalMeta;
+    }
+
+    /**
+     * If we using dataset.
+     * Dimensions types may only know when we initializing series.
+     * So we need to sync the type back to storage when initlializing SeriesData back
+     *
+     * Will return false if dimension type has been known and different from given.
+     * We need to recreate a new data storage in this case.
+     */
+    syncDimensionTypes(targetDims: DataStorageDimensionInfo[]) {
+        for (let i = 0; i < targetDims.length; i++) {
+            const targetDim = targetDims[i];
+            const selfDimIdx = this.getDimensionIndex(targetDim.name);
+            const selfDim = this._dimensions[selfDimIdx];
+            if (!selfDim || (selfDim.type && selfDim.type !== targetDim.type)) {
+                return false;
+            }
+            selfDim.type = targetDim.type;
+        }
+        return true;
+    }
+
     /**
      * Caution: Can be only called on raw data (before `this._indices` created).
      */
@@ -501,333 +550,333 @@ class DataStorage {
     /**
      * Data filter
      */
-     filterSelf(
-         dims: DimensionIndex[],
-         cb: FilterCb
-     ) {
-         if (!this._count) {
-             return;
-         }
-
-         const count = this.count();
-         const Ctor = getIndicesCtor(this._rawCount);
-         const newIndices = new Ctor(count);
-         const value = [];
-         const dimSize = dims.length;
-
-         let offset = 0;
-         const dim0 = dims[0];
-         const chunks = this._chunks;
-
-         for (let i = 0; i < count; i++) {
-             let keep;
-             const rawIdx = this.getRawIndex(i);
-             // Simple optimization
-             if (dimSize === 0) {
-                 keep = (cb as FilterCb0)(i);
-             }
-             else if (dimSize === 1) {
-                 const val = chunks[dim0][rawIdx];
-                 keep = (cb as FilterCb1)(val, i);
-             }
-             else {
-                 let k = 0;
-                 for (; k < dimSize; k++) {
-                     value[k] = chunks[dims[k]][rawIdx];
-                 }
-                 value[k] = i;
-                 keep = (cb as FilterCb).apply(null, value);
-             }
-             if (keep) {
-                 newIndices[offset++] = rawIdx;
-             }
-         }
-
-         // Set indices after filtered.
-         if (offset < count) {
-             this._indices = newIndices;
-         }
-         this._count = offset;
-         // Reset data extent
-         this._extent = [];
-
-         this._updateGetRawIdx();
-     }
-
-     /**
-      * Select data in range. (For optimization of filter)
-      * (Manually inline code, support 5 million data filtering in data zoom.)
-      */
-     selectRange(range: {[dimIdx: number]: [number, number]}) {
-
-         const len = this._count;
-
-         if (!len) {
-             return;
-         }
-
-         const dims = keys(range);
-         const dimSize = dims.length;
-         if (!dimSize) {
-             return;
-         }
-
-         const originalCount = this.count();
-         const Ctor = getIndicesCtor(this._rawCount);
-         const newIndices = new Ctor(originalCount);
-
-         let offset = 0;
-         const dim0 = dims[0];
-
-         const min = range[dim0][0];
-         const max = range[dim0][1];
-         const storeArr = this._chunks;
-
-         let quickFinished = false;
-         if (!this._indices) {
-             // Extreme optimization for common case. About 2x faster in chrome.
-             let idx = 0;
-             if (dimSize === 1) {
-                 const dimStorage = storeArr[dims[0]];
-                 for (let i = 0; i < len; i++) {
-                     const val = dimStorage[i];
-                     // NaN will not be filtered. Consider the case, in line chart, empty
-                     // value indicates the line should be broken. But for the case like
-                     // scatter plot, a data item with empty value will not be rendered,
-                     // but the axis extent may be effected if some other dim of the data
-                     // item has value. Fortunately it is not a significant negative effect.
-                     if (
-                         (val >= min && val <= max) || isNaN(val as any)
-                     ) {
-                         newIndices[offset++] = idx;
-                     }
-                     idx++;
-                 }
-                 quickFinished = true;
-             }
-             else if (dimSize === 2) {
-                 const dimStorage = storeArr[dims[0]];
-                 const dimStorage2 = storeArr[dims[1]];
-                 const min2 = range[dims[1]][0];
-                 const max2 = range[dims[1]][1];
-                 for (let i = 0; i < len; i++) {
-                     const val = dimStorage[i];
-                     const val2 = dimStorage2[i];
-                     // Do not filter NaN, see comment above.
-                     if ((
-                             (val >= min && val <= max) || isNaN(val as any)
-                         )
-                         && (
-                             (val2 >= min2 && val2 <= max2) || isNaN(val2 as any)
-                         )
-                     ) {
-                         newIndices[offset++] = idx;
-                     }
-                     idx++;
-                 }
-                 quickFinished = true;
-             }
-         }
-         if (!quickFinished) {
-             if (dimSize === 1) {
-                 for (let i = 0; i < originalCount; i++) {
-                     const rawIndex = this.getRawIndex(i);
-                     const val = storeArr[dims[0]][rawIndex];
-                     // Do not filter NaN, see comment above.
-                     if (
-                         (val >= min && val <= max) || isNaN(val as any)
-                     ) {
-                         newIndices[offset++] = rawIndex;
-                     }
-                 }
-             }
-             else {
-                 for (let i = 0; i < originalCount; i++) {
-                     let keep = true;
-                     const rawIndex = this.getRawIndex(i);
-                     for (let k = 0; k < dimSize; k++) {
-                         const dimk = dims[k];
-                         const val = storeArr[dimk][rawIndex];
-                         // Do not filter NaN, see comment above.
-                         if (val < range[dimk][0] || val > range[dimk][1]) {
-                             keep = false;
-                         }
-                     }
-                     if (keep) {
-                         newIndices[offset++] = this.getRawIndex(i);
-                     }
-                 }
-             }
-         }
-
-         // Set indices after filtered.
-         if (offset < originalCount) {
-             this._indices = newIndices;
-         }
-         this._count = offset;
-         // Reset data extent
-         this._extent = [];
-
-         this._updateGetRawIdx();
-     }
-
-     /**
-      * Data mapping to a plain array
-      */
-     /* eslint-enable */
-     mapArray(dims: DimensionIndex[], cb: MapArrayCb): any[] {
-         const result: any[] = [];
-         this.each(dims, function () {
-             result.push(cb && (cb as MapArrayCb).apply(null, arguments));
-         });
-         return result;
-     }
-
-     /**
-      * Data mapping to a new List with given dimensions
-      */
-     map(dims: DimensionIndex[], cb: MapCb): DataStorage {
+    filterSelf(
+        dims: DimensionIndex[],
+        cb: FilterCb
+    ) {
+        if (!this._count) {
+            return;
+        }
+
+        const count = this.count();
+        const Ctor = getIndicesCtor(this._rawCount);
+        const newIndices = new Ctor(count);
+        const value = [];
+        const dimSize = dims.length;
+
+        let offset = 0;
+        const dim0 = dims[0];
+        const chunks = this._chunks;
+
+        for (let i = 0; i < count; i++) {
+            let keep;
+            const rawIdx = this.getRawIndex(i);
+            // Simple optimization
+            if (dimSize === 0) {
+                keep = (cb as FilterCb0)(i);
+            }
+            else if (dimSize === 1) {
+                const val = chunks[dim0][rawIdx];
+                keep = (cb as FilterCb1)(val, i);
+            }
+            else {
+                let k = 0;
+                for (; k < dimSize; k++) {
+                    value[k] = chunks[dims[k]][rawIdx];
+                }
+                value[k] = i;
+                keep = (cb as FilterCb).apply(null, value);
+            }
+            if (keep) {
+                newIndices[offset++] = rawIdx;
+            }
+        }
+
+        // Set indices after filtered.
+        if (offset < count) {
+            this._indices = newIndices;
+        }
+        this._count = offset;
+        // Reset data extent
+        this._extent = [];
+
+        this._updateGetRawIdx();
+    }
+
+    /**
+     * Select data in range. (For optimization of filter)
+     * (Manually inline code, support 5 million data filtering in data zoom.)
+     */
+    selectRange(range: {[dimIdx: number]: [number, number]}) {
+
+        const len = this._count;
+
+        if (!len) {
+            return;
+        }
+
+        const dims = keys(range);
+        const dimSize = dims.length;
+        if (!dimSize) {
+            return;
+        }
+
+        const originalCount = this.count();
+        const Ctor = getIndicesCtor(this._rawCount);
+        const newIndices = new Ctor(originalCount);
+
+        let offset = 0;
+        const dim0 = dims[0];
+
+        const min = range[dim0][0];
+        const max = range[dim0][1];
+        const storeArr = this._chunks;
+
+        let quickFinished = false;
+        if (!this._indices) {
+            // Extreme optimization for common case. About 2x faster in chrome.
+            let idx = 0;
+            if (dimSize === 1) {
+                const dimStorage = storeArr[dims[0]];
+                for (let i = 0; i < len; i++) {
+                    const val = dimStorage[i];
+                    // NaN will not be filtered. Consider the case, in line chart, empty
+                    // value indicates the line should be broken. But for the case like
+                    // scatter plot, a data item with empty value will not be rendered,
+                    // but the axis extent may be effected if some other dim of the data
+                    // item has value. Fortunately it is not a significant negative effect.
+                    if (
+                        (val >= min && val <= max) || isNaN(val as any)
+                    ) {
+                        newIndices[offset++] = idx;
+                    }
+                    idx++;
+                }
+                quickFinished = true;
+            }
+            else if (dimSize === 2) {
+                const dimStorage = storeArr[dims[0]];
+                const dimStorage2 = storeArr[dims[1]];
+                const min2 = range[dims[1]][0];
+                const max2 = range[dims[1]][1];
+                for (let i = 0; i < len; i++) {
+                    const val = dimStorage[i];
+                    const val2 = dimStorage2[i];
+                    // Do not filter NaN, see comment above.
+                    if ((
+                            (val >= min && val <= max) || isNaN(val as any)
+                        )
+                        && (
+                            (val2 >= min2 && val2 <= max2) || isNaN(val2 as any)
+                        )
+                    ) {
+                        newIndices[offset++] = idx;
+                    }
+                    idx++;
+                }
+                quickFinished = true;
+            }
+        }
+        if (!quickFinished) {
+            if (dimSize === 1) {
+                for (let i = 0; i < originalCount; i++) {
+                    const rawIndex = this.getRawIndex(i);
+                    const val = storeArr[dims[0]][rawIndex];
+                    // Do not filter NaN, see comment above.
+                    if (
+                        (val >= min && val <= max) || isNaN(val as any)
+                    ) {
+                        newIndices[offset++] = rawIndex;
+                    }
+                }
+            }
+            else {
+                for (let i = 0; i < originalCount; i++) {
+                    let keep = true;
+                    const rawIndex = this.getRawIndex(i);
+                    for (let k = 0; k < dimSize; k++) {
+                        const dimk = dims[k];
+                        const val = storeArr[dimk][rawIndex];
+                        // Do not filter NaN, see comment above.
+                        if (val < range[dimk][0] || val > range[dimk][1]) {
+                            keep = false;
+                        }
+                    }
+                    if (keep) {
+                        newIndices[offset++] = this.getRawIndex(i);
+                    }
+                }
+            }
+        }
+
+        // Set indices after filtered.
+        if (offset < originalCount) {
+            this._indices = newIndices;
+        }
+        this._count = offset;
+        // Reset data extent
+        this._extent = [];
+
+        this._updateGetRawIdx();
+    }
+
+    /**
+     * Data mapping to a plain array
+     */
+    /* eslint-enable */
+    mapArray(dims: DimensionIndex[], cb: MapArrayCb): any[] {
+        const result: any[] = [];
+        this.each(dims, function () {
+            result.push(cb && (cb as MapArrayCb).apply(null, arguments));
+        });
+        return result;
+    }
+
+    /**
+     * Data mapping to a new List with given dimensions
+     */
+    map(dims: DimensionIndex[], cb: MapCb): DataStorage {
         // TODO only clone picked chunks.
-         const target = this.clone(dims, true);
-         const targetChunks = target._chunks;
-
-
-         const tmpRetValue = [];
-         const dimSize = dims.length;
-         const dataCount = this.count();
-         const values = [];
-         const rawExtent = target._rawExtent;
-
-         for (let dataIndex = 0; dataIndex < dataCount; dataIndex++) {
-            const rawIndex = this.getRawIndex(dataIndex);
-
-             for (let k = 0; k < dimSize; k++) {
-                 values[k] = targetChunks[dims[k]][rawIndex];
-             }
-             values[dimSize] = dataIndex;
-
-             let retValue = cb && cb.apply(null, values);
-             if (retValue != null) {
-                 // a number or string (in oridinal dimension)?
-                 if (typeof retValue !== 'object') {
-                     tmpRetValue[0] = retValue;
-                     retValue = tmpRetValue;
-                 }
-
-                 for (let i = 0; i < retValue.length; i++) {
-                     const dim = dims[i];
-                     const val = retValue[i];
-                     const rawExtentOnDim = rawExtent[dim];
-
-                     const dimStore = targetChunks[dim];
-                     if (dimStore) {
-                         (dimStore as ParsedValue[])[rawIndex] = val;
-                     }
-
-                     if (val < rawExtentOnDim[0]) {
-                         rawExtentOnDim[0] = val as number;
-                     }
-                     if (val > rawExtentOnDim[1]) {
-                         rawExtentOnDim[1] = val as number;
-                     }
-                 }
-             }
-         }
-
-         return target;
-     }
-
-     /**
-      * Large data down sampling using largest-triangle-three-buckets
-      * @param {string} valueDimension
-      * @param {number} targetCount
-      */
-     lttbDownSample(
-         valueDimension: DimensionIndex,
-         rate: number
-     ) {
-         const target = this.clone([valueDimension]);
-         const targetStorage = target._chunks;
-         const dimStore = targetStorage[valueDimension];
-         const len = this.count();
-
-         let sampledIndex = 0;
-
-         const frameSize = Math.floor(1 / rate);
-
-         let currentRawIndex = this.getRawIndex(0);
-         let maxArea;
-         let area;
-         let nextRawIndex;
-
-         const newIndices = new (getIndicesCtor(this._rawCount))(Math.ceil(len / frameSize) + 1);
-
-         // First frame use the first data.
-         newIndices[sampledIndex++] = currentRawIndex;
-         for (let i = 1; i < len - 1; i += frameSize) {
-             const nextFrameStart = Math.min(i + frameSize, len - 1);
-             const nextFrameEnd = Math.min(i + frameSize * 2, len);
-
-             const avgX = (nextFrameEnd + nextFrameStart) / 2;
-             let avgY = 0;
-
-             for (let idx = nextFrameStart; idx < nextFrameEnd; idx++) {
-                 const rawIndex = this.getRawIndex(idx);
-                 const y = dimStore[rawIndex] as number;
-                 if (isNaN(y)) {
-                     continue;
-                 }
-                 avgY += y as number;
-             }
-             avgY /= (nextFrameEnd - nextFrameStart);
-
-             const frameStart = i;
-             const frameEnd = Math.min(i + frameSize, len);
-
-             const pointAX = i - 1;
-             const pointAY = dimStore[currentRawIndex] as number;
-
-             maxArea = -1;
-
-             nextRawIndex = frameStart;
-             // Find a point from current frame that construct a triangel with largest area with previous selected point
-             // And the average of next frame.
-             for (let idx = frameStart; idx < frameEnd; idx++) {
-                 const rawIndex = this.getRawIndex(idx);
-                 const y = dimStore[rawIndex] as number;
-                 if (isNaN(y)) {
-                     continue;
-                 }
-                 // Calculate triangle area over three buckets
-                 area = Math.abs((pointAX - avgX) * (y - pointAY)
-                     - (pointAX - idx) * (avgY - pointAY)
-                 );
-                 if (area > maxArea) {
-                     maxArea = area;
-                     nextRawIndex = rawIndex; // Next a is this b
-                 }
-             }
-
-             newIndices[sampledIndex++] = nextRawIndex;
-
-             currentRawIndex = nextRawIndex; // This a is the next a (chosen b)
-         }
-
-         // First frame use the last data.
-         newIndices[sampledIndex++] = this.getRawIndex(len - 1);
-         target._count = sampledIndex;
-         target._indices = newIndices;
-
-         target.getRawIndex = this._getRawIdx;
-         return target;
-     }
+        const target = this.clone(dims, true);
+        const targetChunks = target._chunks;
+
+
+        const tmpRetValue = [];
+        const dimSize = dims.length;
+        const dataCount = this.count();
+        const values = [];
+        const rawExtent = target._rawExtent;
+
+        for (let dataIndex = 0; dataIndex < dataCount; dataIndex++) {
+        const rawIndex = this.getRawIndex(dataIndex);
+
+            for (let k = 0; k < dimSize; k++) {
+                values[k] = targetChunks[dims[k]][rawIndex];
+            }
+            values[dimSize] = dataIndex;
+
+            let retValue = cb && cb.apply(null, values);
+            if (retValue != null) {
+                // a number or string (in oridinal dimension)?
+                if (typeof retValue !== 'object') {
+                    tmpRetValue[0] = retValue;
+                    retValue = tmpRetValue;
+                }
+
+                for (let i = 0; i < retValue.length; i++) {
+                    const dim = dims[i];
+                    const val = retValue[i];
+                    const rawExtentOnDim = rawExtent[dim];
+
+                    const dimStore = targetChunks[dim];
+                    if (dimStore) {
+                        (dimStore as ParsedValue[])[rawIndex] = val;
+                    }
+
+                    if (val < rawExtentOnDim[0]) {
+                        rawExtentOnDim[0] = val as number;
+                    }
+                    if (val > rawExtentOnDim[1]) {
+                        rawExtentOnDim[1] = val as number;
+                    }
+                }
+            }
+        }
+
+        return target;
+    }
+
+    /**
+     * Large data down sampling using largest-triangle-three-buckets
+     * @param {string} valueDimension
+     * @param {number} targetCount
+     */
+    lttbDownSample(
+        valueDimension: DimensionIndex,
+        rate: number
+    ) {
+        const target = this.clone([valueDimension]);
+        const targetStorage = target._chunks;
+        const dimStore = targetStorage[valueDimension];
+        const len = this.count();
+
+        let sampledIndex = 0;
+
+        const frameSize = Math.floor(1 / rate);
+
+        let currentRawIndex = this.getRawIndex(0);
+        let maxArea;
+        let area;
+        let nextRawIndex;
+
+        const newIndices = new (getIndicesCtor(this._rawCount))(Math.ceil(len / frameSize) + 1);
+
+        // First frame use the first data.
+        newIndices[sampledIndex++] = currentRawIndex;
+        for (let i = 1; i < len - 1; i += frameSize) {
+            const nextFrameStart = Math.min(i + frameSize, len - 1);
+            const nextFrameEnd = Math.min(i + frameSize * 2, len);
+
+            const avgX = (nextFrameEnd + nextFrameStart) / 2;
+            let avgY = 0;
+
+            for (let idx = nextFrameStart; idx < nextFrameEnd; idx++) {
+                const rawIndex = this.getRawIndex(idx);
+                const y = dimStore[rawIndex] as number;
+                if (isNaN(y)) {
+                    continue;
+                }
+                avgY += y as number;
+            }
+            avgY /= (nextFrameEnd - nextFrameStart);
+
+            const frameStart = i;
+            const frameEnd = Math.min(i + frameSize, len);
+
+            const pointAX = i - 1;
+            const pointAY = dimStore[currentRawIndex] as number;
+
+            maxArea = -1;
+
+            nextRawIndex = frameStart;
+            // Find a point from current frame that construct a triangel with largest area with previous selected point
+            // And the average of next frame.
+            for (let idx = frameStart; idx < frameEnd; idx++) {
+                const rawIndex = this.getRawIndex(idx);
+                const y = dimStore[rawIndex] as number;
+                if (isNaN(y)) {
+                    continue;
+                }
+                // Calculate triangle area over three buckets
+                area = Math.abs((pointAX - avgX) * (y - pointAY)
+                    - (pointAX - idx) * (avgY - pointAY)
+                );
+                if (area > maxArea) {
+                    maxArea = area;
+                    nextRawIndex = rawIndex; // Next a is this b
+                }
+            }
+
+            newIndices[sampledIndex++] = nextRawIndex;
+
+            currentRawIndex = nextRawIndex; // This a is the next a (chosen b)
+        }
+
+        // First frame use the last data.
+        newIndices[sampledIndex++] = this.getRawIndex(len - 1);
+        target._count = sampledIndex;
+        target._indices = newIndices;
+
+        target.getRawIndex = this._getRawIdx;
+        return target;
+    }
 
 
     /**
      * Large data down sampling on given dimension
      * @param sampleIndex Sample index for name and id
      */
-     downSample(
+    downSample(
         dimension: DimensionIndex,
         rate: number,
         sampleValue: (frameValues: ArrayLike<ParsedValue>) => ParsedValueNumeric,
@@ -889,40 +938,40 @@ class DataStorage {
      *  list.each(['x', 'y'], function (x, y, idx) {});
      *  list.each(function (idx) {})
      */
-     each(dims: DimensionIndex[], cb: EachCb): void {
-         if (!this._count) {
-             return;
-         }
-         const dimSize = dims.length;
-         const chunks = this._chunks;
-
-         for (let i = 0, len = this.count(); i < len; i++) {
-             const rawIdx = this.getRawIndex(i);
-             // Simple optimization
-             switch (dimSize) {
-                 case 0:
-                     (cb as EachCb0)(i);
-                     break;
-                 case 1:
-                     (cb as EachCb1)(chunks[dims[0]][rawIdx], i);
-                     break;
-                 case 2:
-                     (cb as EachCb2)(
-                         chunks[dims[0]][rawIdx], chunks[dims[1]][rawIdx], i
-                     );
-                     break;
-                 default:
-                     let k = 0;
-                     const value = [];
-                     for (; k < dimSize; k++) {
-                         value[k] = chunks[dims[k]][rawIdx];
-                     }
-                     // Index
-                     value[k] = i;
-                     (cb as EachCb).apply(null, value);
-             }
-         }
-     }
+    each(dims: DimensionIndex[], cb: EachCb): void {
+        if (!this._count) {
+            return;
+        }
+        const dimSize = dims.length;
+        const chunks = this._chunks;
+
+        for (let i = 0, len = this.count(); i < len; i++) {
+            const rawIdx = this.getRawIndex(i);
+            // Simple optimization
+            switch (dimSize) {
+                case 0:
+                    (cb as EachCb0)(i);
+                    break;
+                case 1:
+                    (cb as EachCb1)(chunks[dims[0]][rawIdx], i);
+                    break;
+                case 2:
+                    (cb as EachCb2)(
+                        chunks[dims[0]][rawIdx], chunks[dims[1]][rawIdx], i
+                    );
+                    break;
+                default:
+                    let k = 0;
+                    const value = [];
+                    for (; k < dimSize; k++) {
+                        value[k] = chunks[dims[k]][rawIdx];
+                    }
+                    // Index
+                    value[k] = i;
+                    (cb as EachCb).apply(null, value);
+            }
+        }
+    }
 
     /**
      * Get extent of data in one dimension
@@ -976,31 +1025,31 @@ class DataStorage {
      * Do not initialize.
      * Default `getRawIndex`. And it can be changed.
      */
-     getRawIndex: (idx: number) => number;
-
-     /**
-      * Get raw data item
-      */
-     getRawDataItem(idx: number): OptionDataItem {
-         const rawIdx = this.getRawIndex(idx);
-         if (!this._provider.persistent) {
-             const val = [];
-             const chunks = this._chunks;
-             for (let i = 0; i < chunks.length; i++) {
-                 val.push(chunks[i][rawIdx]);
-             }
-             return val;
-         }
-         else {
-             return this._provider.getItem(this.getRawIndex(idx));
-         }
-     }
-
-     /**
-      *
-      * @param clonedDims Determine which dims to clone. Will share the data if not specified.
-      */
-     clone(clonedDims?: number[], cloneIndices?: boolean): DataStorage {
+    getRawIndex: (idx: number) => number;
+
+    /**
+     * Get raw data item
+     */
+    getRawDataItem(idx: number): OptionDataItem {
+        const rawIdx = this.getRawIndex(idx);
+        if (!this._provider.persistent) {
+            const val = [];
+            const chunks = this._chunks;
+            for (let i = 0; i < chunks.length; i++) {
+                val.push(chunks[i][rawIdx]);
+            }
+            return val;
+        }
+        else {
+            return this._provider.getItem(this.getRawIndex(idx));
+        }
+    }
+
+    /**
+     *
+     * @param clonedDims Determine which dims to clone. Will share the data if not specified.
+     */
+    clone(clonedDims?: number[], cloneIndices?: boolean): DataStorage {
         const target = new DataStorage();
         const chunks = this._chunks;
         const clonedDimsMap = clonedDims && reduce(clonedDims, (obj, dimIdx) => {
@@ -1025,9 +1074,9 @@ class DataStorage {
         }
         target._updateGetRawIdx();
         return target;
-     }
+    }
 
-     private _copyCommonProps(target: DataStorage) {
+    private _copyCommonProps(target: DataStorage) {
         target._count = this._count;
         target._rawCount = this._rawCount;
         target._provider = this._provider;
@@ -1036,9 +1085,9 @@ class DataStorage {
 
         target._extent = clone(this._extent);
         target._rawExtent = clone(this._rawExtent);
-     }
+    }
 
-     private _cloneIndices() {
+    private _cloneIndices() {
         if (this._indices) {
             const Ctor = this._indices.constructor as DataArrayLikeConstructor;
             let indices;
@@ -1055,21 +1104,21 @@ class DataStorage {
             return indices;
         }
         return null;
-     }
+    }
 
-     private _getRawIdxIdentity(idx: number) {
-         return idx;
-     }
-     private _getRawIdx(idx: number) {
+    private _getRawIdxIdentity(idx: number) {
+        return idx;
+    }
+    private _getRawIdx(idx: number) {
         if (idx < this._count && idx >= 0) {
             return this._indices[idx];
         }
         return -1;
-     }
+    }
 
-     private _updateGetRawIdx() {
+    private _updateGetRawIdx() {
         this.getRawIndex = this._indices ? this._getRawIdx : this._getRawIdxIdentity;
-     }
+    }
 
     private static internalField = (function () {
 
@@ -1086,7 +1135,7 @@ class DataStorage {
             objectRows(
                 this: DataStorage, dataItem: any, dimName: string, dataIndex: number, dimIndex: number
             ): ParsedValue {
-                return parseDataValue(dataItem[dimName], this._dimensions[dataIndex]);
+                return parseDataValue(dataItem[dimName], this._dimensions[dimIndex]);
             },
 
             keyedColumns: getDimValueSimply,
diff --git a/src/data/SeriesData.ts b/src/data/SeriesData.ts
index 3a28396..74b3bf3 100644
--- a/src/data/SeriesData.ts
+++ b/src/data/SeriesData.ts
@@ -320,16 +320,8 @@ class SeriesData<
         return dim as DimensionName;
     }
 
-    getDimensionIndex(dim: DimensionLoose): DimensionIndex {
-        if (typeof dim === 'number') {
-            return dim;
-        }
-        const idx = this._store.getDimensionIndex(dim);
-        if (idx == null) {
-            // If being a number-like string but not being defined a dimension name.
-            return +dim;
-        }
-        return idx;
+    private _getStoreDimIndex(dim: DimensionLoose): DimensionIndex {
+        return this._store.getDimensionIndex(this.getDimension(dim));
     }
 
     /**
@@ -375,7 +367,7 @@ class SeriesData<
         return (dims || []).slice();
     }
 
-    getStore() {
+    getStorage() {
         return this._store;
     }
 
@@ -394,19 +386,35 @@ class SeriesData<
         dimValueGetter?: DimValueGetter
     ): void {
         let store: DataStorage;
+        const dimensions = this.dimensions;
+        const dimensionInfos = map(dimensions, dimName => this._dimensionInfos[dimName]);
         if (data instanceof DataStorage) {
-            store = data;
+            if (data.syncDimensionTypes(dimensionInfos)) {
+                store = data;
+            }
+            // Sync failed
+            else {
+                // Needs to recreate data storage if it's not match the given dimension.
+                data = data.getSource();
+            }
         }
-        else {
-            const dimensions = this.dimensions;
+
+        if (!store) {
             const provider = (isSourceInstance(data) || zrUtil.isArrayLike(data))
                 ? new DefaultDataProvider(data as Source | OptionSourceData, dimensions.length)
                 : data as DataProvider;
-            const dimensionInfos = map(dimensions, dimName => this._dimensionInfos[dimName]);
             store = new DataStorage();
             store.initData(provider, dimensionInfos, dimValueGetter);
         }
 
+        for (let i = 0; i < dimensions.length; i++) {
+            const dimInfo = this._dimensionInfos[dimensions[i]];
+            if (dimInfo.ordinalMeta) {
+                const dimIdx = store.getDimensionIndex(dimensions[i]);
+                store.setOrdinalMeta(dimIdx, dimInfo.ordinalMeta);
+            }
+        }
+
         this._store = store;
 
         // Reset
@@ -514,7 +522,7 @@ class SeriesData<
      * be erased because of the filtering.
      */
     getApproximateExtent(dim: DimensionLoose): [number, number] {
-        return this._approximateExtent[dim] || this._store.getDataExtent(this.getDimensionIndex(dim));
+        return this._approximateExtent[dim] || this._store.getDataExtent(this._getStoreDimIndex(dim));
     }
 
     /**
@@ -571,11 +579,11 @@ class SeriesData<
 
     private _getCategory(dimIdx: number, idx: number) {
         const ordinal = this._store.get(dimIdx, idx);
-        const dimInfo = this._dimensionInfos[this.dimensions[dimIdx]];
-        const ordinalMeta = dimInfo.ordinalMeta;
+        const ordinalMeta = this._store.getOrdinalMeta(dimIdx);
         if (ordinalMeta) {
             return ordinalMeta.categories[ordinal as OrdinalNumber];
         }
+        return ordinal;
     }
 
     /**
@@ -610,15 +618,15 @@ class SeriesData<
     }
 
     getDataExtent(dim: DimensionLoose): [number, number] {
-        return this._store.getDataExtent(this.getDimensionIndex(dim));
+        return this._store.getDataExtent(this._getStoreDimIndex(dim));
     }
 
     getSum(dim: DimensionLoose): number {
-        return this._store.getSum(this.getDimensionIndex(dim));
+        return this._store.getSum(this._getStoreDimIndex(dim));
     }
 
     getMedian(dim: DimensionLoose): number {
-        return this._store.getMedian(this.getDimensionIndex(dim));
+        return this._store.getMedian(this._getStoreDimIndex(dim));
     }
     /**
      * Get value for multi dimensions.
@@ -709,7 +717,7 @@ class SeriesData<
      */
     indicesOfNearest(dim: DimensionLoose, value: number, maxDistance?: number): number[] {
         return this._store.indicesOfNearest(
-            this.getDimensionIndex(dim),
+            this._getStoreDimIndex(dim),
             value, maxDistance
         );
     }
@@ -742,7 +750,7 @@ class SeriesData<
         // ctxCompat just for compat echarts3
         const fCtx = (ctx || this) as CtxOrList<Ctx>;
 
-        const dimIndices = map(normalizeDimensions(dims), this.getDimensionIndex, this);
+        const dimIndices = map(normalizeDimensions(dims), this._getStoreDimIndex, this);
 
         if (__DEV__) {
             validateDimensions(this, dimIndices);
@@ -777,7 +785,7 @@ class SeriesData<
         // ctxCompat just for compat echarts3
         const fCtx = (ctx || this) as CtxOrList<Ctx>;
 
-        const dimIndices = map(normalizeDimensions(dims), this.getDimensionIndex, this);
+        const dimIndices = map(normalizeDimensions(dims), this._getStoreDimIndex, this);
 
         if (__DEV__) {
             validateDimensions(this, dimIndices);
@@ -802,7 +810,7 @@ class SeriesData<
         const dims = zrUtil.keys(range);
         const dimIndices: number[] = [];
         zrUtil.each(dims, (dim) => {
-            const dimIdx = this.getDimensionIndex(dim);
+            const dimIdx = this._getStoreDimIndex(dim);
             innerRange[dimIdx] = range[dim];
             dimIndices.push(dimIdx);
         });
@@ -867,7 +875,7 @@ class SeriesData<
         const fCtx = (ctx || ctxCompat || this) as CtxOrList<Ctx>;
 
         const dimIndices = map(
-            normalizeDimensions(dims), this.getDimensionIndex, this
+            normalizeDimensions(dims), this._getStoreDimIndex, this
         );
 
         if (__DEV__) {
@@ -894,7 +902,7 @@ class SeriesData<
     ): SeriesData<HostModel> {
         const list = cloneListForMapAndSample(this);
         list._store = this._store.downSample(
-            this.getDimensionIndex(dimension),
+            this._getStoreDimIndex(dimension),
             rate,
             sampleValue,
             sampleIndex
@@ -913,7 +921,7 @@ class SeriesData<
     ) {
         const list = cloneListForMapAndSample(this);
         list._store = this._store.lttbDownSample(
-            this.getDimensionIndex(valueDimension),
+            this._getStoreDimIndex(valueDimension),
             rate
         );
         return list;
@@ -942,8 +950,8 @@ class SeriesData<
         const thisList = this;
 
         return new DataDiffer(
-            otherList ? otherList.getStore().getIndices() : [],
-            this.getStore().getIndices(),
+            otherList ? otherList.getStorage().getIndices() : [],
+            this.getStorage().getIndices(),
             function (idx: number) {
                 return getId(otherList, idx);
             },
diff --git a/src/data/Source.ts b/src/data/Source.ts
index bedebb1..3d56655 100644
--- a/src/data/Source.ts
+++ b/src/data/Source.ts
@@ -45,6 +45,7 @@ import {
 } from '../util/types';
 import { DatasetOption } from '../component/dataset/install';
 import { getDataItemValue } from '../util/model';
+import { BE_ORDINAL, guessOrdinal } from './helper/sourceHelper';
 
 /**
  * [sourceFormat]
@@ -120,13 +121,6 @@ class SourceImpl {
     readonly dimensionsDefine: DimensionDefinition[];
 
     /**
-     * encode definition in option.
-     * can be null/undefined.
-     * Might be specified outside.
-     */
-    readonly encodeDefine: HashMap<OptionEncodeValue, DimensionName>;
-
-    /**
      * Only make sense in `SOURCE_FORMAT_ARRAY_ROWS`.
      * That is the same as `sourceHeader: number`,
      * which means from which line the real data start.
@@ -176,42 +170,21 @@ class SourceImpl {
         // Visit config
         this.seriesLayoutBy = fields.seriesLayoutBy || SERIES_LAYOUT_BY_COLUMN;
         this.startIndex = fields.startIndex || 0;
-        this.dimensionsDefine = fields.dimensionsDefine;
         this.dimensionsDetectedCount = fields.dimensionsDetectedCount;
-        this.encodeDefine = fields.encodeDefine;
         this.metaRawOption = fields.metaRawOption;
-    }
 
-    // There is performance issue in some browser like Safari,
-    // an also slower than clone in Chrome.
-    // So DO NOT use `Object.freeze`.
-    /**
-     * When expose the source to thrid-party transform, it probably better to
-     * freeze to make sure immutability.
-     * If a third-party transform modify the raw upstream data structure, it might bring about
-     * "uncertain effect" when using multiple transforms with different combinations.
-     *
-     * [Caveat]
-     * `OptionManager.ts` have perform `clone` in `setOption`.
-     * The original user input object should better not be frozen in case they
-     * make other usages.
-     */
-    // freeze() {
-    //     assert(sourceFormatCanBeExposed(this));
-    //     const data = this.data as OptionSourceDataArrayRows;
-    //     if (this.frozen || !data || !isFunction(Object.freeze)) {
-    //         return;
-    //     }
-    //     // @ts-ignore
-    //     this.frozen = true;
-    //     // PENDING:
-    //     // There is a flaw that there might be non-primitive values like `Date`.
-    //     // Is it worth handling that?
-    //     for (let i = 0; i < data.length; i++) {
-    //         Object.freeze(data[i]);
-    //     }
-    //     Object.freeze(data);
-    // }
+        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';
+                    }
+                }
+            }
+        }
+    }
 
 }
 
@@ -223,8 +196,7 @@ export function createSource(
     sourceData: OptionSourceData,
     thisMetaRawOption: SourceMetaRawOption,
     // can be null. If not provided, auto detect it from `sourceData`.
-    sourceFormat: SourceFormat,
-    encodeDefine: OptionEncode  // can be null
+    sourceFormat: SourceFormat
 ): Source {
     sourceFormat = sourceFormat || detectSourceFormat(sourceData);
     const seriesLayoutBy = thisMetaRawOption.seriesLayoutBy;
@@ -243,7 +215,6 @@ export function createSource(
         dimensionsDefine: determined.dimensionsDefine,
         startIndex: determined.startIndex,
         dimensionsDetectedCount: determined.dimensionsDetectedCount,
-        encodeDefine: makeEncodeDefine(encodeDefine),
         metaRawOption: clone(thisMetaRawOption)
     });
 
@@ -273,20 +244,10 @@ export function cloneSourceShallow(source: Source): Source {
         seriesLayoutBy: source.seriesLayoutBy,
         dimensionsDefine: clone(source.dimensionsDefine),
         startIndex: source.startIndex,
-        dimensionsDetectedCount: source.dimensionsDetectedCount,
-        encodeDefine: makeEncodeDefine(source.encodeDefine)
+        dimensionsDetectedCount: source.dimensionsDetectedCount
     });
 }
 
-function makeEncodeDefine(
-    encodeDefine: OptionEncode | HashMap<OptionEncodeValue, DimensionName>
-): HashMap<OptionEncodeValue, DimensionName> {
-    // null means user not specify `series.encode`.
-    return encodeDefine
-        ? createHashMap<OptionEncodeValue, DimensionName>(encodeDefine)
-        : null;
-}
-
 /**
  * Note: An empty array will be detected as `SOURCE_FORMAT_ARRAY_ROWS`.
  */
diff --git a/src/data/helper/completeDimensions.ts b/src/data/helper/completeDimensions.ts
index 99072e8..f94c276 100644
--- a/src/data/helper/completeDimensions.ts
+++ b/src/data/helper/completeDimensions.ts
@@ -122,7 +122,7 @@ function completeDimensions(
         dimDefItem.displayName != null && (resultItem.displayName = dimDefItem.displayName);
     }
 
-    let encodeDef = opt.encodeDef || source.encodeDefine;
+    let encodeDef = opt.encodeDef;
     if (!encodeDef && opt.encodeDefaulter) {
         encodeDef = opt.encodeDefaulter(source, dimCount);
     }
diff --git a/src/data/helper/createDimensions.ts b/src/data/helper/createDimensions.ts
index d3f65b3..070bdf7 100644
--- a/src/data/helper/createDimensions.ts
+++ b/src/data/helper/createDimensions.ts
@@ -69,7 +69,7 @@ export default function createDimensions(
         source = source.getSource();
     }
     else if (source instanceof SeriesData) {
-        source = source.getStore().getSource();
+        source = source.getStorage().getSource();
     }
     else if (!isSourceInstance(source)) {
         source = createSourceFromSeriesDataOption(source as OptionSourceData);
@@ -77,7 +77,6 @@ export default function createDimensions(
 
     opt = opt || {};
     return completeDimensions(opt.coordDimensions || [], source, {
-        // FIXME:TS detect whether source then call `.dimensionsDefine` and `.encodeDefine`?
         dimsDef: opt.dimensionsDefine,
         encodeDef: opt.encodeDefine,
         dimCount: opt.dimensionsCount,
diff --git a/src/data/helper/dataProvider.ts b/src/data/helper/dataProvider.ts
index 66eb815..458fc2c 100644
--- a/src/data/helper/dataProvider.ts
+++ b/src/data/helper/dataProvider.ts
@@ -484,7 +484,7 @@ export function retrieveRawValue(
         return;
     }
 
-    const sourceFormat = data.getStore().getSource().sourceFormat;
+    const sourceFormat = data.getStorage().getSource().sourceFormat;
     let dimName;
     let dimIndex;
 
@@ -515,7 +515,7 @@ export function retrieveRawAttr(data: SeriesData, dataIndex: number, attr: strin
         return;
     }
 
-    const sourceFormat = data.getStore().getSource().sourceFormat;
+    const sourceFormat = data.getStorage().getSource().sourceFormat;
 
     if (sourceFormat !== SOURCE_FORMAT_ORIGINAL
         && sourceFormat !== SOURCE_FORMAT_OBJECT_ROWS
diff --git a/src/data/helper/dataValueHelper.ts b/src/data/helper/dataValueHelper.ts
index 98e36c8..2a625f3 100644
--- a/src/data/helper/dataValueHelper.ts
+++ b/src/data/helper/dataValueHelper.ts
@@ -40,18 +40,14 @@ export function parseDataValue(
         // will be parsed to NaN if do not set `type` as 'ordinal'. It has been
         // the logic in `List.ts` for long time. Follow the same way if you need
         // to get same result as List did from a raw value.
-        type?: DimensionType,
-        ordinalMeta?: OrdinalMeta
+        type?: DimensionType
     }
 ): ParsedValue {
     // Performance sensitive.
     const dimType = opt && opt.type;
     if (dimType === 'ordinal') {
         // If given value is a category string
-        const ordinalMeta = opt && opt.ordinalMeta;
-        return ordinalMeta
-            ? ordinalMeta.parseAndCollect(value)
-            : value;
+        return value;
     }
 
     if (dimType === 'time'
diff --git a/src/data/helper/sourceManager.ts b/src/data/helper/sourceManager.ts
index ed4e7eb..cc95e96 100644
--- a/src/data/helper/sourceManager.ts
+++ b/src/data/helper/sourceManager.ts
@@ -30,7 +30,7 @@ import {
     querySeriesUpstreamDatasetModel, queryDatasetUpstreamDatasetModels
 } from './sourceHelper';
 import { applyDataTransform } from './transform';
-import DataStorage, { DataStorageDimensionInfo } from '../DataStorage';
+import DataStorage from '../DataStorage';
 import { DefaultDataProvider } from './dataProvider';
 
 
@@ -237,8 +237,7 @@ export class SourceManager {
             resultSourceList = [createSource(
                 data,
                 { seriesLayoutBy, sourceHeader, dimensions },
-                sourceFormat,
-                seriesModel.get('encode', true)
+                sourceFormat
             )];
         }
         else {
@@ -256,8 +255,6 @@ export class SourceManager {
                 resultSourceList = [createSource(
                     sourceData,
                     this._getSourceMetaRawOption(),
-                    null,
-                    // Note: dataset option does not have `encode`.
                     null
                 )];
                 upstreamSignList = [];
@@ -356,8 +353,7 @@ export class SourceManager {
     }
 
     /**
-     * Will return undefined if source is series.data
-     * because dimension not known yet.
+     * Will return undefined if source don't have dimensions.
      */
     getDataStorage(): DataStorage | undefined {
         // TODO Can use other sourceIndex?
@@ -369,7 +365,7 @@ export class SourceManager {
         if (!cachedStore) {
             const upSourceMgr = this._getUpstreamSourceManagers()[0];
 
-            if (upSourceMgr) {
+            if (isSeries(this._sourceHost) && upSourceMgr) {
                 cachedStore = upSourceMgr.getDataStorage();
             }
             else {
diff --git a/src/data/helper/transform.ts b/src/data/helper/transform.ts
index 43625cd..78c1a70 100644
--- a/src/data/helper/transform.ts
+++ b/src/data/helper/transform.ts
@@ -533,7 +533,6 @@ function applySingleDataTransform(
         return createSource(
             result.data,
             resultMetaRawOption,
-            null,
             null
         );
     });
diff --git a/src/layout/points.ts b/src/layout/points.ts
index 2d138be..7228b38 100644
--- a/src/layout/points.ts
+++ b/src/layout/points.ts
@@ -69,7 +69,7 @@ export default function pointsLayout(seriesType: string, forceStoreInTypedArray?
 
                     const tmpIn: ParsedValueNumeric[] = [];
                     const tmpOut: number[] = [];
-                    const store = data.getStore();
+                    const store = data.getStorage();
 
                     for (let i = params.start, offset = 0; i < params.end; i++) {
                         let point;
diff --git a/src/model/Series.ts b/src/model/Series.ts
index 144da01..47ef654 100644
--- a/src/model/Series.ts
+++ b/src/model/Series.ts
@@ -23,7 +23,12 @@ import * as modelUtil from '../util/model';
 import {
     DataHost, DimensionName, StageHandlerProgressParams,
     SeriesOption, ZRColor, BoxLayoutOptionMixin,
-    ScaleDataValue, Dictionary, OptionDataItemObject, SeriesDataType
+    ScaleDataValue,
+    Dictionary,
+    OptionDataItemObject,
+    SeriesDataType,
+    SeriesEncodeOptionMixin,
+    OptionEncodeValue
 } from '../util/types';
 import ComponentModel, { ComponentModelConstructor } from './Component';
 import {PaletteMixin} from './mixin/palette';
@@ -386,9 +391,16 @@ class SeriesModel<Opt extends SeriesOption = SeriesOption> extends ComponentMode
         inner(this).data = data;
     }
 
+    getEncode() {
+        const encode = (this as Model<SeriesEncodeOptionMixin>).get('encode');
+        if (encode) {
+            return zrUtil.createHashMap<OptionEncodeValue, DimensionName>(encode);
+        }
+    }
+
     getSource(): DataStorage | Source {
         const sourceMgr = inner(this).sourceManager;
-        return sourceMgr.getDataStorage() || sourceMgr.getSource();
+        return sourceMgr.getSource();
     }
 
     /**
diff --git a/src/util/types.ts b/src/util/types.ts
index ebbe444..51c9a52 100644
--- a/src/util/types.ts
+++ b/src/util/types.ts
@@ -429,9 +429,6 @@ export interface DataVisualDimensions {
     label?: DimensionIndex;
     itemName?: DimensionIndex;
     itemId?: DimensionIndex;
-    // Group id is used for linking the aggregate relationship between two set of data.
-    // Which is useful in prepresenting the transition key of drilldown/up animation.
-    // Or hover linking.
     itemGroupId?: DimensionIndex;
     seriesName?: DimensionIndex;
 }
@@ -651,6 +648,11 @@ export interface OptionEncodeVisualDimensions {
     itemId?: OptionEncodeValue;
     seriesName?: OptionEncodeValue;
     // Notice: `value` is coordDim, not nonCoordDim.
+
+    // Group id is used for linking the aggregate relationship between two set of data.
+    // Which is useful in prepresenting the transition key of drilldown/up animation.
+    // Or hover linking.
+    itemGroupId?: OptionEncodeValue;
 }
 export interface OptionEncode extends OptionEncodeVisualDimensions {
     [coordDim: string]: OptionEncodeValue | undefined

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org