0

I am using Syncfusion pivot View, Here I have a requirement of saving Multiple charts on button click and loading charts on button click. I am able to save and load data using getPersistData() and loadPersistData(). But I want to save toolbar selections as well like if the user has selected Bar for Chart 1 and Line for Chart 2 then on loading these charts again on button click Chart 1 should load as Bar chart and Chart 2 will load as Line chart. any configuration which user has done using toolbar like if the user has selected grid or 1 pivot view and charts for 2nd pivot view on loading them again I want to load as per their previous selections.

1 Answers1

1

We have analyzed your requirement and prepared a pivot sample using toolbar feature to save and load pivot report with the current view (table or chart) and chart type. Kindly refer to the following sample and code example.

Sample: https://stackblitz.com/edit/angular-fsd4c1?file=app.component.ts

Code Example:

loadReport(args: any) {
    let reportCollection: string[] = [];
    if (localStorage.pivotviewReports && localStorage.pivotviewReports !== "") {
        reportCollection = JSON.parse(localStorage.pivotviewReports);
    }
    reportCollection.map(function (item: any): void {
        if (args.reportName === item.reportName) {
            args.report = item.report;
        }
    });
    if (args.report) {
        var report = JSON.parse(args.report);
        this.pivotObj.chartSettings.chartSeries.type = report.chartSettings.chartSeries.type;
        this.pivotObj.displayOption = report.displayOption;
        this.pivotObj.currentView = report.displayOption.primary === 'Chart' ? 'Chart' : 'Table';
        this.pivotObj.dataSourceSettings = report.dataSourceSettings;
    }
}
Dharman
  • 30,962
  • 25
  • 85
  • 135
Mani
  • 11
  • 1