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

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

Collapses all nodes and performs the drill-up of all hierarchies in the slice on the grid.

Example

webdatarocks.collapseAllData();

Check out the CodePen example.

See also

expandAllData(withAllChildren: Boolean)

Expands all nodes and performs the drill-down of all hierarchies in the slice on the grid.

Parameters

NameTypeDescription
withAllChildrenBooleanoptional Defines whether to drill down all levels of all hierarchies or not. Set this property to false to expand all nodes and not to drill down hierarchies. Default value is true.

Examples

1) Expand all nodes and drill down all hierarchies in the slice:

webdatarocks.expandAllData();

Check out the CodePen example.

2) Expand all nodes without drilling down the hierarchies in the slice:

webdatarocks.expandAllData(false);

See also

dataloaded: String

The event is triggered once the component loads data.

Example

webdatarocks.on('dataloaded', function(){
alert('Data loaded!');
});

Check out the CodePen example.

celldoubleclick: String

Triggered once a user double clicks the cell on the grid.

Data passed to the handler

cell – Cell Data Object. It contains information about the double-clicked cell.

Example

webdatarocks.on('celldoubleclick', function(cell) {
    alert("Double click on cell - row: " + cell.rowIndex +
        ", column: " + cell.columnIndex +
        ", label: " + cell.label);
});

See in the demo on CodePen.

getAllMeasures():Array

Returns a list of all available measures (both active and inactive) from the report.

Returns

Returns an array of objects. Each object is characterized by the following properties:

  • aggregation – String. The measure’s aggregation name.
  • availableAggregations – Array of strings. An array of available aggregations for the measure.
  • availableAggregationsCaptions – Array of strings. An array of captions of available aggregations.
  • calculated – Boolean. true if the measure is calculated.
  • caption – String. The measure’s caption.
  • folder – String.
  • format – String. The number formatting rule name.
  • formula – String. A formula if a measure is calculated.
  • grandTotalCaption – String. The measure’s grand total caption.
  • individual – Boolean.
  • name – String.
  • originalCaption – String.
  • uniqueName – String. The measure’s unique name.

Example

webdatarocks.getAllMeasures();
/* The method returns an array of objects: 
[
    {
        aggregation: "sum", 
        availableAggregations: 
            ["sum", "count", "distinctcount", "average", "product", 
            "min", "max", "percent", "percentofcolumn", "index", 
            "difference", "%difference", "stdevp", 
            "stdevs", "runningtotals"], 
        availableAggregationsCaptions: 
            ["Sum", "Count", "Distinct Count", "Average", "Product", 
            "Min", "Max", "Percent", "Percent of Column", "Index", 
            "Difference", "% Difference", "Population StDev", 
            "Sample StDev", "Running Totals"], 
        caption: "Sum of Sales", 
        format: "currency", 
        grandTotalCaption: "Total Sum of Sales", 
        name: "Sales", 
        originalCaption: "Sales",
        uniqueName: "Sales"
    },
    {
        aggregation: "none", 
        availableAggregations: [ ], 
        availableAggregationsCaptions: [ ], 
        caption: "Revenue", 
        format: "", 
        formula: "SUM('Price') * SUM('Quantity')", 
        grandTotalCaption: "Total Revenue", 
        name: "Revenue", 
        originalCaption: "Revenue",
        uniqueName: "Revenue"
    }
]
*/

Try on CodePen.

See also

getAllHierarchies():Array

Returns a list of all available hierarchies from the report.

Returns

Returns an array of objects. Each object is characterized by the following properties:

  • caption – String. The hierarchy caption.
  • folder – String.
  • uniqueName – String. The unique hierarchy name.

Example

webdatarocks.getAllHierarchies();

/* The method returns an array of objects: 
[
{caption: "Month", uniqueName: "Month", folder: ""},
{caption: "Region", uniqueName: Region", folder: ""},
{caption: "Country", uniqueName: "Country", folder: ""}
]
*/

Try on CodePen.

See also

getAllConditions():Array

Returns a list of all the rules for conditional formatting of the current report. This API call is most commonly used for editing existing conditional formatting rules.

Returns

Returns an array of Conditional Format Objects.

Example

Get all the conditional formatting rules from the report:

var conditions = webdatarocks.getAllConditions();

Try on CodePen.

See also

removeSelection()

Clears the selection from the cells on the grid.

Example

webdatarocks.removeSelection();

Try out on CodePen.

See also

getSelectedCell(): Cell Data Object | Array of Cell Data Objects

Returns all the information about the structure of the selected cell.

Returns

Cell Data Object that contains information about the selected cell. If multiple cells are selected, the method returns an array of Cell Data Objects.

Example

webdatarocks.getSelectedCell();

Try out on CodePen.

See also