Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 9164

Re: SAPUI5 - Live Update of a chart ?

$
0
0

Hi John,

 

first of all thanks for your quick reply

 

It did not work ;( Here is our code, maybe you can have a look on it, would be great.

 

This is the code in our view.js:

 

...

var model = oController.loadChart();

linechart.setModel(model);   

 

function updateChart() {

 

 

     var lineChart = sap.ui.getCore().byId("linechart"); 

     // this.byId did not work , i got an error that this method is unknown

     var oModel = lineChart.getModel();

     var oData = oModel.getData();

        

     var updatemodel = oController.update(); 

     // the method update() calls a method in an xsjs file that return the data

     // as a JSON model, i can see the data in my developer console

     var updatedata = updatemodel.getData(); 

     // here i try to get the new data like you described it above

        

     oData["modelData"] =  updatedata;

     oModel.setData(oData);

 

     //jQuery.sap.delayedCall(5000, this, updateChart);

 

}

 

var interval = setInterval(updateLineChart, 5000);

 

...


This is the code in our controller.js for the update method:


...


update: function() {

    

var model = new sap.ui.model.json.JSONModel();

var aUrl = '../../../dev/data_HANAXS/services/readdata.xsjs?cmd=loadChart;

jQuery.ajax({

     url: aUrl,

     method: 'GET',

     dataType: 'json',

     success: function(updatedata) {

            

     model.setData({modelData : updatedata});

 

     }

});

            

return model;

    

}


...


Strange thing is that we receive no errors in the developer console in mozilla firefox. But when trying to update the data after 5 seconds the chart disappears and it is displayed "No data".


Would be great if you could give us a hint what the problem could be.

It would also be very helpful if other people who have the same issues would write and share their experiences as this is in my opinion a very important topic to be able to live update your charts without having to reload the whole chart again and again. Otherwise you have to use d3 ...


Thanks in advance & regards,

Andreas



Viewing all articles
Browse latest Browse all 9164

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>