fusioncharts.getData
fusioncharts.getData(options: Object, callbackHandler: Function, updateHandler: Function)
This method is used for integration with FusionCharts.
It gets the data from the pivot table and pre-processes it to the appropriate format for the required chart’s type.
To use this method, add the webdatarocks.fusioncharts.js
library to your application. It serves as a connector between WebDataRocks Pivot Table and FusionCharts and handles the data processing.
You can find the full list of the chart’s types supported by WebDataRocks in the Integration with FusionCharts tutorial.
Parameters
Name | Type | Description |
---|---|---|
options | Object | Describes options for data pre-processing. It has the following parameters: |
| String |
optional Specifies a chart’s type to prepare the data for. The default value is "line" .
|
| Object | optional Specifies the slice of data that needs to be pre-processed for the specified chart. If not set, the method sends the data that is currently displayed in the pivot table. |
| Function | optional An external function. Use it if webdatarocks.fusioncharts.js does not support the specified chart’s type or you need to pre-process the data in a custom way. This function takes raw (non-aggregated) data from the table as rawData parameter and an object with options defined in fusioncharts.getData() as options parameter. Find more details about rawData ‘s structure in the documentation |
callbackHandler | Function |
Specifies what happens when the data is ready. It has the following
parameters:
data – data that is ready to be used in the chart and rawData (optionally) – the raw data that is passed in case you need to get access rawData.meta properties, e.g., for defining number formatting.
|
updateHandler | Function |
optional Triggered when the data in the pivot table is
updated, sorted or filtered. It has the following parameters: data and rawData .
|
Number formatting for charts
WebDataRocks Connector for FusionCharts provides an API call fusioncharts.getNumberFormat(format:Object)
– Object. This method takes a format object of a pivot table as an input parameter and returns a format object for number formatting in FusionCharts. It can be used in prepareDataFunction
when you need to set the pivot table’s number formatting to the chart.
The response object has the following properties:
- decimalSeparator
- decimals
- forceDecimals
- numberPrefix
- thousandsSeparator
Example
fusioncharts.getNumberFormat()
can be used in prepareDataFunction
as follows:
var format = pivot.fusioncharts.getNumberFormat(data.meta.formats[0]);
for (var prop in format) {
output.chart[prop] = format[prop];
}