Skip to content

feat(bar): add stackGap for stacked bar segments - #21852

Open
ahuja2666 wants to merge 1 commit into
apache:masterfrom
ahuja2666:fix-21848
Open

ahuja2666 wants to merge 1 commit into
apache:masterfrom
ahuja2666:fix-21848

Conversation

@ahuja2666

Copy link
Copy Markdown

Brief Information

This pull request is in the type of:

  • bug fixing
  • new feature
  • others

What does this PR do?

Adds a pixel-based stackGap option for separating adjacent segments in stacked Cartesian bar series.

Fixed issues

Details

Before: What was the problem?

Stacked bar segments touch. Using borders as dividers can hide thin segments, depend on the chart background, and change the outside edges of the stack.

After: How does it behave after the fixing?

stackGap defaults to 0. For stacked Cartesian bars, each segment is inset by half the configured pixel gap at shared same-sign edges. The layout keeps each segment at least 1px in the value-axis direction (or barMinHeight when larger), preserves the stack's outside edges, and leaves axis data and values unchanged. Use the same stackGap on every series in a stack for a uniform gap.

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.

ZRender Changes

  • This PR depends on ZRender changes (ecomfe/zrender#xxx).

Related test cases or examples to use the new APIs

test/ut/spec/series/bar.test.ts covers vertical and horizontal layout, positive and negative stacks, same-sign boundaries, zero and missing items, thin segments, large mode, and time-axis index stacking. test/bar-stack-gap.html provides a visual comparison with the default layout.

Merging options

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

Other information

Verification passed: all 26 unit test suites (201 tests), TypeScript checks, ESLint, header checks, npm run build:lib, and npm run build.

@echarts-bot echarts-bot Bot added PR: awaiting doc Document changes is required for this PR. PR: awaiting review labels Nov 20, 2026
@echarts-bot

echarts-bot Bot commented Nov 20, 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.

Document changes are required in this PR. Please also make a PR to apache/echarts-doc for document changes and update the issue id in the PR description. When the doc PR is merged, the maintainers will remove the PR: awaiting doc label.

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

Labels

PR: awaiting doc Document changes is required for this PR. PR: awaiting review size/L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] Bar series: stackGap to separate stacked segments without affecting outer edges

1 participant