ChartJS datalabels rotation is not reflecting until hover

106 Views Asked by At

I have radial chart where I have put datalabels at various angles using rotation function. These changes to labels are not reflected until mouse hover.

What do I need to do to reflect rotation changes with manually hovering my mouse on the chart ?

Test case:

Add following rotation function to any chart. Problem can be seen at: https://chartjs-plugin-datalabels.netlify.app/samples/charts/doughnut.html

        rotation: function( ctx ) { 
          var today = new Date();
          var angle = 6 * today.getSeconds();
          console.log(angle);
          return angle;
        },

Here to demonstrate the problem, I am changing labels with time. In my case I rotate labels when a a legend is clicked to hide or show. Show/hide legend item calls rotation function and udpates angles, but doesn't show on the graph until hover. Rotated labels need to update as the arc size change with legend item show/hide.

I have gone through documents. various examples, traversing through chart object and web searches. Everyone has a one time rotation applied.

0

There are 0 best solutions below