* Note that it is too complicated to support 3d stack by value * (have to create two-dimension inverted index), so in 3d case * we just support that stacked by index. * * @param {module:echarts/model/Series} seriesModel * @param {Array. } dimensionInfoList The same as the input of
(seriesModel, dimensionInfoList, opt)
| 32602 | * } |
| 32603 | */ |
| 32604 | function enableDataStack(seriesModel, dimensionInfoList, opt) { |
| 32605 | opt = opt || {}; |
| 32606 | var byIndex = opt.byIndex; |
| 32607 | var stackedCoordDimension = opt.stackedCoordDimension; |
| 32608 | |
| 32609 | // Compatibal: when `stack` is set as '', do not stack. |
| 32610 | var mayStack = !!(seriesModel && seriesModel.get('stack')); |
| 32611 | var stackedByDimInfo; |
| 32612 | var stackedDimInfo; |
| 32613 | var stackResultDimension; |
| 32614 | var stackedOverDimension; |
| 32615 | |
| 32616 | each$1(dimensionInfoList, function (dimensionInfo, index) { |
| 32617 | if (isString(dimensionInfo)) { |
| 32618 | dimensionInfoList[index] = dimensionInfo = {name: dimensionInfo}; |
| 32619 | } |
| 32620 | |
| 32621 | if (mayStack && !dimensionInfo.isExtraCoord) { |
| 32622 | // Find the first ordinal dimension as the stackedByDimInfo. |
| 32623 | if (!byIndex && !stackedByDimInfo && dimensionInfo.ordinalMeta) { |
| 32624 | stackedByDimInfo = dimensionInfo; |
| 32625 | } |
| 32626 | // Find the first stackable dimension as the stackedDimInfo. |
| 32627 | if (!stackedDimInfo |
| 32628 | && dimensionInfo.type !== 'ordinal' |
| 32629 | && dimensionInfo.type !== 'time' |
| 32630 | && (!stackedCoordDimension || stackedCoordDimension === dimensionInfo.coordDim) |
| 32631 | ) { |
| 32632 | stackedDimInfo = dimensionInfo; |
| 32633 | } |
| 32634 | } |
| 32635 | }); |
| 32636 | |
| 32637 | if (stackedDimInfo && !byIndex && !stackedByDimInfo) { |
| 32638 | // Compatible with previous design, value axis (time axis) only stack by index. |
| 32639 | // It may make sense if the user provides elaborately constructed data. |
| 32640 | byIndex = true; |
| 32641 | } |
| 32642 | |
| 32643 | // Add stack dimension, they can be both calculated by coordinate system in `unionExtent`. |
| 32644 | // That put stack logic in List is for using conveniently in echarts extensions, but it |
| 32645 | // might not be a good way. |
| 32646 | if (stackedDimInfo) { |
| 32647 | // Use a weird name that not duplicated with other names. |
| 32648 | stackResultDimension = '__\0ecstackresult'; |
| 32649 | stackedOverDimension = '__\0ecstackedover'; |
| 32650 | |
| 32651 | // Create inverted index to fast query index by value. |
| 32652 | if (stackedByDimInfo) { |
| 32653 | stackedByDimInfo.createInvertedIndices = true; |
| 32654 | } |
| 32655 | |
| 32656 | var stackedDimCoordDim = stackedDimInfo.coordDim; |
| 32657 | var stackedDimType = stackedDimInfo.type; |
| 32658 | var stackedDimCoordIndex = 0; |
| 32659 | |
| 32660 | each$1(dimensionInfoList, function (dimensionInfo) { |
| 32661 | if (dimensionInfo.coordDim === stackedDimCoordDim) { |
no test coverage detected