From 2f2014aa164e252daaee2749e5c3568954c27c39 Mon Sep 17 00:00:00 2001 From: RomanTsukanov Date: Tue, 9 Apr 2024 11:36:37 +0400 Subject: [PATCH] Describe `onStateChanged` (#423) --- src/visualizationPanel.ts | 1 + src/visualizerBase.ts | 23 +++++++++++++++++++++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/visualizationPanel.ts b/src/visualizationPanel.ts index 05a662d5f..27b505d3e 100644 --- a/src/visualizationPanel.ts +++ b/src/visualizationPanel.ts @@ -988,6 +988,7 @@ export class VisualizationPanel extends VisualizerBase { /** * The state of `VisualizationPanel`. Includes information about the visualized elements and current locale. + * @see onStateChanged */ public get state(): IState { return this.getState(); diff --git a/src/visualizerBase.ts b/src/visualizerBase.ts index abf8a0250..42b3a119d 100644 --- a/src/visualizerBase.ts +++ b/src/visualizerBase.ts @@ -93,6 +93,23 @@ export class VisualizerBase implements IDataInfo { // VisualizationPanel, // any // >(); + /** + * An event that is raised when the visualizer's state has changed. + * + * The state includes selected chart types, chart layout, sorting, filtering, and other customizations that a user has made while using the dashboard. Handle the `onStateChanged` event to save these customizations, for example, in `localStorage` and restore them when the user reloads the page. + * + * Parameters: + * + * - `sender`: `VisualizerBase`\ + * A `VisualizerBase` instance that raised the event. + * + * - `state`: `any`\ + * A new state of the visualizer. Includes information about the visualized elements and current locale. + * + * [View Demo](/dashboard/examples/save-dashboard-state-to-local-storage/ (linkStyle)) + * @see getState + * @see setState + */ public onStateChanged: Event< (sender: VisualizerBase, options: any) => any, VisualizerBase, @@ -640,8 +657,9 @@ export class VisualizerBase implements IDataInfo { /** * Returns an object with properties that describe a current visualizer state. The properties are different for each individual visualizer. * - * > This method is overriden in descendant classes. + * > This method is overriden in classes descendant from `VisualizerBase`. * @see setState + * @see onStateChanged */ public getState(): any { return {}; @@ -649,8 +667,9 @@ export class VisualizerBase implements IDataInfo { /** * Sets the visualizer's state. * - * > This method is overriden in descendant classes. + * > This method is overriden in classes descendant from `VisualizerBase`. * @see getState + * @see onStateChanged */ public setState(state: any): void { }