Hydrothermal Hydrothermal - 1 year ago 97
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?

Answer Source


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:


Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download