Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
106
rated 0 times [  107] [ 1]  / answers: 1 / hits: 39850  / 14 Years ago, sat, september 25, 2010, 12:00:00

I would like to build a web-based real time data graph and i'm looking at the different options such as:




  • Html5 canvas

  • JS libraries with graph support such
    as Extjs



By real time i mean, either the client polling the web server say every second or using reverse ajax; the server pushes data to the client when available.



Can you please recommend any?


More From » html

 Answers
16

You may want to consider using Flot, an open-source plotting library based on jQuery.



I'm assuming that by real-time you mean that the graph will update automatically. The following is how your code would look like if you were to fetch and plot the data using AJAX polling at 1 second intervals:



function fetchData() {
$.ajax({
url: 'json_fetch_new_data.php',
method: 'GET',
dataType: 'json',
success: function(series) {
var data = [ series ];

$.plot($('#placeholder'), data, options);
}
});

setTimeout(fetchData, 1000);
}


Make sure to check out the following demo to see it in action (Click on the Poll for Data button):





For further information on Flot:




[#95504] Thursday, September 23, 2010, 14 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
cruz

Total Points: 415
Total Questions: 98
Total Answers: 109

Location: France
Member since Thu, May 6, 2021
3 Years ago
;