getReport(options:Object): Report Object

This method returns a current Report Object from a pivot table component. Use it to save or edit a report.

Parameters

Name Type
Description
options Object
Contains the following properties:
  • withDefaults

 

Boolean
Specifies whether default values of an options object should be included in a report (true) of not (false). Default value: false.
  • withGlobals

 

Boolean
Specifies whether values of an options object defined in a global object should be included in a report (true) or not (false). Default value: false.

Examples

  1. Get a report:

    var pivot = new WebDataRocks({
        container: "#wdr-component",
        toolbar: true,
        height: 490,
        report: "https://cdn.webdatarocks.com/reports/report.json"
    });
    function getReport() {
        console.log(pivot.getReport());
    }

    See the CodePen demo.

  2. Swap two reports:

  3. <div id="wdr-component1"></div>
    <div id="wdr-component2"></div>
    <script>
        var pivot1 = new WebDataRocks({
            container: "#wdr-component1",
            toolbar: true,
            height: 490,
            report: {
                "dataSource": {
                    "dataSourceType": "csv",
                    "filename": "https://cdn.webdatarocks.com/data/data.csv"
                },
                "slice": {
                    "rows": [{
                        "uniqueName": "Category"
                    }],
                    "columns": [{
                            "uniqueName": "Measures"
                        },
                        {
                            "uniqueName": "Country"
                        }
                    ],
                    "measures": [{
                        "uniqueName": "Price",
                        "aggregation": "sum"
                    }]
                }
            }
        });
        var pivot2 = new WebDataRocks({
            container: "#wdr-component2",
            toolbar: true,
            height: 390,
            report: "https://cdn.webdatarocks.com/reports/report.json"
        });
        function swapReports() {
            var report1 = pivot1.getReport();
            var report2 = pivot2.getReport();
            pivot1.setReport(report2);
            pivot2.setReport(report1);
        }
    </script>

    See the CodePen demo.

    1. Get report with defaults or globals: see the CodePen demo.