Skip to main content
Version: v11.6.0

Charts - Custom Data


Custom Data Manipulation: Instead of using the existing columns to be plotted on the x- and y-axis (see here to know how), you can plot custom data as an aggregation or sum of the columns. For example, from the Department table of the sample hrdb, we want to plot the chart with average of all four quarters data (Q1, Q2, Q3, and Q4)

  1. Drag and drop chart widget, bind the Dataset Value property to the Database CRUD Variable (say, HrdbDepartmentData) with source as hrdb, and type as Department
  2. Enter the following script in the above-mentioned variable onSuccess event. This script will calculate the average of budget value and set it to the chart data set.
App.HrdbDepartmentDataonSuccess = function(variable, data) {
var aggregatedData = [];

for (var i = 0; i < data.length; i++) {
var deptObj = data[i],
avgBudget = (deptObj.q1 + deptObj.q2 + deptObj.q3 + deptObj.q4) / 4;

//Constructing aggregated data of all quarters
aggregatedData[i] = {
'name': deptObj.name,
'quaterBudget': avgBudget
};
}
//Update the variable that is bound to chart
App.Variables.ChartData.dataSet = aggregatedData;
};

See Also 

Chart Widget Cases
How to capture user selection
How to handling dynamic data