Chart.js icon indicating copy to clipboard operation
Chart.js copied to clipboard

Tooltip animation can't be disabled

Open JeroenBuenno opened this issue 2 years ago • 3 comments

Expected behavior

When hovering over the chart, the tooltip should show. Drawn metadata should stay, the animation of the tooltip shouldn't be there.

Current behavior

I draw some metadata in the table using the following:

animation: {
  onComplete: ChartHelper.distributionChartDrawMetadata()
},

The metadata disappears while the tooltip is fading in/out. I can disable the animation of the tooltip using:

animation: false

But that also removes the metadata drawing.

Reproducible sample

Optional extra steps/info to reproduce

No response

Possible solution

No response

Context

No response

chart.js version

v3.6.0

Browser name and version

No response

Link to your project

No response

JeroenBuenno avatar Feb 25 '22 10:02 JeroenBuenno

This is working as designed, when you disable the animation there won't be a onAnimationComplete since there is no animation to begin with.

If you want to draw/show custom data on the canvas you can use the plugin system to draw it on the canvas:

https://www.chartjs.org/docs/master/developers/plugins.html

LeeLenaleee avatar Feb 25 '22 10:02 LeeLenaleee

Thanks.

Is there any way to disable the animation (or make animationDuration 0) of tooltips, so the metadata isn't gone for 400ms at a time?

I tried the following, but doesn't seem to do anything:

hover: {
  animationDuration: 0
},

EDIT: And another related question; currently tooltip only shows when hovering over data bars. Can this be extended that also hovering over labels respond to it?

JeroenBuenno avatar Feb 25 '22 10:02 JeroenBuenno

I think a better way to achieve this would be to use a plugin that hooks into the afterDraw call. That way it will be drawn every time the chart draws. https://www.chartjs.org/docs/latest/developers/plugins.html#rendering

etimberg avatar Apr 03 '22 15:04 etimberg