chartjs / chartjs/chartjs-plugin-datalabels
Error: Cannot set properties of undefined (setting '_listened')
- Dominant language
- JavaScript
- Stars
- 920
- Forks
- 507
- PR merge metrics
- No merged PRs in 30d
Description
### 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.

### extra detail
Whole stack trace of error message on console

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

### versions
"chart.js": "^3.6.1",
"chartjs-plugin-datalabels": "^2.0.0",
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.