Skip to content

Labels are undefined with different zoom levels #438

Description

@kk-adi

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions