Git Product home page Git Product logo

Comments (6)

kurkle avatar kurkle commented on May 22, 2024 1

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);

from chartjs-chart-treemap.

kurkle avatar kurkle commented on May 22, 2024 1

And the explanation is here, if Tooltip is not registered before TreemapController, the tooltip positioner is not registered.

TreemapController.afterRegister = function() {
const tooltipPlugin = registry.plugins.get('tooltip');
if (tooltipPlugin) {
tooltipPlugin.positioners.treemap = function(active) {
if (!active.length) {
return false;
}
const item = active[active.length - 1];
const el = item.element;
return el.tooltipPosition();
};
}
};

Should probably emit a warning about this.

from chartjs-chart-treemap.

kurkle avatar kurkle commented on May 22, 2024

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);

from chartjs-chart-treemap.

kurkle avatar kurkle commented on May 22, 2024

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).

from chartjs-chart-treemap.

koin612 avatar koin612 commented on May 22, 2024

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.

from chartjs-chart-treemap.

koin612 avatar koin612 commented on May 22, 2024

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.

from chartjs-chart-treemap.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.