All documentation
  • API Reference for older versions
  • setReport

    setReport(report: ReportObject)

    [starting from version: 1.4]

    Sets a report to be displayed in the component. Use this method to load and show previously saved reports.

    Parameters

    Parameter/TypeDescription
    report
    ReportObject
    Describes the report and contains all its properties.

    Example

    1) Set report:

    <div id="pivotContainer">The component will appear here</div>  
    <script src="flexmonster/flexmonster.js"></script> 
    
    <script> 
    var pivot = new Flexmonster({ 
      container: "pivotContainer",
      componentFolder: "node_modules/flexmonster/",
    }); 
    </script> 
    
    <button onclick="setReport()">Set Report</button> 
    <script> 
    function setReport() { 
      var report = {
        dataSource: {
          filename: "https://cdn.flexmonster.com/data/data.csv"
        } 
      } 
      pivot.setReport(report); 
    } 
    </script> 

    Open the example on JSFiddle.

    2) Swap two reports:

    <div id="firstPivotContainer">The component will appear here</div>  
    <div id="secondPivotContainer">The component will appear here</div>  
    <script src="flexmonster/flexmonster.js"></script> 
    
    <script> 
    var pivot1 = new Flexmonster({ 
      container: "firstPivotContainer", 
      componentFolder: "node_modules/flexmonster/",
      toolbar: true, 
      report: { 
        dataSource: { 
          filename: "data1.csv" 
        } 
      }
    }); 
    var pivot2 = new Flexmonster({ 
      container: "secondPivotContainer", 
      componentFolder: "node_modules/flexmonster/",
      toolbar: true, 
      report: { 
        dataSource: { 
          filename: "data2.csv" 
        } 
      }
    }); 
    </script> 
    
    <button onclick="javascript: swapReports()">Swap Reports</button> 
    <script>   
    function swapReports() { 
      var report1 = pivot1.getReport(); 
      var report2 = pivot2.getReport(); 
            
      pivot1.setReport(report2); 
      pivot2.setReport(report1);   
    } 
    </script> 

    Open on JSFiddle.

    See also

    getReport
    shareReport
    ReportObject
    open
    load
    save
    Save and restore the report