runQuery(query:Query Object)

This method is invoked on a pivot table instance. It takes a Query Object as an argument and runs it. The Query Object contains a slice with rows, columns, measures, and reportFilters.

Use it to:

  • reorganize the hierarchies on the grid
  • compose a new report that is based on the current data

Parameters

Name Type Description
query Query Object Contains rows, columns, measures, and reportFilters from a Slice Object.

Example

Suppose you have a pivot table with the following report:

var pivot = new WebDataRocks({
    container: "wdr-component",
    toolbar: true,
    report: {
        "dataSource": {
            "filename": "https://cdn.webdatarocks.com/data/data.csv"
        },
        "slice": {
            "rows": [{
                "uniqueName": "Category"
            }],
            "columns": [{
                    "uniqueName": "Measures"
                },
                {
                    "uniqueName": "Country"
                }
            ],
            "measures": [{
                "uniqueName": "Price",
                "aggregation": "sum"
            }]
        }
    }
});

If you want to rearrange the hierarchies in a slice programmatically, write the following code:

var slice = {
    "rows": [{
        "uniqueName": "Country"
    }],
    "columns": [{
        "uniqueName": "Category"
    }],
    "measures": [{
        "uniqueName": "Price",
        "aggregation": "sum"
    }]
};
webdatarocks.runQuery(slice);

View the details in the CodePen demo.

More information