grofit / knockout.chart

A knockout binding to allow chart.js and knockout to work together for the greater good.
MIT License
25 stars 12 forks source link

Chartjs is fully redrawn on every update instead of just updated #3

Open mika76 opened 7 years ago

mika76 commented 7 years ago

It seems that since the whole data object is updated on the chart object, the chart loses all it's metadata and it redraws the whole chart from scratch. That is why the pie chart on your example always animates from 0 instead of just changing the slices dynamically.

I managed to get around it currently by changing the refreshChart function to the following

var refreshChart = function () {
   var d = ko.toJS(chartBinding.data);
   chartData.data.datasets[0].data = d.datasets[0].data;
   activeChart.update();
   activeChart.resize();
};

but of course this only works in the specific case of one dataset and nothing else changing...

grofit commented 7 years ago

As mentioned in the other ticket currently I am unable to work on this lib, but I accept PRs.