We have updated WebDataRocks EULA, effective as of April 18, 2024. Learn more about what's changed.
Documentation menu

getReport

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

NameTypeDescription
optionsObjectContains the following properties:
  • withDefaults
BooleanSpecifies whether default values of an options object should be included in a report (true) of not (false). Default value: false.
  • withGlobals
BooleanSpecifies 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:

<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.

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