Chart.js icon indicating copy to clipboard operation
Chart.js copied to clipboard

Live data via APIs?

Open vacquah opened this issue 13 years ago • 40 comments

Would be great to illustrate how the data variable for any chart can be updated from another source vs. hard coding it, as shown in the examples - for example, can I use this with a text file with the values? or even pull data directly from an API source like google analytics? thx

vacquah avatar Mar 18 '13 14:03 vacquah

+1 this would be very useful, as I want to use this on a wallboard which i want to create the chart once, and just refresh the data

webdestroya avatar Mar 18 '13 21:03 webdestroya

Thanks for this, in the coming couple of weeks I'm planning to add some utility methods on the charts that are returned, so after creating a chart and assigning it to a variable, you could call a method on that variable to add new data, or clear the chart etc. Stay tuned!

nnnick avatar Mar 18 '13 21:03 nnnick

What you could do for now is recreate your chart each time you update your data via ajax or sockets or whatever.

nnnick avatar Mar 18 '13 21:03 nnnick

+1

joshhunt avatar Apr 01 '13 05:04 joshhunt

+1

drorm avatar Apr 01 '13 06:04 drorm

+1

billdami avatar Apr 05 '13 13:04 billdami

+1

ialtamirano avatar Apr 05 '13 23:04 ialtamirano

+1

tan-tan-kanarek avatar Apr 11 '13 11:04 tan-tan-kanarek

+1

arathael avatar Apr 16 '13 18:04 arathael

+1

mbuchetics avatar Apr 26 '13 07:04 mbuchetics

+1

marcj avatar May 07 '13 17:05 marcj

+1

katanacrimson avatar May 09 '13 18:05 katanacrimson

+1

pinara747 avatar May 11 '13 09:05 pinara747

@nnnick The simplest solution i've found for now to live update is to use jQuery's replaceWith().

See here for an example: https://gist.github.com/skhisma/5689383

geoff-parsons avatar Jun 01 '13 05:06 geoff-parsons

That would work right now @skhisma

Alternatively, you could do something like this and keep hold of your chart object, then call Doughnut each time you want to load new data in.

var chartConstruct = new Chart(ctx);

chartConstruct.Doughnut(data,options);

//A little later on when you've got some new data...
chartConstruct.Doughnut(newData,options)

Chart.js won't have methods for getting new data - that'll be up to your application, but there will be a better API for this soon.

nnnick avatar Jun 05 '13 22:06 nnnick

will there be an update for this feature soon?

jwerle avatar Jul 01 '13 23:07 jwerle

:+1:

balexandre avatar Jul 02 '13 00:07 balexandre

There will be an update for this. I don't have an ETA just yet, but it'll have a whole load of new fancy stuff!

nnnick avatar Jul 04 '13 17:07 nnnick

awesome! +100

marcj avatar Jul 04 '13 18:07 marcj

any chance this will be done for the challenge post contest?

jwerle avatar Jul 08 '13 17:07 jwerle