Skip to content

Support negative values for log Scale. #20872

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
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

Antti-Palola
Copy link

@Antti-Palola Antti-Palola commented Mar 27, 2025

Support implemented by inverting the extents at input and handling the input as absolute value and finally mapping everything back to negative axes in inverted order.

Added test cases for passing through 0 power and new a new file logScale-negative.html.

Brief Information

This pull request is in the type of:

  • bug fixing
  • new feature
  • others

What does this PR do?

Add support for plotting negative values on Log scales.

Fixed issues

Fix a previous PR #16547 more generically and correctly.

Details

Before: What was the problem?

Negative values could not be plotted with log scaling.

After: How does it behave after the fixing?

Log scale can now be used

Before: nothing is drawn
Screenshot 2025-03-27 at 23 06 24

After
Screenshot 2025-03-27 at 23 04 38

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

There is no mention of negative values having problems in docs.

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

Copy link

echarts-bot bot commented Mar 27, 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.

@Antti-Palola Antti-Palola force-pushed the fix-logarithmic-scale-negative-below-one branch 2 times, most recently from c67121f to 17b68f2 Compare March 28, 2025 07:48
@Antti-Palola Antti-Palola marked this pull request as ready for review March 28, 2025 08:50
Copy link
Contributor

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

Support implemented by inverting the extents at input and handling the
input as absolute value and finally mapping everything back to negative
axes in inverted order.

Added test cases for passing through 0 power and new a new file ogScale-negative.html.
Properly inherit IntervalScale and inline the only thing
that really was required from Scale base class `unionExtent`.
Add limit to major tick generation to stop at base extents. If log base 10 range
is from 4 to 200, previously ticks overflowed from top and bottom to 1-1000.

Create minor ticks within decade linearly spaced as before but if the extent
is not within even log steps, stop generating at extent end.
When major ticks are more than one decade apart, generate a minor tick for each
decade up to the split number times.
@Antti-Palola Antti-Palola force-pushed the fix-logarithmic-scale-negative-below-one branch from 85787f2 to b6aeb01 Compare April 25, 2025 10:49
@Antti-Palola
Copy link
Author

@Ovilia Hey, could you take a look at this: an improved shot at fixing log scaled line plots.

@Ovilia Ovilia requested a review from 100pah June 16, 2025 06:44
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.

[Feature] Support negative and zero when axis type is 'log' Display negative value in Logarithmic axis
1 participant