Skip to content

fix(axis): refactor axisLabel formatter#21432

Merged
plainheart merged 1 commit into
masterfrom
fix-axisTickLabel
Dec 18, 2025
Merged

fix(axis): refactor axisLabel formatter#21432
plainheart merged 1 commit into
masterfrom
fix-axisTickLabel

Conversation

@Ovilia
Copy link
Copy Markdown
Contributor

@Ovilia Ovilia commented Dec 18, 2025

https://github.com/apache/echarts/pull/21220/changes#r2622525473

Brief Information

This pull request is in the type of:

  • bug fixing
  • new feature
  • others

What does this PR do?

Refactor to remove the indexOf call.

Fixed issues

Details

Before: What was the problem?

indexOf should not be necessary.

After: How does it behave after the fixing?

Use the index from map function`.

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

N.A.

Merging options

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

Other information

@echarts-bot
Copy link
Copy Markdown

echarts-bot Bot commented Dec 18, 2025

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.

The pull request is marked to be PR: author is committer because you are a committer of this project.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors the createAxisLabels function to eliminate an unnecessary indexOf call within a map operation. The change improves both code clarity and performance by utilizing the index parameter that map already provides.

Key Changes:

  • Removed redundant indexOf call that was performing O(n) lookup on each map iteration
  • Added index parameter to the map callback function to directly access the iteration index

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@github-actions
Copy link
Copy Markdown
Contributor

The changes brought by this PR can be previewed at: https://echarts.apache.org/examples/editor?version=PR-21432@921496a

@plainheart plainheart merged commit 2292edb into master Dec 18, 2025
8 checks passed
@plainheart plainheart deleted the fix-axisTickLabel branch December 18, 2025 03:18
@echarts-bot
Copy link
Copy Markdown

echarts-bot Bot commented Dec 18, 2025

Congratulations! Your PR has been merged. Thanks for your contribution! 👍

@plainheart plainheart removed this from the 6.0.1 milestone Dec 18, 2025
@Ovilia Ovilia restored the fix-axisTickLabel branch January 13, 2026 06:44
@plainheart plainheart deleted the fix-axisTickLabel branch February 4, 2026 04:26
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.

3 participants