From c2fe8e59d6d1f7a0f95de3a34bab9c765af875ad Mon Sep 17 00:00:00 2001 From: Mangesh Raut <95149253+mangeshraut712@users.noreply.github.com> Date: Sun, 29 Nov 2026 15:46:56 +0530 Subject: [PATCH] Allow embed callers to clear snapshots when loading a dataset --- packages/sanddance-embed/README.md | 2 ++ packages/sanddance-explorer/src/explorer.tsx | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/sanddance-embed/README.md b/packages/sanddance-embed/README.md index 81147601f..4820eaaaf 100644 --- a/packages/sanddance-embed/README.md +++ b/packages/sanddance-embed/README.md @@ -79,6 +79,8 @@ Use `postMessage` to communicate with `embedIframe.contentWindow`. For all comma The `data` variable can be an array, or a [DataFile object](https://microsoft.github.io/SandDance/docs/sanddance-explorer/v4/interfaces/DataFile.html). + To discard snapshots from the previous dataset, pass `options: { resetSnapshots: true }` in the load message. Snapshots supplied by the incoming data file take precedence. + Notable optional parameters: * The `props` member, of type [Explorer Props](https://microsoft.github.io/SandDance/docs/sanddance-explorer/v4/interfaces/Props.html), here is shown used to specify the dark color theme, initially close the sidebar, and use the advanced renderer: diff --git a/packages/sanddance-explorer/src/explorer.tsx b/packages/sanddance-explorer/src/explorer.tsx index 8a5ff478b..908712a28 100644 --- a/packages/sanddance-explorer/src/explorer.tsx +++ b/packages/sanddance-explorer/src/explorer.tsx @@ -63,6 +63,8 @@ import Snapshot = SandDance.types.Snapshot; import { setInsightBackgroundImage } from './dialogs/backgroundImageEditor'; export interface Options { + /** Clear previous snapshots when loading data without its own snapshots. */ + resetSnapshots?: boolean; chartPrefs?: Prefs; tooltipExclusions?: string[]; setup?: SandDance.types.Setup; @@ -492,12 +494,14 @@ function _Explorer(_props: Props) { const selectedItemIndex = { ...this.state.selectedItemIndex }; const sideTabId = SideTabId.ChartType; resetSelectedItemIndex(selectedItemIndex); + const resetSnapshots = (optionsOrPrefs as Options)?.resetSnapshots; const newState: Partial = { camera: undefined, columns: {}, dataFile, dataContent, - snapshots: dataContent.snapshots || this.state.snapshots, + snapshots: dataContent.snapshots || (resetSnapshots ? [] : this.state.snapshots), + selectedSnapshotIndex: resetSnapshots || dataContent.snapshots ? -1 : this.state.selectedSnapshotIndex, autoCompleteDistinctValues: {}, filteredData: null, tooltipExclusions: (optionsOrPrefs && (optionsOrPrefs as Options).tooltipExclusions) || [],