diff --git a/src/data/SeriesData.ts b/src/data/SeriesData.ts index 975cbad74e..82a427d71f 100644 --- a/src/data/SeriesData.ts +++ b/src/data/SeriesData.ts @@ -1391,7 +1391,7 @@ class SeriesData< const invertedIndicesMap = data._invertedIndicesMap; zrUtil.each(invertedIndicesMap, function (invertedIndices, dim) { const dimInfo = data._dimInfos[dim]; - // Currently, only dimensions that has ordinalMeta can create inverted indices. + // Currently, only dimensions that have ordinalMeta or are of type time can create inverted indices. const ordinalMeta = dimInfo.ordinalMeta; const store = data._store; if (ordinalMeta) { @@ -1408,6 +1408,13 @@ class SeriesData< invertedIndices[store.get(dimInfo.storeDimIndex, i) as number] = i; } } + else if (dimInfo.type === 'time') { + invertedIndices = invertedIndicesMap[dim] = { length: store.count() }; + for (let i = 0; i < store.count(); i++) { + // Only support the case that all values are distinct. + invertedIndices[store.get(dimInfo.storeDimIndex, i) as number] = i; + } + } }); }; diff --git a/src/data/helper/dataStackHelper.ts b/src/data/helper/dataStackHelper.ts index 549820c912..658d868fbd 100644 --- a/src/data/helper/dataStackHelper.ts +++ b/src/data/helper/dataStackHelper.ts @@ -103,7 +103,7 @@ export function enableDataStack( if (mayStack && !dimensionInfo.isExtraCoord) { // Find the first ordinal dimension as the stackedByDimInfo. - if (!byIndex && !stackedByDimInfo && dimensionInfo.ordinalMeta) { + if (!byIndex && !stackedByDimInfo && (dimensionInfo.ordinalMeta || dimensionInfo.type === 'time')) { stackedByDimInfo = dimensionInfo; } // Find the first stackable dimension as the stackedDimInfo. diff --git a/test/line-stack-disjunct-timeseries.html b/test/line-stack-disjunct-timeseries.html new file mode 100644 index 0000000000..8899479cc4 --- /dev/null +++ b/test/line-stack-disjunct-timeseries.html @@ -0,0 +1,121 @@ + + + + + + + + + + + + + + + + + +
+ + + +