We have updated WebDataRocks EULA, effective as of April 18, 2024. Learn more about what's changed.
Documentation menu

amcharts.getData

webdatarocks.amcharts.getData(options: Object, callbackHandler: Function, updateHandler: Function): Array

[starting from version: 1.3.1]

This method plays the most important role in communication between a pivot table component and a chart. It gets the data from the pivot table and pre-processes according to a format required by amCharts, namely to an array of objects.

Parameters

Name Type Description
options Object Describes the options for data pre-processing. Contains the following properties:
  • slice
Slice Object optionalSpecifies the pivot table’s slice according to which to prepare the chart’s data. If not defined, the Connector prepares the data that is currently displayed on the grid. Note that if a slice is passed to amcharts.getData() explicitly, the chart will not be changed upon changes applied to the grid (via the UI or in code). The data shown in the chart will be static. See the example.
  • prepareDataFunction
Function optionalThis function can be implemented and passed as a property of options if the data is required to be prepared differently from the way the Connector does by default. After the data is processed by prepareDataFunction, it is passed to callbackHandler and updateHandler (the description of these event handlers is given below).

prepareDataFunction accepts two input arguments:

  • rawData – the raw data from the pivot table. Find information about the structure of rawData here.
  • options – an object with options passed to amcharts.getData().
callbackHandler Function Fired once the data is prepared. Accepts two input arguments:
  • chartData – the data processed either by the Connector or prepareDataFunction (if defined).
  • rawData – the raw data from the pivot table. It can be used for defining number formatting for a chart. It is possible to access rawData.meta properties (e.g., available format objects). Find information about the structure of rawData and its meta properties here.
updateHandler Function optional Fired once any change is applied to the report’s configuration (e.g., the pivot table’s slice or number formatting are changed). Alike callbackHandler, accepts two input arguments: chartData and rawData.

Examples

1)Here is an example of how to pass the slice to the amcharts.getData() method:

function createChart() {
     pivot.amcharts.getData({
         slice: {
             rows: [{uniqueName: "Country"}],
             columns: [{uniqueName: "Measures"}],
             measures: [{uniqueName: "Quantity"}]
         }
     },
 drawChart, updateChart);
} 

See also