(insight: Insight, data: object[], options: RenderOptions, forceNewCharacterSet: boolean)
| 483 | } |
| 484 | |
| 485 | private async _render(insight: Insight, data: object[], options: RenderOptions, forceNewCharacterSet: boolean) { |
| 486 | if (this._tooltip) { |
| 487 | this._tooltip.finalize(); |
| 488 | this._tooltip = null; |
| 489 | } |
| 490 | if (this._dataScope.setData(data, options.columns)) { |
| 491 | //apply transform to the data |
| 492 | this.transformData(data, insight.transform); |
| 493 | } |
| 494 | this._specColumns = getSpecColumns(insight, this._dataScope.getColumns(options.columnTypes)); |
| 495 | const ordinalMap = assignOrdinals(this._specColumns, data, options.ordinalMap); |
| 496 | |
| 497 | this._characterSet.resetCharacterSet(forceNewCharacterSet, this.insight, insight); |
| 498 | |
| 499 | this.insight = VegaDeckGl.util.clone(insight); |
| 500 | this._lastColorOptions = VegaDeckGl.util.clone(this.options.colors); |
| 501 | this._shouldSaveColorContext = () => !options.initialColorContext; |
| 502 | const colorContext = options.initialColorContext || { |
| 503 | colorMap: null, |
| 504 | legend: null, |
| 505 | legendElement: null, |
| 506 | }; |
| 507 | const specResult = await this.renderNewLayout( |
| 508 | insight.signalValues, |
| 509 | { |
| 510 | preStage: (stage: VegaDeckGl.types.Stage, deckProps: VegaDeckGl.DeckProps) => { |
| 511 | if (this._shouldSaveColorContext()) { |
| 512 | //save off the colors from Vega layout |
| 513 | colorContext.colorMap = colorMapFromCubes(stage.cubeData); |
| 514 | } else { |
| 515 | //apply passed colorContext |
| 516 | applyColorMapToCubes([colorContext.colorMap], VegaDeckGl.util.getCubes(deckProps)); |
| 517 | } |
| 518 | //if items are selected, repaint |
| 519 | const hasSelectedData = !!this._dataScope.hasSelectedData(); |
| 520 | const hasActive = !!this._dataScope.active; |
| 521 | if (this._dataScope.hasSelectedData() || this._dataScope.active) { |
| 522 | const selectedColorMap = getSelectedColorMap(this._dataScope.currentData(), hasSelectedData, hasActive, this.options); |
| 523 | applyColorMapToCubes([colorContext.colorMap, selectedColorMap], stage.cubeData, this.options.colors.unselectedColorMethod); |
| 524 | } |
| 525 | this.preStage(stage, deckProps); |
| 526 | }, |
| 527 | onPresent: () => { |
| 528 | if (this._shouldSaveColorContext()) { |
| 529 | populateColorContext(colorContext, this.presenter); |
| 530 | this.changeColorContexts([colorContext]); |
| 531 | } else { |
| 532 | //apply passed colorContext |
| 533 | this.applyLegendColorContext(colorContext); |
| 534 | } |
| 535 | }, |
| 536 | shouldViewstateTransition: () => this.shouldViewstateTransition(insight, this.insight), |
| 537 | }, |
| 538 | this.getView(insight.view), |
| 539 | ); |
| 540 | //future signal changes should save the color context |
| 541 | this._shouldSaveColorContext = () => !options.discardColorContextUpdates || !options.discardColorContextUpdates(); |
| 542 | this._details.render(); |
no test coverage detected