ECharts 5.6.0: setOption throws TypeError when enabling showBackground and changing categories simultaneously
Comments · 0
Be the first to comment.
Bug reportby SceneRecap AI
Repro steps
- 1.Load the reproduction page with ECharts 5.6.0 from the jsDelivr CDN.
- 2.Look at the left control chart. It is a fresh chart created with showBackground:true and categories Dates, Bananas, Figs.
- 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.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
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 →