Skip to content

test(scale): add regression test for empty bar series changing time axis bounds - #21817

Open
Raman-Katiyar wants to merge 1 commit into
apache:masterfrom
Raman-Katiyar:fix/21148-empty-bar-axis-bounds
Open

Raman-Katiyar wants to merge 1 commit into
apache:masterfrom
Raman-Katiyar:fix/21148-empty-bar-axis-bounds

Conversation

@Raman-Katiyar

Copy link
Copy Markdown

Brief Information

This pull request is in the type of:

  • bug fixing
  • new feature
  • others (regression test)

What does this PR do?

Adds Jest regression tests locking in that an empty bar series does not change explicitly set axis bounds, covering the scenario reported in #21148.

Fixed issues

Details

Before: What was the problem?

On 5.6.0 / 6.0.0, adding an empty bar series ({type: 'bar', data: []}) to a chart whose time xAxis has explicit min/max caused the axis bounds to be expanded (e.g. a configured 2025-01-01 → 2025-01-10 range rendered as roughly 2024-12-22 → 2025-01-20). Root cause on those versions: adjustScaleForOverflow in src/coord/axisHelper.ts adjusted the extent for any bar series on a time base axis, ignoring the fixed min/max and the fact that the bar series had no data.

After: How does it behave after the fixing?

The behaviour is already correct on master (the adjustScaleForOverflow path was removed by the axis extent rework; contain-shape expansion now only affects the mapping extent, and empty series produce no supplement). This PR only adds tests in test/ut/spec/scale/emptyBarAxisExtent.test.ts:

  • time axis with fixed min/max, line series + empty bar series → extent stays exactly [min, max]
  • time axis with fixed min/max, empty bar series only → extent stays exactly [min, max]
  • value axis with fixed min/max, line series + empty bar series → extent stays exactly [min, max]

The first two tests fail on tag 6.0.0 with the reported wrong extent and pass on master.

Document Info

  • This PR doesn't relate to document changes
  • The document should be updated later
  • The document changes have been made in apache/echarts-doc#xxx

Misc

Security Checking

  • This PR uses security-sensitive Web APIs. (not applicable — test only)

ZRender Changes

  • This PR depends on ZRender changes. (no)

Related test cases or examples to use the new APIs

test/ut/spec/scale/emptyBarAxisExtent.test.ts (new). Existing test/ut/spec/scale/interval.test.ts still passes.

Merging options

  • Please squash the commits into a single one when merging.

Other information

No source files and no dist/ files are changed in this PR.

PR checklist (from the repo PR guidance):

  • Issue reproduced and root cause identified (on the reported versions)
  • No fix needed in src/ on master — verified the faulty code path no longer exists
  • Regression test added; fails before (6.0.0) / passes after (master)
  • Relevant existing tests run (interval.test.ts) — pass
  • No dist/, i18n/ or ssr/client/dist/ files included
  • Commit message follows <type>(<scope>): <subject> convention
  • No document changes required
  • No ZRender changes required
  • No security-sensitive APIs used

@echarts-bot

echarts-bot Bot commented Nov 5, 2026

Copy link
Copy Markdown

Thanks for your contribution!
The community will review it ASAP. In the meanwhile, please checkout the coding standard and Wiki about How to make a pull request.

Please DO NOT commit the files in dist, i18n, and ssr/client/dist folders in a non-release pull request. These folders are for release use only.

@Raman-Katiyar
Raman-Katiyar force-pushed the fix/21148-empty-bar-axis-bounds branch from f777329 to a4adf2a Compare November 5, 2026 17:03
@Raman-Katiyar

Copy link
Copy Markdown
Author

I have pushed a small correction to the tests in this PR. The time-axis cases originally used string min/max values ('2025-01-01'), which ECharts parses as local time, so the assertions only held in UTC environments. The tests now use numeric timestamps instead, which makes them deterministic in any timezone — I verified they pass under IST, America/New_York, Asia/Tokyo and UTC, and the full scale spec folder passes (7/7). The behaviour being locked in is unchanged: an empty bar series does not change the explicitly set axis bounds.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant