Skip to content
Bug reportNov 28, 2026· 0:31· 17 views

Chart.js: legend.maxHeight is ignored when position is 'left' or 'right'

0:31 total

Comments · 0

Be the first to comment.

Bug reportby SceneRecap AI

mediumLegend plugin layout (fit/height calculation for vertical positions 'left'/'right'): maxHeight is not used to clamp the legend height when the legend is laid out in columns.
os: macOSdpr: 1locale: en-USbrowser: Chromium 151.0.7922.34library: Chart.js 4.6.2 (cdn.jsdelivr.net chart.umd.min.js)timezone: Europe/Berlinviewport: 1280x720page_title: Chart.js legend maxHeight bug, chartjs/Chart.js#11805

Repro steps

  1. 1.Load Chart.js 4.6.2 from cdn.jsdelivr.net in a page.
  2. 2.Create a line chart with 12 datasets (Series 1 to Series 12) and plugins: { legend: { position: 'top', maxHeight: 60 } } as a control.
  3. 3.Create a second line chart with the same 12 datasets and plugins: { legend: { position: 'left', maxHeight: 60 } }.
  4. 4.Compare the rendered legend heights of both charts.

Expected

With legend.maxHeight: 60, the legend should be limited to 60px tall for any position, including 'left'. Entries beyond that height should be clipped, as happens with position 'top'.

Actual

With position 'left', maxHeight: 60 has no effect. All 12 legend entries (Series 1 to Series 12) render in a tall column, about 240px tall. With position 'top', the same maxHeight clips the legend as expected.

Evidence

visualControl: the chart titled "position: 'top' + maxHeight: 60" shows Series 1 to 10 in full. The row with Series 11 and 12 is cut off, so maxHeight is applied. This case works correctly.
visualBug: the chart titled "position: 'left' + maxHeight: 60" lists all 12 entries, Series 1 to Series 12, in a column far taller than 60px.
visualNeither chart changes between 1s and 19s. The 'left' legend stays unclipped.
visualA summary overlay reads "position: 'top' → legend clips", "position: 'left' → maxHeight ignored" and "all 12 series visible despite maxHeight:60".
consoleA parser-blocking cross-site script warning appears for chart.umd.min.js loaded via document.write. This is a loading warning and is likely unrelated to the bug.
Issue markdown (copy-paste ready)
## Summary
In Chart.js 4.6.2, `legend.maxHeight` is ignored when `legend.position` is `'left'`. The same option works with `position: 'top'`.

## Environment
- Chart.js 4.6.2 (cdn.jsdelivr.net `chart.umd.min.js`)
- Chromium 151.0.7922.34, macOS
- Viewport 1280x720, DPR 1

## Steps to reproduce
1. Load Chart.js 4.6.2.
2. Create a line chart with 12 datasets and `plugins: { legend: { position: 'top', maxHeight: 60 } }` as a control.
3. Create a second line chart with the same data and `plugins: { legend: { position: 'left', maxHeight: 60 } }`.
4. Compare the legend heights.

## Expected
The legend is limited to 60px tall for both positions. Entries past that height are clipped.

## Actual
- **Control (`'top'`), works:** Series 1 to 10 show in full and the Series 11/12 row is clipped (0:01).
- **Bug (`'left'`):** all 12 entries, Series 1 to Series 12, render in a column about 240px tall. `maxHeight: 60` has no effect (0:01 to 0:29).

## Evidence
- 0:01: side by side charts show the clipped top legend and the unclipped left legend.
- 0:21: the summary overlay reads "all 12 series visible despite maxHeight:60".
- 0:00: the console shows a parser-blocking `document.write` script warning for chart.umd.min.js. It is likely unrelated.

## Suggested area
Legend plugin layout for vertical positions (`'left'` / `'right'`). The computed legend height does not appear to be clamped by `maxHeight`.

Related: chartjs/Chart.js#11805

*Recorded with SceneRecap.*

This report was written by SceneRecap from a screen recording. Try SceneRecap free

Turn a screen recording into a bug report like this one.

Repro steps, expected vs actual and the console and network evidence, each with a timestamp. On every plan, Free included.

Try SceneRecap free →