getData

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

This method is for integration with third-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

NameTypeDescription
optionsObjectOptions for data pre-processing. This object has the following parameters:
  • slice
Objectoptional Defines the slice of data for pre-processing. If the slice is not defined, the API call sends the data displayed in the pivot table.
callbackHandlerFunctionSpecifies what happens after the data is ready. It has one input parameter – rawData (non-aggregated data for sending to the chart).
updateHandlerFunctionoptional 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:

NameTypeDescription
dataArrayArray 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 is put the appropriate v0 - vN field.
metaObjectMetadata for the data API call returns:
  • cAmount
NumberColumns’ quantity in the slice object.
  • c0Name
StringThe title of the columns’ first field in the slice object. The quantity of c0Name, c1Name, c2Name, … , cnName is equal to cAmount of the meta object.
  • formats
ArrayArray of format objects for measures in the slice object. The quantity of format objects is equal to vAmount.
  • rAmount
NumberThe quantity of fields in rows in the slice object.
  • r0Name
StringThe title of the rows’ first field in the slice object. The number of r0Name, r1Name, r2Name, … , rnName is equal to rAmount of the meta object.
  • vAmount
NumberThe measures’ quantity in the slice object.
  • v0Name
StringThe 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:

Here we show an example of data

Then the output of the API call

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

is the following one:

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