Skip to content

Sometimes it makes chart stop being responsive #439

Open

Description

@vmisq

Reproduction: https://jsfiddle.net/wqc6mgyj/

If the chart is created with resizeDelay, sometimes the extension raises an error that makes the chart not responsive anymore.
When reproducing it in jsfiddle, sometimes it doesn't break, so I've also added the screenshot. (Refreshing and resizing window/fiddle panel might give different results)

Image

Workaround: ...draw:function(t,e){var r,a,o,n,i,l;for(r=0,a=e ? .length;r<a;++r)...

As a workaround I've added ? after the undefined variable and it worked.

Activity

  1. ajuvonen commented on Feb 16, 2026

    @ajuvonen

    Encountered the same issue, using resizeDelay on a chart crashes the plugin. Here's the unminified stack:

    Uncaught (in promise) TypeError: can't access property "length", labels is undefined
        draw chartjs-plugin-datalabels.esm.js:1003
        afterDatasetsDraw chartjs-plugin-datalabels.esm.js:1302
        callback helpers.core.ts:109
        _notify core.plugins.js:65
        notify core.plugins.js:46
        notifyPlugins core.controller.js:1130
        _drawDatasets core.controller.js:775
        draw core.controller.js:724
        render core.controller.js:693
        _resize core.controller.js:299
        resize core.controller.js:271
        attached core.controller.js:1026
        bindResponsiveEvents core.controller.js:1045
        bindEvents core.controller.js:967
        _initialize core.controller.js:246
        Chart core.controller.js:191
        renderChart chart.ts:40
    

    The error comes through this for-loop in the draw function:

    for (i = 0, ilen = labels.length; i < ilen; ++i) {
      label = labels[i];
      state = label.$layout;
    
      if (state._visible) {
        geometry = label.geometry();
        center = coordinates(label._el, label.model(), geometry);
        state._box.update(center, geometry, label.rotation());
        label.draw(chart, center);
      }
    }
    
  2. brian-patrick-kyndryl commented on Feb 20, 2026

    @brian-patrick-kyndryl

    +1, had to remove resizeDelay to resolve

  3. ajuvonen commented on Mar 12, 2026

    @ajuvonen

    A similar problem with resizeDelay has a suggested resolution in another popular chartJS plugin: chartjs/chartjs-plugin-annotation#909. Would something similar also work for this plugin, even if the error location is not the same?

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