getData(options: Object, callbackHandler: Function, updateHandler: Function)
[starting from version: 2.3]
Note! This method is only for integration with 3rd party charting libraries.
The getData()
method asynchronously passes the data to the callbackHandler
and updateHandler
functions.
The callbackHandler
tracks when the data is ready to be retrieved from Flexmonster. The updateHandler
tracks if the slice or number formatting was changed.
Read the tutorial to see how getData()
is used for integration with any charting library.
Parameter/Type | Description |
---|---|
options Object | Allows setting options for data preprocessing. |
options.slice SliceObject | optional Specify the slice to get a particular subset of the data. If this property is not specified, getData() will return the data displayed on the grid.Only for "json" and "csv" data source types.Example: pivot.getData({See the full code on JSFiddle. |
callbackHandler Function | Tracks when the data is ready. Data passed to the callbackHandler :
|
updateHandler Function | optional Tracks if the slice or number formatting was changed. Gets two input parameters: rawData and error . Check their structure in callbackHandler. |
Property/Type | Description |
---|---|
String | Chart’s title. |
cAmount Number | The number of fields selected for columns. |
c0Name, c1Name, …, cNName String | Captions of the fields in columns. The number of c0Name , c1Name , … , cNName properties is equal to the number of columns in the slice. |
formats FormatObject[] | Number formats of the measures from the slice. The number of objects in the array is equal to the number of measures in the slice. |
rAmount Number | The number of fields selected for rows. |
r0Name, r1Name, …, rNName String | Captions of the fields in rows. The number of r0Name , r1Name , … , rNName properties is equal to the number of rows in the slice. |
vAmount Number | The number of fields selected for measures. |
v0Name, v1Name, …, vNName String | Captions of the fields selected for measures. The number of v0Name , v1Name , … , vNName properties is equal to the number of measures in the slice. |
Property/Type | Description |
---|---|
dataHeight Number | The number of rows from the report that failed to be retrieved by getData() . |
dataWidth Number | The number of columns that failed to be retrieved by getData() . |
errorMessage String | An error message. Its text description can be changed via the localization file. Default value: "Dataset is too large. Some fields cannot be expanded. Please narrow down the dataset." . |
To understand how the getData()
method works, check out the example on JSFiddle. Find the detailed explanation of this example below.
Let’s assume we have the following pivot table:
Category | |||
Color | Accessories | Components | Total Sum of Price |
blue | 130014 | 130014 | |
green | 9336 | 50 260 | 59 596 |
Grand Total | 9336 | 180 274 | 189 610 |
The getData()
method is called like this:
pivot.getData({},
function(data) {
console.log(data);
},
function(data) {
console.log(data);
}
);
The output looks as follows:
{ meta: { caption: "", vAmount: 1, formats: [ { name: "", thousandsSeparator: " ", decimalSeparator: ".", decimalPlaces: -1, maxDecimalPlaces: -1, maxSymbols: 20, currencySymbol: "", positiveCurrencyFormat: "$1", negativeCurrencyFormat: "-$1", negativeNumberFormat: "-1", nullValue: "", infinityValue: "Infinity", divideByZeroValue: "Infinity", textAlign: "right", isPercent: false, isCount: false, beautifyFloatingPoint: true } ], v0Name: "Sum of Price", r0Name: "Color", c0Name: "Category", rAmount: 1, cAmount: 1 }, data: [ { v0: 189610 }, { r0: "blue", r0_full: "color.[blue]", v0: 130014 }, { r0: "green", r0_full: "color.[green]", v0: 59596 }, { c0: "Accessories", c0_full: "category.[accessories]", v0: 9336 }, { c0: "Components", c0_full: "category.[components]", v0: 180274 }, { r0: "blue", r0_full: "color.[blue]", c0: "Accessories", c0_full: "category.[accessories]", v0: null }, { r0: "blue", r0_full: "color.[blue]", c0: "Components", c0_full: "category.[components]", v0: 130014 }, { r0: "green", r0_full: "color.[green]", c0: "Accessories", c0_full: "category.[accessories]", v0: 9336 }, { r0: "green", r0_full: "color.[green]", c0: "Components", c0_full: "category.[components]", v0: 50260 } ] }
The data
array in the rawData
object contains all numbers shown in the pivot table including grand totals, totals, and regular cells. Depending on a visualization tool you are using, you may need data with totals and grand totals or without them.
Learn more about grand totals, totals, and regular cells below.
Each object representing grand totals contains only values (v0
, v1
, …
, vN
). Our example has one object representing grand totals:
{ v0: 189610 }
Each object representing totals contains either values (v0
, v1
, …
, vN
) and columns (c0
, c1
, …
, cN
) or values and rows (r0
, r1
, …
, rN
). Our example has the following objects representing totals:
{ r0: "blue", r0_full: "color.[blue]", v0: 130014 }, { r0: "green", r0_full: "color.[green]", v0: 59596 }, { c0: "Accessories", c0_full: "category.[accessories]", v0: 9336 }, { c0: "Components", c0_full: "category.[components]", v0: 180274 }
Each object representing regular cells contains values (v0
, v1
, …
, vN
), columns (c0
, c1
, …
, cN
), and rows (r0
, r1
, …
, rN
). Our example has the following objects representing regular cells:
{ r0: "blue", r0_full: "color.[blue]", c0: "Accessories", c0_full: "category.[accessories]", v0: null }, { r0: "blue", r0_full: "color.[blue]", c0: "Components", c0_full: "category.[components]", v0: 130014 }, { r0: "green", r0_full: "color.[green]", c0: "Accessories", c0_full: "category.[accessories]", v0: 9336 }, { r0: "green", r0_full: "color.[green]", c0: "Components", c0_full: "category.[components]", v0: 50260 }
See an example on JSFiddle.
Read the tutorial to see how getData
is used for integration with any charting library.