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.
Name | Type | Description |
---|---|---|
options | Object | Describes the options for data pre-processing. Contains the following properties: |
| 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.
|
| 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).
|
callbackHandler | Function |
Fired once the data is prepared. Accepts two input arguments:
|
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 .
|
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); }
Collapses all nodes and performs the drill-up of all hierarchies in the slice on the grid.
webdatarocks.collapseAllData();
Check out the CodePen example.
expandAllData(withAllChildren: Boolean)
Expands all nodes and performs the drill-down of all hierarchies in the slice on the grid.
Name | Type | Description |
---|---|---|
withAllChildren | Boolean | optional 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 . |
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);
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 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. 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.
getAllHierarchies():Array
Returns a list of all available hierarchies from the report.
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.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.
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 an array of Conditional Format Objects.
Get all the conditional formatting rules from the report:
var conditions = webdatarocks.getAllConditions();
Try on CodePen.
removeSelection()
Clears the selection from the cells on the grid.
webdatarocks.removeSelection();
Try out on CodePen.
getSelectedCell(): Cell Data Object | Array of Cell Data Objects
Returns all the information about the structure of the selected cell.
Cell Data Object that contains information about the selected cell. If multiple cells are selected, the method returns an array of Cell Data Objects.
webdatarocks.getSelectedCell();
Try out on CodePen.