question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error: Cannot set properties of undefined (setting '_listened')

See original GitHub issue

Definition

I have an application created with next.js which I am making client-side routing. I am using chartjs with datalabels on one page and I am getting a Cannot set properties of undefined (setting '_listened') error while making the page transition. It is not always happening. I couldn’t find the exact case and I can not reproduce it with certain steps. But When I tried to make lots of concurrent page transition click sometimes it happens. So it is an unpredictable error that I am facing while demoing the application.

Can You please look into the details and provide some solution? Thanks

Implementation Details:

I have one dashboard page which has one doughnut chart. Also, I have different charts on some detailed reports. On the dashboard, I don’t want to see the data labels but on reports, I want to have them. The plugin is

I am registering Datalabel Plugin globally like below:

import { ArcElement, Chart, Legend } from 'chart.js';
import ChartDataLabels from 'chartjs-plugin-datalabels';

Chart.register(ArcElement, Legend, ChartDataLabels);

I am disabling the datalabels plugin when it is not desired according to user selection with the below option settings. And Datalabels is disabled on the page, I am getting this error.

image

extra detail

Whole stack trace of error message on console image

I have followed up error line it it is showing the line in redbox

image

versions

"chart.js": "^3.6.1",
"chartjs-plugin-datalabels": "^2.0.0",

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:1
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
fstrazzantecommented, May 30, 2022

I got the same error. In my case I registered the plugin globally but needed only in one chart. I switch from registered globally to the exact chart and now I don’t have the error anymore.

The conf of the chart that is using this plugin is something like this (I’m using plain JS) : { type: 'pie', data: {.....}, plugins: [ChartDataLabels], options: {...} }

0reactions
kurklecommented, Aug 3, 2022

Is it safe to simply replace beforeInit by install without introducing breaking change?

That is the idea. I’m not aware of any plugin doing that in a minor version thought, so I don’t have any proof.

Read more comments on GitHub >

github_iconTop Results From Across the Web

JavaScript - cannot set property of undefined - Stack Overflow
I get the following error: Uncaught TypeError: Cannot set property 'greeting' of undefined. I'm trying to do something similar to an associative ...
Read more >
How to solve the 'cannot set property of undefined' issue on ...
To access an object key the object has to exist. When it doesn't and you try to access the key, you get the...
Read more >
cannot set properties of undefined (setting 'height') - You.com
Button doesn't have a 'href' property hence you get an internal javascript error. But later on, as you're also using dash-bootstrap-templates library, when...
Read more >
Cannot set properties of undefined (setting ... - WordPress.org
[This thread is closed.] after search and show result, when do search agian. clcking on result not working and showing following error in...
Read more >
Metamask Error Cannot set properties of undefined (setting ...
Both of them are tokens and I want the user to exchange tokens with the previous token to the new tokens. So, I...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found