Hydrothermal Hydrothermal - 4 months ago 29
Javascript Question

Detecting hover events over parts of a chart using Chart.js

I've made a pie chart using Chart.js, and I'd like to detect when a segment is hovered over. I've found plenty of documentation regarding manipulating the tooltips that appear when hovering over segments, but nothing regarding doing something else when a tooltip would appear. Is this possible?



There's nothing in the ChartJS API to override or extend the tooltip,

But, a workaround...

You can modify the draw method of the Chart.Tooltip class. This would allow you to "do something else" when the tooltip would normally be rendered by ChartJS.

The draw method you want to tie into starts at line 1351 of the source here: