question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can not cancel draw of tooltip using beforeTooltipDraw

See original GitHub issue

Expected behavior

When any plugin returns false from beforeTooltipDraw, then the tooltip is canceled and not drawn. This is the stated behavior in the docs.

Example: https://codepen.io/granthynd/pen/GRxBgPr

Current behavior

Returning false from beforeTooltipDraw does not seem to cancel anything. The Tooltip is still drawn.

Reproducible sample

https://codepen.io/granthynd/pen/GRxBgPr

Optional extra steps/info to reproduce

Just hover over a tooltip and you will see the console logs of each step.

Possible solution

No response

Context

I am trying to write a small custom plugin to draw a crosshair line on the chart, but the tooltip drawing seems to interfere with that, so I would like to cancel the drawing of the tooltip so I can manually update it myself.

chart.js version

v3.9.1

Browser name and version

Chrome 103

Link to your project

No response

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
GrantHyndcommented, Aug 9, 2022

Hopefully, it is that simple 🙏 I actually have not contributed to open source before, let me take a whack at creating a PR for it.

1reaction
stockiNailcommented, Aug 10, 2022

It’s not breaking but it’s an enhancement so I would say 4.0

@LeeLenaleee I’m not 100% sure that’s an enhancement because it’s not working as designed, I guess. Nevertheless it could be a bug to fix in version 4.0 even because there is a workaround, setting cancelable to true inside the hook implementation.

Read more comments on GitHub >

github_iconTop Results From Across the Web

beforeTooltipDraw does not cancel draw - CodePen
The owner of this Pen needs to verify their email address to enable Full Page View. Their name is Grant. Feel free to...
Read more >
Interface: ExtendedPlugin - Chart.js
Called before drawing the tooltip . If any plugin returns false , the tooltip drawing is cancelled until another render is triggered. #...
Read more >
Moving vertical line when hovering over the chart using chart ...
This question is two years old. Nowadays, we can achieve this using plugins and hook calls in this case beforeTooltipDraw to capture the ......
Read more >
Flickering with tracking ownerdraw ToolTip - MSDN - Microsoft
However, when the tooltip is drawn, the dummy text passed as argument to ToolTip.Show() is displayed just before ToolTip.Draw is called (as ...
Read more >
ChartControl - @pnp/spfx-controls-react
To find sample code that you can use, visit the Chart. ... Note that this hook will not be called if the tooltip...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found