☝️Small business or a startup? See if you qualify for our special offer.
+
All documentation
  • API Reference for older versions
  • amcharts.getData

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

    Requests data from Flexmonster and preprocesses it to the format required by amCharts, which is an array of objects.

    Parameters

    Parameter/TypeDescription
    options
    Object
    Sets options for data preprocessing.
    options.slice
    SliceObject
    optional Defines the slice to be used for the chart Live example.
    If options.slice is not specified, 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.
    Only for "json" and "csv" data source types.
    options.prepareDataFunction
    Function
    optional Implement this function to preprocess data for the chart into the necessary format manually.
    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).
    • options — Object. It contains options set in the amcharts.getData() function.
    callbackHandler
    Function
    Сreates the chart once the data is ready. Takes two input parameters:
    • chartData — Object. Data preprocessed by either the Connector or prepareDataFunction (if it is defined).
    • rawData — Object. Raw data from the component. It can be used to get the number formatting specified in Flexmonster. Check out the structure of rawData.
    updateHandler
    Function
    optional Updates the chart when the report is changed. It takes the same input parameters as the callbackHandler function: chartData and rawData.

    Returns

    An array of objects with the data for the chart. Each object contains one category field and all measures from the slice. For example:

    [
    {
    Country: "Australia",
    Sum of Price: 1349952
    },
    {
    Country: "Canada",
    Sum of Price: 745412
    }
    ]

    Examples

    1) Calling the amcharts.getData() method:

    pivot.amcharts.getData({}, drawChart, updateChart);

    Live example

    2) Defining the options.slice parameter in amcharts.getData():

    pivot.amcharts.getData(
    {
    slice: {
    rows: [
    {
    uniqueName: "Color",
    },
    ],
    measures: [
    {
    uniqueName: "Quantity",
    },
    ],
    },
    },
    drawChart,
    updateChart,
    )

    Live example

    See also