Dear all,
I want to display some dialogs like "Loading..." while the data is loaded backend, and after the chart show up, this "Loading..." icon should disappear.
I know I can use sap.m.busyDialog or chart.setBusy() to display the "Loading" icon.
I tried below code but does not work, in the last several lines, I used console.log to trace when attachRequestSent/attachRequestCompleted are triggered, but I could not even see them in F12, seems attachRequestSent/attachRequestCompleted are not even triggered?
Is there anything wrong with my code? Or should I use some other ways to trace when data loading event starts/completes?
createContent : function(oController) {
var oModel = new sap.ui.model.json.JSONModel({
businessData : [
{Country :"Canada",revenue:410.87,profit:-141.25, population:34789000},
{Country :"China",revenue:338.29,profit:133.82, population:1339724852},
{Country :"France",revenue:487.66,profit:348.76, population:65350000},
{Country :"Germany",revenue:470.23,profit:217.29, population:81799600},
{Country :"India",revenue:170.93,profit:117.00, population:1210193422},
{Country :"United States",revenue:905.08,profit:609.16, population:313490000}
]
});
var oDataset = new sap.viz.ui5.data.FlattenedDataset({
dimensions : [{
axis : 1,
name : 'Country',
value : "{Country}"
}],
measures : [
{
name : 'Profit', // 'name' is used as label in the Legend
value : '{profit}' // 'value' defines the binding for the displayed value
},
{
name : 'Revenue',
value : '{revenue}'
}
],
data : {
path : "/businessData"
}
});
var oBarChart = new sap.viz.ui5.Bar({
width : "80%",
height : "400px",
plotArea : {
},
title : {
visible : true,
text : 'Profit and Revenue By Country'
},
dataset : oDataset
});
oBarChart.setModel(oModel);
oModel.attachRequestSent(function(){
oBarChart.setBusy(true);
console.log("attachRequestSent");
});
oModel.attachRequestCompleted(function(){
oBarChart.setBusy(false);
console.log("attachRequestCompleted");
});
return oBarChart;
}
Thanks and best regards,
Tim