Skip to content

Conversation

bg451
Copy link

@bg451 bg451 commented Sep 2, 2025

Brief Information

This pull request is in the type of:

  • bug fixing
  • new feature
  • others

What does this PR do?

This PR adds the ability to change the base of the tick intervals to align on (1, 2, 3, 4,... * base^x).

Fixed issues

#21208

Details

Before: What was the problem?

When using KMB formatting for a unit that is non base 10 such as binary bytes, the tick intervals will align on a multiple of a base 10 number, so when the formatting occurs the number do not align nicely with the KMB formatting. Setting the interval manually can be difficult/expensive when you have a highly variable, dynamic dataset.

For example, where formatter code looks like so:

function (value) {
  if (value >= 1024 * 1024 * 1024) {
    return (value / (1024 * 1024 * 1024)).toFixed(2) + ' GiB';
  } else if (value >= 1024 * 1024) {
    return (value / (1024 * 1024)).toFixed(2) + ' MiB';
  } else if (value >= 1024) {
    return (value / 1024).toFixed(2) + ' KiB';
  } else {
    return value + ' B';
  }
}
Screenshot 2025-09-02 at 3 09 39 PM

After: How does it behave after the fixing?

When using the same formatter but with tickBase = 2

Screenshot 2025-09-02 at 3 11 35 PM

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

ZRender Changes

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

Related test cases or examples to use the new APIs

N.A.

Others

Merging options

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

Other information

Let me know what you think! Thanks!

Copy link

echarts-bot bot commented Sep 2, 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.

⚠️ MISSING DOCUMENT INFO: Please make sure one of the document options are checked in this PR's description. Search "Document Info" in the description of this PR. This should be done either by the author or the reviewers of the PR.

@bg451 bg451 marked this pull request as ready for review September 2, 2025 19:12
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