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

Method load

packages/sanddance-explorer/src/explorer.tsx:459–542  ·  view source on GitHub ↗
(
            data: DataFile | object[],
            getPartialInsight?: (
                columns: SandDance.types.Column[]
            ) => Partial<SandDance.specs.Insight>,
            optionsOrPrefs?: Prefs | Options,
        )

Source from the content-addressed store, hash-verified

457 }
458
459 public load(
460 data: DataFile | object[],
461 getPartialInsight?: (
462 columns: SandDance.types.Column[]
463 ) => Partial<SandDance.specs.Insight>,
464 optionsOrPrefs?: Prefs | Options,
465 ) {
466 this.setState({ historyIndex: -1, historyItems: [] });
467 this.changeInsight(
468 { columns: null },
469 { label: null, omit: true },
470 { note: null },
471 );
472 return new Promise<void>((resolve, reject) => {
473 const loadFinal = (dataContent: DataContent) => {
474 let partialInsight: Partial<SandDance.specs.Insight>;
475 this.prefs = (optionsOrPrefs && (optionsOrPrefs as Options).chartPrefs || (optionsOrPrefs as Prefs)) || {};
476 if (getPartialInsight) {
477 partialInsight = getPartialInsight(dataContent.columns);
478 initPrefs(this.prefs, partialInsight);
479 }
480 if (!partialInsight) {
481 //load recommendation
482 const r = new RecommenderSummary(dataContent.columns, dataContent.data);
483 partialInsight = r.recommend();
484 }
485 partialInsight = {
486 facetStyle: 'wrap',
487 filter: null,
488 totalStyle: null,
489 transform: null,
490 ...partialInsight,
491 };
492 if (partialInsight.chart === 'barchart') {
493 partialInsight.chart = 'barchartV';
494 }
495 const selectedItemIndex = { ...this.state.selectedItemIndex };
496 const sideTabId = SideTabId.ChartType;
497 selectedItemIndex[DataScopeId.AllData] = 0;
498 selectedItemIndex[DataScopeId.FilteredData] = 0;
499 selectedItemIndex[DataScopeId.SelectedData] = 0;
500 const newState: Partial<State> = {
501 dataFile,
502 dataContent,
503 snapshots: dataContent.snapshots || this.state.snapshots,
504 autoCompleteDistinctValues: {},
505 filteredData: null,
506 tooltipExclusions: (optionsOrPrefs && (optionsOrPrefs as Options).tooltipExclusions) || [],
507 selectedItemIndex,
508 sideTabId,
509 ...partialInsight,
510 };
511 this.getColorContext = null;
512 ensureColumnsExist(newState.columns, dataContent.columns, newState.transform);
513 const errors = ensureColumnsPopulated(partialInsight?.chart, partialInsight?.totalStyle, newState.columns, dataContent.columns);
514 newState.errors = errors;
515 //change insight
516 this.changeInsight(

Callers 7

innerLoadFunction · 0.45
demo.jsFile · 0.45
perf.jsFile · 0.45
sanddance-specs.tsFile · 0.45
loadDataFileFunction · 0.45
treeMapTest.tsFile · 0.45
scatterplotTest.tsFile · 0.45

Calls 3

changeInsightMethod · 0.95
loadDataArrayFunction · 0.90
loadDataFileFunction · 0.90

Tested by

no test coverage detected