I started computing calculated field in Odata.read()' success callback using for loop as suggested by Dan.
_getCalculatedField : function(){..} onAfterRendering : function() { // from controller // accessing ""plan"" model from component.js) var oComponent = this.getOwnerComponent(); var oDataModel = oComponent.getModel("plan"); // create JSON model for chart sap.ui.getCore().AppContext.myModelForVizChart = new sap.ui.model.json.JSONModel({}, 'myModelForVizChart'); var that = this; oDataModel.read("/Path", { sorters: [new sap.ui.model.Sorter("Createstamp", false, false)], urlParameters:{"$select" : "field1,field2,field3"}, // reduce payload async: true, context: null, success: function(oData, oResponse){ // success callback var inputArray = oData.results // compute calculated fields for(i=0; i < inputArray.length; i++){ inputArray[i].calculatedField = that._getCalculatedField(inputArray[i]); } // save JSON in AppContext sap.ui.getCore().AppContext.myModelForVizChart.setData({ "dataWithCalculatedField": inputArray }); } ); var oVizFrame = this.getView().byId("myVizChart"); oVizFrame.setModel(sap.ui.getCore().AppContext.myModelForVizChart); }
I'm not sure what be the best way to group data by calculated field?