getData(options:Object, callbackHandler:Function, updateHandler:Function)

This method is for integration with 3rd party charting libraries. It is used for requesting the data from the pivot table, pre-processing it to the appropriate format for the required type of the chart in the charting library and passing the data to callbackHandler and updateHandler.

Parameters

    Name Type Description
    options Object Options for data pre-processing. This object has the following parameters:
  • slice
  • Object optional Define the slice of data for pre-processing. If it is not defined, the API call will send the data displayed in the pivot table.
    callbackHandler Function This function specifies what happens after the data is ready. It has one input parameter – rawData (non-aggregated data for sending to the chart).
    updateHandler Function optional It is triggered when the data in the pivot table is updated, sorted or filtered. It has one input parameter – rawData.

Response

rawData is an object returned by getData() API call and then asynchronously passed to callbackHandler and updateHandler. It consists of the following fields:

    Name Type Description
    data Array Array of objects describing the data from the dataset. Each object can have c0 - cN , r0 - rN and v0 - vN fields, where c0 - cN are for column members, r0 - rN are for row members and v0 - vN are for values. If a cell has no value, NaN will be put the appropriate v0 - vN field.
    meta Object Metadata for the data API call returns:
  • cAmount
  • Number Columns’ quantity in the slice object.
  • c0Name
  • String The title of the columns’ first field in the slice object. The quantity of c0Name, c1Name, c2Name, … , cnName will be equal to cAmount of the meta object.
  • formats
  • Array Array of format objects for measures in the slice object. The quantity of format objects is equal to vAmount.
  • rAmount
  • Number The quantity of fields in rows in the slice object.
  • r0Name
  • String The title of the rows’ first field in the slice object. The number of r0Name, r1Name, r2Name, … , rnName will be equal to rAmount of the meta object.
  • vAmount
  • Number The measures’ quantity in the slice object.
  • v0Name
  • String The title of the first measure in the slice object. The number of v0Name, v1Name, v2Name, … , vnName is equal to vAmount of the meta object.

Example

Assume that you have the pivot table with the following content:

Then the output of the API call

webdatarocks.getData({}, function(data) {console.log(data)})

will be the following:

{
    data: [{
            v0: 131295
        },
        {
            r0: "France",
            v0: 76900

        },
        {
            r0: "Germany",
            v0: 54395
        },
        {
            c0: "Bikes",
            v0: 131295
        },
        {
            c0: "Bikes",
            r0: "France",
            v0: 76900
        },
        {
            c0: "Bikes",
            r0: "Germany",
            v0: 54395
        }
    ],
    meta: {
        cAmount: 1,
        c0Name: "Category",
        formats: [{
            currencySymbol: "$",
            currencySymbolAlign: "left",
            decimalPlaces: 2,
            decimalSeparator: ".",
            divideByZeroValue: "Infinity",
            infinityValue: "Infinity",
            isCount: false,
            isPercent: false,
            maxDecimalPlaces: -1,
            maxSymbols: 20,
            name: "currency",
            nullValue: "",
            textAlign: "right",
            thousandsSeparator: ","
        }],
        r0Name: "Country",
        rAmount: 1,
        v0Name: "Sum of Price",
        vAmount: 1:

    }
}

This data array in rawData object contains all the data from the pivot table’s slice. It includes grand totals, totals, and subtotals as well.

Objects with grand totals contain only (v0 - vN) values. In our example you can see such an object with grand totals:

{
    v0: 131295
}

Similarly, objects with totals contain either values (v0 - vN) and columns (c0 - cN ) or values (v0 - vN) and rows ( r0 - rN). The following set of objects corresponds to the example described before:

{
    r0: "France",
    v0: 76900
}, {
    r0: "Germany",
    v0: 54395
}, {
    c0: "Bikes",
    v0: 131295
}

Various charting libraries may have different requirements for data pre-processing before sending it from the pivot table to the charts. The data can be with grand totals, totals and subtotals or without them.