(ecModel)
| 175 | const dataColorPaletteTask: StageHandler = { |
| 176 | performRawSeries: true, |
| 177 | overallReset(ecModel) { |
| 178 | // Each type of series uses one scope. |
| 179 | // Pie and funnel are using different scopes. |
| 180 | const paletteScopeGroupByType = createHashMap<object>(); |
| 181 | ecModel.eachSeries((seriesModel: SeriesModel) => { |
| 182 | if (!seriesModel.isColorBySeries()) { |
| 183 | const key = seriesModel.type + '-' + seriesModel.getColorBy(); |
| 184 | inner(seriesModel).scope = paletteScopeGroupByType.get(key) |
| 185 | || paletteScopeGroupByType.set(key, {}); |
| 186 | } |
| 187 | }); |
| 188 | |
| 189 | ecModel.eachSeries((seriesModel: SeriesModel) => { |
| 190 | if (seriesModel.isColorBySeries()) { |
| 191 | return; |
| 192 | } |
| 193 | |
| 194 | const dataAll = seriesModel.getRawData(); |
| 195 | const idxMap: Dictionary<number> = {}; |
| 196 | const data = seriesModel.getData(); |
| 197 | const colorScope = inner(seriesModel).scope; |
| 198 | |
| 199 | const stylePath = seriesModel.visualStyleAccessPath || 'itemStyle'; |
| 200 | const colorKey = getDefaultColorKey(seriesModel, stylePath); |
| 201 | |
| 202 | data.each(function (idx) { |
| 203 | const rawIdx = data.getRawIndex(idx); |
| 204 | idxMap[rawIdx] = idx; |
| 205 | }); |
| 206 | |
| 207 | // Iterate on data before filtered. To make sure color from palette can be |
| 208 | // Consistent when toggling legend. |
| 209 | dataAll.each(function (rawIdx) { |
| 210 | const idx = idxMap[rawIdx]; |
| 211 | const fromPalette = data.getItemVisual(idx, 'colorFromPalette'); |
| 212 | // Get color from palette for each data only when the color is inherited from series color, which is |
| 213 | // also picked from color palette. So following situation is not in the case: |
| 214 | // 1. series.itemStyle.color is set |
| 215 | // 2. color is encoded by visualMap |
| 216 | if (fromPalette) { |
| 217 | const itemStyle = data.ensureUniqueItemVisual(idx, 'style'); |
| 218 | const name = dataAll.getName(rawIdx) || (rawIdx + ''); |
| 219 | const dataCount = dataAll.count(); |
| 220 | itemStyle[colorKey] = seriesModel.getColorFromPalette(name, colorScope, dataCount); |
| 221 | } |
| 222 | }); |
| 223 | }); |
| 224 | } |
| 225 | }; |
| 226 | |
| 227 | export { |
nothing calls this directly
no test coverage detected