Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update label.js #380

Closed
wants to merge 2 commits into from
Closed

Update label.js #380

wants to merge 2 commits into from

Conversation

kqikz
Copy link

@kqikz kqikz commented Apr 27, 2023

instanceof not working anymore in chart.js 4.0.1, switched to class name isntead

instanceof not working anymore in chart.js 4.0.1, switched to class name isntead
@MasterCash
Copy link

This seems to fix an issue where for pie charts we are attempting to use a point system not the radian one. throws an error about x not being defined.

Would it be possible to move this in?

constructor.name is getting overriden by webpack, safer to use this way
@tedik123
Copy link

I am having this same issue on the main branch, is there an official fix?

chartjs-plugin-datalabels.esm.js:118 Uncaught TypeError: Cannot read properties of null (reading 'x')
    at orient (chartjs-plugin-datalabels.esm.js:118:19)
    at Object.fallback [as positioner] (chartjs-plugin-datalabels.esm.js:342:13)
    at coordinates (chartjs-plugin-datalabels.esm.js:838:21)
    at Object.draw (chartjs-plugin-datalabels.esm.js:1009:18)
    at Object.afterDatasetsDraw (chartjs-plugin-datalabels.esm.js:1302:12)
    at callback (helpers.core.ts:109:15)
    at PluginService._notify (core.plugins.js:60:11)
    at PluginService.notify (core.plugins.js:42:25)
    at Chart.notifyPlugins (core.controller.js:1148:26)
    at Chart._drawDatasets (core.controller.js:787:10)

@simonbrunel
Copy link
Member

Unfortunately, the suggested fix is not acceptable because el instanceof ArcElement behaves differently than el.constructor.id == "arc" (same for all other tests). First case tests if el inherits from ArcElement (directly or indirectly) while in the second case, el must be of class ArcElement.

However, I believe the issue should be solved inside your project so the plugin depends on the exact same Chart.js package used to create the chart (i.e, ArcElement used in this check is the same object as ArcElement used by the chart). Having different ArcElement classes in your project does not seem correct.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants