Skip to content

Change defaults after render leads to: TypeError: Cannot read properties of undefined (reading 'height') #12196

Open

Description

@davseitsev

Expected behavior

I would expect exception on changing defaults after render or correctly react on new values.

Current behavior

It may be minor but I spent one day debugging it. When you set Chart.defaults.font after render with responsive: true you can get NPE and puzzle over the reasons. It may happen when you do in the React app in different places.

Uncaught TypeError: Cannot read properties of undefined (reading 'height')
    at eval (chart.js:8605:1)
    at Array.forEach (<anonymous>)
    at Legend._draw (chart.js:8587:1)
    at Legend.draw (chart.js:8498:1)
    at Object.draw (chart.js:3130:1)
    at Chart.draw (chart.js:6094:1)
    at Chart.render (chart.js:6070:1)
    at Chart._resize (chart.js:5777:1)
    at Chart.resize (chart.js:5747:1)
    at listener (chart.js:6304:1)
    at eval (chart.js:3397:1)
    at eval (helpers.dataset.js:588:1)
    at r (helpers.js:97:17)

Reproducible sample

https://codepen.io/dimka-747/pen/yyJdrYe

Optional extra steps/info to reproduce

Just open devtools in the codepan and see the exception

Possible solution

No response

Context

No response

chart.js version

v4.5.1

Browser name and version

Version 144.0.7559.135 (Official Build) (arm64)

Link to your project

No response

Activity

  1. changed the title [-]Vertical legend: TypeError: Cannot read properties of undefined (reading 'height')[/-] on Feb 19, 2026
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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions