Closed koin612 closed 2 years ago
Maybe you could try importing and registering Tooltip
?
Edit: just to make it clear, the top part:
import { Vue, Component, Ref } from "vue-property-decorator";
import { Chart, Tooltip } from "chart.js";
import { TreemapController, TreemapElement } from "chartjs-chart-treemap";
Chart.register(Tooltip, TreemapController, TreemapElement);
Also, if a the "Basic treemap example" text is rendered on the chart, I suspect this might be an issue with SSR. You could try disabling that for this component (don't as me how, I don't use Vue).
ty for your help. It's client side rendered but the tooltip (I've tried already) import seems like it's working now. I've already imported in main.ts
the registerables like:
import { Chart, registerables } from "chart.js";
import { TreemapController, TreemapElement } from "chartjs-chart-treemap";
Chart.register(TreemapController, TreemapElement, ...registerables);
which I think should import Tooltip and don't treeshake. Specifying it explicitly again/twice seems to work from my tests.
I've usually created a file for doing the registration like:
chart.js
import { Chart, registerables } from "chart.js";
import { TreemapController, TreemapElement } from "chartjs-chart-treemap";
Chart.register(...registerables, TreemapController, TreemapElement);
export default Chart;
component.js
import Chart from './chart';
...
But the actual fix is probably registering the ...registrables before TreemapController:
Chart.register(...registerables, TreemapController, TreemapElement);
And the explanation is here, if Tooltip is not registered before TreemapController, the tooltip positioner is not registered.
Should probably emit a warning about this.
thank you kurkle for analyzing the problem, really appreciate this. I can confirm if I do Chart.register(...registerables, TreemapController, TreemapElement)
it works as intended. Kinda makes sense, but I did not expect an order in the register at first glance. Seeing the controller it makes sense.
I'm using
chart.js 3.7.1
andchartjs-chart-treemap 2.0.2
in an vue project. The chart renders but when I hover it does not show the tooltip and fires errors in console. Sometimes it worked when the live-server reloaded code and when I've did the imports inmain.ts
and in the component itself.the component looks like this