user1869421
user1869421

Reputation: 837

Google Charts and real time updates

I'm thinking of using the google charts api, in particular column charts and scatter plots. I want to know that can these charts be updated constantly by data it receives from the server via a websocket.

My understanding is that this data will first be added to a data table and then plotted onto a chart. So if data is being updated in the table will this update the chart in 'real time'.

Another question is I'll also have an instance when the columns cannot be defined straight away but again will be updated by the received data; again can google charts handle this.

Thanks

Upvotes: 5

Views: 11072

Answers (2)

Arye P.
Arye P.

Reputation: 198

if you have

var data = new google.visualization.DataTable();
var chart = new google.visualization.LineChart(document.getElementById('chart_div'));

you can do

data.addRows([2015,10])
chart.draw(data);

and it updates the chart

I made a button that adds data in this JSfiddle:

https://jsfiddle.net/kdn2ojxb/3/

Upvotes: 1

Alfred
Alfred

Reputation: 61773

I do not know about google charts, but recently I discovered Smoothie Charts. It can do real-time(smooth). The only problem is that I does only work in Chrome, Firefox according to this Introducing Smoothie Charts post.

Or maybe highCharts. A real-time example at jsfiddle.

Upvotes: 3

Related Questions