chartjs / chartjs/chartjs-plugin-datalabels

Labels are undefined with different zoom levels

Open
#438 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
920
Forks
507
PR merge metrics
No merged PRs in 30d

Description

After updating chart.js from 4.5.0 to 4.5.1, I face an issue when using the plugin.
The plugin is in the version 2.2.0.

Stacktrace:
```
hook.js:608 React Router caught the following error during render TypeError: Cannot read properties of undefined (reading 'length')
at Object.draw (chartjs-plugin-datalabels.esm.js:1003:31)
at Object.afterDatasetsDraw (chartjs-plugin-datalabels.esm.js:1302:12)
at callback (helpers.core.ts:109:15)
at PluginService._notify (core.plugins.js:65:11)
at PluginService.notify (core.plugins.js:46:25)
at Chart.notifyPlugins (core.controller.js:1130:26)
at Chart._drawDatasets (core.controller.js:775:10)
at Chart.draw (core.controller.js:724:10)
at Chart.render (core.controller.js:693:12)
at Chart._resize (core.controller.js:299:14)
```

After debugging, I pinpointed the issue to `_labels` being undefined (but only in resize with zoom != 100%)

```
afterDatasetsDraw: function(chart) {
layout.draw(chart, chart[EXPANDO_KEY]._labels);
},
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.