Hi,
I'm just a beginner in JavaScript and I am using the basic line graphing library for my graph, currently the graph refreshes when I refresh the page, how ever I would like the graph to refresh using a javascript timer, does anyone know how to do this?
this is very important to me, your help would be much appreciated
thanks
Ben
You can use the update() function, documented here, to do this and tie it to a timer function. I don't believe this is the most elegant way to go about it, but it's the clearest way for those who aren't familiar with JavaScript APIs.
Example:
window.setTimeout(timerFunction, 3000); // Generic timer function called after 3 seconds
var myChart = new Chartist.Line(. . .); // The variable you used to create the chart
function timerFunction() {
var newData = {"data1":"value1", "data2":"value2"}; // Make sure this matches the format of your original data
myChart.update(newData);
};
You can also use timers within the Chartist API for more complex functionality such as delayed animations.
Thanks @KinnaT
Most helpful comment
You can use the
update()function, documented here, to do this and tie it to a timer function. I don't believe this is the most elegant way to go about it, but it's the clearest way for those who aren't familiar with JavaScript APIs.Example:
You can also use timers within the Chartist API for more complex functionality such as delayed animations.