You must be logged in to post your query.
Home › Forums › Chart Support › redraw chart
Tagged: redrawing dynamic charts
hi, i need the function in canvasjs to redraw a dynamic chart with multiple data-series. thank you.
@umustaphax,
While creating a dynamic chart, to redraw a chart, you will just have to change/add the dataPoints to the dataPoints array and then call chart.render() again.
Please take a look at the code snippet below,
var xVal = dps.length + 1; var yVal = 100; var updateInterval = 1000; var updateChart = function () { yVal = yVal + Math.round(5 + Math.random() *(-5-5)); dps.push({x: xVal,y: yVal,}); xVal++; chart.render(); }; setInterval(function(){updateChart()}, updateInterval);
Please refer to this documentation page for a step-by-step tutorial on how to create a dynamic chart.
I cant make it work with the doughnut chart at all. Take a look at my tests: https://cabanapps.com.br/valores-vale/TESTS/
It only changes the colors of the graphics, not the values. What I am doing is setting: chartTwitter.options.data[0].dataPoints = [my new dataPoints] and calling chartTwitter.render();
If I do like in the example: https://canvasjs.com/docs/charts/how-to/creating-dynamic-charts/ Just updating the dataPoints variable array, nothing happens.
Any help?
Besides that, I couldnt manage to creat charts runtime, instead of using “onLoad”. It looks like that the way it search for the canvas context get messes up if you dont use onload. Do you have any workable example that dont use “onload” event to create the chart?
Oops, forget about the redraw part. Just got it to work. But can I animate the redrawing process, as if it was being created for the first time?
As of now animation is supported only for Pie Charts – during first render. For other charts it isn’t available yet.
You must be logged in to reply to this topic. Login/Register