How to change doughnut segment color on click?

Hello!

I need change dougnut segment color on click. I try to use onClick event for this purpose. But settting of new backgroundColor has no effect on chart. I’m not sure, that my way is correct. But I guess, there is no such feature in chart.js.

There is my event handler:

options: {
	onClick: function(evt, elements) {
        if (elements && elements.length) {
			console.log(elements[0]._model.backgroundColor);
			//elements[0]._model.backgroundColor = "#ff9933" - it doesn't work
        	}
	}
}

Here is my plunk for convenience.

Thanks!

Author: Fantashit

1 thought on “How to change doughnut segment color on click?

Comments are closed.