Get Free Trial
API reference
Table of contents

amcharts.getData

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

Requests data from the component and preprocesses it to an array of objects. It is the format required by amCharts.

Parameters

  • options – Object. Allows setting options for data preprocessing. Has the following properties:
    • slice optional – Object. Defines the data slice to be used for the chart. If not defined, the Connector prepares the data based on the current slice in Flexmonster Pivot.
      Note: if amcharts.getData() gets the slice as a parameter, the chart will not respond to further slice changes on the grid, which means data shown on the chart will be static.
    • prepareDataFunction optional – Function. Allows you to override the Connector’s default prepareDataFunction and perform custom data preprocessing if needed.
      If prepareDataFunction is not specified, the Connector uses the built-in method to preprocess the data.
      prepareDataFunction takes two input parameters:
      • rawData – Object. Raw data to preprocess (check out the structure of rawData in getData());
      • options – Object.  It contains options set in the amcharts.getData() function.
  • callbackHandler – Function. Used to create the chart once the data is ready to be passed to it. Takes two input parameters:
    • chartData – data preprocessed by either the Connector or prepareDataFunction (if it is defined).
    • rawData – raw data from the component. It can be used to get the number formatting specified in Flexmonster. Check out the structure of rawData.
  • updateHandler optional – Function. Used to update the chart when the report is updated. It takes the same input parameters as the callbackHandler function: chartData and rawData.

Returns

Returns an array of objects that contains the data for the chart. For example:

[
    {
        "categoryName": "value",
        "measureName 1": "value",
         …
        "measureName n": "value",
    }
    …
]

Learn more about how the Connector prepares data for the chart.

Example

Here is an example of passing the slice to the amcharts.getData() method:

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

See also

amcharts.getCategoryName
amcharts.getMeasureNameByIndex
amcharts.getNumberOfMeasures
amcharts.getNumberFormatPattern