chartjs / Chart.js

Simple HTML5 Charts using the <canvas> tag
https://www.chartjs.org/
MIT License
63.92k stars 11.89k forks source link

Tooltip is not registered properbly if loaded as plugin #11691

Open CordlessWool opened 4 months ago

CordlessWool commented 4 months ago

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

LeeLenaleee commented 2 months ago

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.