This is a migrated thread and some comments may be shown as answers.

Realtime data from server

2 Answers 207 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Peter
Top achievements
Rank 1
Peter asked on 31 Aug 2018, 05:00 PM

Hi,

I found the dojo for realtime draw https://www.telerik.com/forums/redraw-in-real-time.

What is the best way to implement this for measurement data in 100-ms-steps from a server with database?

At first call, the read method for the DataSourceRequest  in the Controller class can send the newest datapoints of the last minute (600 datapoints).
The next calls from the timeout event should only send the newer values.
That is no problem to realize it in the C# controller classs.

In a normal chart the data are overwritten. How can I append this values?

Possible by using of the datasource events push or requestEnd? Is there an example available?

Peter

 

2 Answers, 1 is accepted

Sort by
0
Accepted
Tsvetina
Telerik team
answered on 05 Sep 2018, 11:41 AM
Hello Peter,

You would need to manually handle the data accumulation on the client, as the DataSource behavior is to overwrite the old data with the new items returned by the server. It cannot add up the data itself.
What you can do it use a jQuery $.ajax request to get the latest data items and append them to an array on the client. Then, set this array to the Chart DataSource. Something like this:
var chartData = [];
 
var dataIndex = 0;
setInterval(function () {
    $.ajax({
        url: "/Financial/_BoeingStockData",
        type: "GET",
        success: function (response) {
            var chart = $("#chart").data("kendoChart");
            chartData = chartData.concat(response);
            chart.dataSource.data(chartData);
        }
    });
}, 1000);

However, it sounds as if the number of data points on the client would reach thousands in a few minutes, which could result in a page crash if the page in question stays open longer. Do you plan on limiting the total number of data items that will be stored on the client?

Regards,
Tsvetina
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Peter
Top achievements
Rank 1
answered on 10 Sep 2018, 07:52 AM

Hello Tsvetina,
thank you. I will use the jQuery $.ajax request. Of course I will insert chartData.splice() to limit the array size.

Regards,
Peter

Tags
Chart
Asked by
Peter
Top achievements
Rank 1
Answers by
Tsvetina
Telerik team
Peter
Top achievements
Rank 1
Share this question
or