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

Tooltip is not registered properbly if loaded as plugin

Open CordlessWool opened this issue 1 year ago • 1 comments

Expected behavior

As a plugin I expect, that I could load as a plugin per compnentn and do not have to use Chart.register

Current behavior

Default tooltip is not displayed if registered as plugin. If I add a custom Tooltip it will displayed. The default tooltip is only displayed if I add it with Chart.register

Reproducible sample

https://codesandbox.io/p/devbox/react-chartjs-2-chart-js-issue-template-v4-forked-mdczmz?file=%2Fsrc%2FChart.tsx%3A14%2C31&workspaceId=8c9977f2-c083-4e1b-8fe6-12fa4a16c29b

Optional extra steps/info to reproduce

No response

Possible solution

No response

Context

No response

chart.js version

v4.4.2

Browser name and version

Firefox 123

Link to your project

https://github.com/cotton-coding/loom-ui

CordlessWool avatar Feb 28 '24 23:02 CordlessWool

The tooltip plugin uses an hook that only fires once after the chart has been made to create its own tooltip object. This is why the plugin needs to be registered.

LeeLenaleee avatar May 01 '24 20:05 LeeLenaleee

Closing as per my above comment, inline registration does not work because it needs specific hooks.

If you don't want to tooltip on all charts you can disable it in the options by setting options.plugins,tooltip: false

LeeLenaleee avatar Nov 17 '24 21:11 LeeLenaleee