Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Adds support for changing the tick interval base #21240

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
bg451 wants to merge 1 commit into apache:master
base: master
Choose a base branch
Loading
from bg451:bg/tick_interval_base

Conversation

Copy link

@bg451 bg451 commented Sep 2, 2025
edited
Loading

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!

sjcobb reacted with thumbs up emoji
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
Copy link
Author

bg451 commented Oct 8, 2025

@Ovilia friendly bump on this!

Copy link
Contributor

@Ovilia Ovilia left a comment

Choose a reason for hiding this comment

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

The change of this PR looks a little complex to me. Would it be simpler if we process the option.series.data by dividing the original data by 1024 if the max data is less than 1024 * 1024 and use axisLabel.formatter to add 'KB', or by 1024 * 1024 if the max data is less than 1024 * 1024 * 1024 and use axisLabel.formatter to add 'MB'... ?

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

Reviewers

@Ovilia Ovilia Ovilia left review comments

At least 1 approving review is required to merge this pull request.

Assignees

No one assigned

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants

AltStyle によって変換されたページ (->オリジナル) /