(dataLayout: DataLayoutChange, filter?: Search)
| 200 | } |
| 201 | |
| 202 | private async onDataChanged(dataLayout: DataLayoutChange, filter?: Search) { |
| 203 | switch (dataLayout) { |
| 204 | case DataLayoutChange.same: { |
| 205 | this.renderSameLayout(); |
| 206 | break; |
| 207 | } |
| 208 | case DataLayoutChange.refine: { |
| 209 | //save cube colors |
| 210 | const oldColorContext = this.colorContexts[this.currentColorContext]; |
| 211 | let colorMap: ColorMap; |
| 212 | await this.renderNewLayout({}, { |
| 213 | preStage: (stage: VegaDeckGl.types.Stage, deckProps: VegaDeckGl.DeckProps) => { |
| 214 | //save off the spec colors |
| 215 | colorMap = colorMapFromCubes(stage.cubeData); |
| 216 | applyColorMapToCubes([oldColorContext.colorMap], VegaDeckGl.util.getCubes(deckProps)); |
| 217 | this.preStage(stage, deckProps); |
| 218 | }, |
| 219 | onPresent: () => { |
| 220 | //save new legend |
| 221 | const newColorContext: ColorContext = { |
| 222 | colorMap, |
| 223 | legend: VegaDeckGl.util.clone(this.presenter.stage.legend), |
| 224 | legendElement: this.presenter.getElement(VegaDeckGl.PresenterElement.legend).children[0] as HTMLElement, |
| 225 | }; |
| 226 | //apply old legend |
| 227 | this.applyLegendColorContext(oldColorContext); |
| 228 | this.changeColorContexts([oldColorContext, newColorContext]); |
| 229 | }, |
| 230 | }); |
| 231 | |
| 232 | //narrow the filter only if it is different |
| 233 | if (!searchExpression.compare(this.insight.filter, filter)) { |
| 234 | this.insight.filter = searchExpression.narrow(this.insight.filter, filter); |
| 235 | } |
| 236 | if (this.options.onDataFilter) { |
| 237 | this.options.onDataFilter(this.insight.filter, this._dataScope.currentData()); |
| 238 | } |
| 239 | break; |
| 240 | } |
| 241 | case DataLayoutChange.reset: { |
| 242 | const colorContext: ColorContext = { |
| 243 | colorMap: null, |
| 244 | legend: null, |
| 245 | legendElement: null, |
| 246 | }; |
| 247 | this.changeColorContexts([colorContext]); |
| 248 | await this.renderNewLayout({}, { |
| 249 | onPresent: () => { |
| 250 | populateColorContext(colorContext, this.presenter); |
| 251 | }, |
| 252 | }); |
| 253 | |
| 254 | delete this.insight.filter; |
| 255 | if (this.options.onDataFilter) { |
| 256 | this.options.onDataFilter(null, null); |
| 257 | } |
| 258 | break; |
| 259 | } |
no test coverage detected