MCPcopy
hub / github.com/microsoft/SandDance / _render

Method _render

packages/sanddance/src/viewer.ts:485–545  ·  view source on GitHub ↗
(insight: Insight, data: object[], options: RenderOptions, forceNewCharacterSet: boolean)

Source from the content-addressed store, hash-verified

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();

Callers 1

renderMethod · 0.95

Calls 15

transformDataMethod · 0.95
renderNewLayoutMethod · 0.95
preStageMethod · 0.95
changeColorContextsMethod · 0.95
getViewMethod · 0.95
getSpecColumnsFunction · 0.90
assignOrdinalsFunction · 0.90
colorMapFromCubesFunction · 0.90
applyColorMapToCubesFunction · 0.90
getSelectedColorMapFunction · 0.90

Tested by

no test coverage detected