(
coordDimensions: (DimensionName | CoordDimensionDefinition)[],
seriesModel: SeriesModel,
source: Source
)
| 97 | * @return encode Never be `null/undefined`. |
| 98 | */ |
| 99 | export function makeSeriesEncodeForAxisCoordSys( |
| 100 | coordDimensions: (DimensionName | CoordDimensionDefinition)[], |
| 101 | seriesModel: SeriesModel, |
| 102 | source: Source |
| 103 | ): SeriesEncodeInternal { |
| 104 | const encode: SeriesEncodeInternal = {}; |
| 105 | |
| 106 | const datasetModel = querySeriesUpstreamDatasetModel(seriesModel); |
| 107 | // Currently only make default when using dataset, util more reqirements occur. |
| 108 | if (!datasetModel || !coordDimensions) { |
| 109 | return encode; |
| 110 | } |
| 111 | |
| 112 | const encodeItemName: DimensionIndex[] = []; |
| 113 | const encodeSeriesName: DimensionIndex[] = []; |
| 114 | |
| 115 | const ecModel = seriesModel.ecModel; |
| 116 | const datasetMap = innerGlobalModel(ecModel).datasetMap; |
| 117 | const key = datasetModel.uid + '_' + source.seriesLayoutBy; |
| 118 | |
| 119 | let baseCategoryDimIndex: number; |
| 120 | let categoryWayValueDimStart; |
| 121 | coordDimensions = coordDimensions.slice(); |
| 122 | each(coordDimensions, function (coordDimInfoLoose, coordDimIdx) { |
| 123 | const coordDimInfo: CoordDimensionDefinition = isObject(coordDimInfoLoose) |
| 124 | ? coordDimInfoLoose |
| 125 | : (coordDimensions[coordDimIdx] = { name: coordDimInfoLoose as DimensionName }); |
| 126 | if (coordDimInfo.type === 'ordinal' && baseCategoryDimIndex == null) { |
| 127 | baseCategoryDimIndex = coordDimIdx; |
| 128 | categoryWayValueDimStart = getDataDimCountOnCoordDim(coordDimInfo); |
| 129 | } |
| 130 | encode[coordDimInfo.name] = []; |
| 131 | }); |
| 132 | |
| 133 | const datasetRecord = datasetMap.get(key) |
| 134 | || datasetMap.set(key, {categoryWayDim: categoryWayValueDimStart, valueWayDim: 0}); |
| 135 | |
| 136 | // TODO |
| 137 | // Auto detect first time axis and do arrangement. |
| 138 | each(coordDimensions, function (coordDimInfo: CoordDimensionDefinition, coordDimIdx) { |
| 139 | const coordDimName = coordDimInfo.name; |
| 140 | const count = getDataDimCountOnCoordDim(coordDimInfo); |
| 141 | |
| 142 | // In value way. |
| 143 | if (baseCategoryDimIndex == null) { |
| 144 | const start = datasetRecord.valueWayDim; |
| 145 | pushDim(encode[coordDimName], start, count); |
| 146 | pushDim(encodeSeriesName, start, count); |
| 147 | datasetRecord.valueWayDim += count; |
| 148 | |
| 149 | // ??? TODO give a better default series name rule? |
| 150 | // especially when encode x y specified. |
| 151 | // consider: when multiple series share one dimension |
| 152 | // category axis, series name should better use |
| 153 | // the other dimension name. On the other hand, use |
| 154 | // both dimensions name. |
| 155 | } |
| 156 | // In category way, the first category axis. |
nothing calls this directly
no test coverage detected
searching dependent graphs…