Suppose I have an OData list represented in JSON format:
var data = [
{"category" : "A", "value" : 1, "group" : "x"},
{"category" : "B", "value" : 2, "group" : "y"},
{"category" : "C", "value" : 3, "group" : "x"},
{"category" : "A", "value" : 4, "group" : "y"},
{"category" : "A", "value" : 5, "group" : "x"}
];
Initially, a filter is applied to select entries with group == x;
. The resulting values are:
var data = [
{"category" : "A", "value" : 1, "group" : "x"},
{"category" : "C", "value" : 3, "group" : "x"},
{"category" : "A", "value" : 5, "group" : "x"}
];
The next step involves client-side grouping by category and summing up the values, leading to the following result:
var data = [
{"category" : "A", "value" : 6, },
{"category" : "C", "value" : 3, },
];
This grouped data can then be bound to a SAPUI5 control.
If anyone has a generic solution for this grouping issue, please share it.
An example scenario could involve:
var oDataset = new sap.viz.ui5.data.FlattenedDataset({
dimensions : [ {axis : 1, value : "{category}", name : "Category" } ],
measures : [ {value : "{value}", name : "Value" } ],
data : {
path : "/Data"
}
});
var oGraph = new sap.viz.ui5.Donut({
dataset : oDataset, // sap.viz.ui5.data.Dataset
});