Skip to content

feat(axis): add nameOffset applied after nameMoveOverlap resolution - #21840

Open
Faseehshahid246517 wants to merge 1 commit into
apache:masterfrom
Faseehshahid246517:feat/axis-name-offset
Open

Faseehshahid246517 wants to merge 1 commit into
apache:masterfrom
Faseehshahid246517:feat/axis-name-offset

Conversation

@Faseehshahid246517

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 new axis option nameOffset that shifts the axis name by a pixel offset after nameGap and the automatic overlap resolution (nameMoveOverlap) have been applied.

Fixed issues

Details

Before: What was the problem?

With nameMoveOverlap: true, nameGap is applied before overlap resolution. If the requested position still overlaps the axis labels, the axis name is moved automatically, so different nameGap values can end up at the same final position. The overlap boundary depends on label size, font, rotation and data, so developers cannot predict which offset to use. The only workaround, nameMoveOverlap: false, disables automatic collision avoidance entirely.

After: How does it behave after the fixing?

The new nameOffset option is applied as the last step: nameGap -> overlap resolution -> nameOffset.

  • number: signed pixel offset along the outward direction used by overlap resolution (positive = farther from the axis, negative = closer).
  • [dx, dy]: screen-space pixel offset.
  • Default is 0, so existing charts are unchanged.
  • It applies whether nameMoveOverlap is true or false.
yAxis: {
  name: 'Axis title',
  nameLocation: 'middle',
  nameMoveOverlap: true,
  nameGap: 10,
  nameOffset: 15
}

Document Info

One of the following should be checked.

  • 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/axis-name-offset.html (visual cases)
  • test/ut/spec/component/axis/nameOffset.test.ts (unit tests)

Merging options

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

Other information

Docs PR for apache/echarts-doc will follow. I'm happy to adjust the API shape, for example dropping the [dx, dy] form if a smaller first version is preferred.
image_2026-11-13_175615882
image_2026-11-13_175623625
image_2026-11-13_175632442

Copilot AI balanced review requested due to automatic review settings November 13, 2026 12:57
@echarts-bot

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

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

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.

2 participants