How to highlight bar at stacked bar chart on click

hi

its not an issue but implementation question i looked lots in google but didn’t find solution,

how can i change colour or highlight something like happen on hover of bar on click, means when i click to particular label dataset bar it should highlighted or change colour for bar.

in previous version docs i saw there is method getBarAtEvent() which give me bar and we can do with that in latest version i didn’t see that method.

please let me know how can i achieve this.

Thanks

Author: Fantashit

1 thought on “How to highlight bar at stacked bar chart on click

  1. @WalkOffEarth you could set config.data.datasets[0].backgroundColor as an array of colours.

    alternatively you can do

    var element = this.getElementAtEvent(event)[0];
    element.custom = element.custom || {};
    element.custom.backgroundColor = '#000';

    You could need to keep track of the previous index so that you can clear the custom property of the old bar first

Comments are closed.