Skip to content

Commit

Permalink
Describe onStateChanged (#423)
Browse files Browse the repository at this point in the history
  • Loading branch information
RomanTsukanov authored Apr 9, 2024
1 parent 577c97a commit 2f2014a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/visualizationPanel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
23 changes: 21 additions & 2 deletions src/visualizerBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -640,17 +657,19 @@ 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 {};
}
/**
* 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 {
}
Expand Down

0 comments on commit 2f2014a

Please sign in to comment.