[Chartjs]-Chart.js – make barchart element blink

3👍

As far as I understand, you want to have a blinking bar.

So what you can do is create the bar and then dynamically update its background-color from ‘transparent’ to the original color periodically using a timer.

This will create a blinking effect.

Ok, so if you want the first bar to blink:

let count = 0;
setInterval(() => {
  if(count % 2 === 0) {
      myChart.data.datasets[0].backgroundColor[0] = 'transparent';
      myChart.update();
  }
  else {
    myChart.data.datasets[0].backgroundColor[0] = '#FFC857';
    myChart.update();
  }
  count++;
}, 2000);

I don’t know if there is a better solution for it, but this is the first thing that came to my mind.

Leave a comment