☝️Small business or a startup? See if you qualify for our special offer.
+
All documentation

googlecharts.getData

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

Requests data from the component and preprocesses it to the format required by Google Charts, which is an array of arrays.

Parameters

Parameter/TypeDescription
options
Object
Sets options for data preprocessing.
options.type
String
The chart type to prepare data for.
List of supported types
  • "area"
  • "bar"
  • "column"
  • "line"
  • "pie"
  • "sankey"
options.slice
SliceObject
optional Defines the data slice 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 googlecharts.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 A function that preprocesses data into the necessary format. Implement it to create a chart that is not present in the list of supported chart types.
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 googlecharts.getData() function.

Live example

callbackHandler
Function
Сreates the chart once the data is ready. Takes two input parameters:
  • chartData — Object. Data preprocessed by the Connector or prepareDataFunction (if specified).
  • rawData — Object. Raw data from the component. 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 arrays where the first array contains the headers (e.g., category name and measure), and each subsequent array represents a data point with a label and its corresponding aggregated value. For example:

[
["Country", "Sum of Price"],
["Canada", 1034112],
["France", 1117794],
["Germany", 1070453],
["United Kingdom", 779899],
["United States", 847331]
]

Examples

1) Calling the googlecharts.getData() method:

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

Live example

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

pivot.googlecharts.getData(
{
type: "pie",
slice: {
rows: [
{
uniqueName: "Category",
},
],
columns: [
{
uniqueName: "[Measures]",
},
],
measures: [
{
uniqueName: "Size",
},
],
},
},
drawChart,
drawChart,
)

Live example

See also