Skip to content
Bug reportNov 23, 2026· 0:35· 16 views

ECharts 5.6.0: setOption throws TypeError when enabling showBackground and changing categories simultaneously

0:35 total

Comments · 0

Be the first to comment.

Bug reportby SceneRecap AI

mediumBar series rendering (BarView) background-rect path when showBackground is enabled on update while the category axis data or data length changes in the same setOption. A layout or background shape appears to be undefined when its width is read.
os: macOSdpr: 1page: ECharts #21862 reproduction (local page)locale: en-USbrowser: Chromiumlibrary: ECharts 5.6.0 (jsDelivr CDN, echarts.min.js)viewport: 1280x720

Repro steps

  1. 1.Load the reproduction page with ECharts 5.6.0 from the jsDelivr CDN.
  2. 2.Look at the left control chart. It is a fresh chart created with showBackground:true and categories Dates, Bananas, Figs.
  3. 3.Look at the right chart. An existing bar chart is updated with myChart.setOption({ showBackground: true, data: top3categories }). This enables showBackground and reduces categories in the same call.
  4. 4.Check the bars and background tracks on the right chart, and check the error shown below it.

Expected

After setOption, the right chart renders like the control. It shows 3 bars, one under each of the Dates, Bananas and Figs labels, and each bar has a grey background track. No error is thrown.

Actual

setOption throws TypeError: Cannot read properties of undefined (reading 'width'). The right chart renders bars at about 75, 88 and 61 over the Bananas and Figs area. No bar sits under Dates and no bars have background tracks. The state does not change for the rest of the recording.

Evidence

visualControl case works. The left chart 'Control: fresh chart with showBackground:true' shows 3 bars (Dates, Bananas, Figs), each with a grey background track. The status reads 'Renders correctly, 3 bars each have a grey background track'.
visualThe right chart shows the red error box 'TypeError: Cannot read properties of undefined (reading 'width')' under the code line 'myChart.setOption({ showBackground: true, data: top3categories })'.
visualThe Dates category on the right chart has no bar. Three bars (about 75, 88, 61) are packed over the Bananas and Figs categories and none have background tracks.
visualThe cursor hovers over the error text and the setOption call. The error is still present.
visualBoth charts are unchanged at the end of the recording. The control is still correct and the bug chart is still misrendered with the TypeError.
consoleThere are only two console warnings, both at load: the parser-blocking cross-site script echarts.min.js is invoked via document.write. These are unrelated to the bug. The TypeError is not in the captured console log. It is only visible in the page's error box.
Issue markdown (copy-paste ready)
## Summary
In ECharts 5.6.0, one `setOption` call that both enables `showBackground: true` and reduces the category data throws `TypeError: Cannot read properties of undefined (reading 'width')`. After the error, the chart renders misaligned bars with no background tracks.

## Environment
- ECharts 5.6.0 (jsDelivr CDN, `echarts.min.js`)
- Chromium on macOS, viewport 1280x720, dpr 1, locale en-US

## Steps to reproduce
1. Create a bar chart with a category axis and data, with `showBackground` not set.
2. Call `myChart.setOption({ showBackground: true, data: top3categories })`. This enables the background and reduces categories in the same call.

## Expected
The chart shows 3 bars, one under each of Dates, Bananas and Figs, each with a grey background track. No error is thrown. This matches a fresh chart created with `showBackground: true` (control).

## Actual
- The error box shows `TypeError: Cannot read properties of undefined (reading 'width')` (visible at 1s).
- The Dates category has no bar. Three bars (about 75, 88, 61) are packed over Bananas and Figs (11s).
- No background tracks are drawn.
- The state persists through the end of the recording (31s).

## Control (works)
A fresh chart initialized with `showBackground: true` and the same 3 categories renders correctly. It shows 3 bars, each with a grey background track (1s).

## Notes
The console only shows two unrelated warnings at load about `document.write` injecting the CDN script. The TypeError was shown in the page's error box.

## Suggested area
Bar series rendering for background rects when `showBackground` is turned on during an update that also changes category count.

*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 →
ECharts 5.6.0: setOption throws TypeError when enabling showBackground and changing categories simultaneously · SceneRecap