0

I'm trying to implement custom hover method. In my case I need to change color not only on hovered bar but also on some previous elements. For example when I hover on 29.04 I need to color this and previous 23.04. Code below not working :( help me please.

hover: {
      onHover: function(event, activeElements: any): void {
        if (activeElements.length) {
          const indexes = [];

          for (let index = activeElements[0]._index; index > 0; index = index - 6) {
            indexes.push(index);
          }

          this.getDatasetMeta(0).data.forEach(function(ele) {
            if (indexes.includes(ele._index)) {
              ele._view.backgroundColor = CONSTANTS.COLORS.HIGHLIGHT;
            }
          });
          this.update();
        }
      },
    }

enter image description here

Sekru
  • 515
  • 2
  • 11
  • Does this answer your question? [How to trigger hover programmatically in chartjs](https://stackoverflow.com/questions/53764367/how-to-trigger-hover-programmatically-in-chartjs) – Giovanni Esposito May 06 '21 at 10:47

1 Answers1

0

I fixed it by changing this.update(); to this.render();

Sekru
  • 515
  • 2
  • 11