Skip to content
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

feat(chart): support negative values in logarithmic axes #16547

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

andreasgerstmayr
Copy link

@andreasgerstmayr andreasgerstmayr commented Feb 19, 2022

The logarithm of negative values is not defined.
However, in the case of a logarithmic chart axis, it makes sense to
define log(-x) as -log(x), to support logarithmic axes with negative
values.

Cf. 'symlog' in matplotlib

Resolves: #15558
Resolves: #17459

Brief Information

This pull request is in the type of:

  • bug fixing
  • new feature
  • others

What does this PR do?

Supports negative values in logarithmic axes.

Fixed issues

Details

Before: What was the problem?

Axes with logarithmic scales didn't support negative values, because Math.log() of a negative number is undefined (NaN). Therefore the ticks on the yAxis disappeared entirely.

After: How is it fixed in this PR?

Negative values for logarithmic scales work by defining log(-x) = -log(x) and negative values are shown on logarithmic axes.

Misc

Related test cases or examples to use the new APIs

test/bar-log-negative.html

Others

Merging options

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

Other information

The logarithm of negative values is not defined.
However, in the case of a logarithmic chart axis, it makes sense to
define log(-x) as -log(x), to support logarithmic axes with negative
values.

Cf. 'symlog' in matplotlib

Resolves: apache#15558
@echarts-bot
Copy link

echarts-bot bot commented Feb 19, 2022

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.

andreasgerstmayr added a commit to andreasgerstmayr/fava-portfolio-returns that referenced this pull request Apr 16, 2022
hanjano added a commit to crypkit/echarts that referenced this pull request Apr 18, 2023
src/scale/Log.ts Outdated Show resolved Hide resolved
Copy link

echarts-bot bot commented Feb 23, 2024

To reviewers: If this PR is going to be described in the changelog in the future release, please make sure this PR has one of the following labels: PR: doc ready, PR: awaiting doc, PR: doc unchanged

This message is shown because the PR description doesn't contain the document related template.

@alexandrepola
Copy link

Hey @andreasgerstmayr, do you know if they have an estimated deadline for reviewing/merging the PR? I'm facing the same problem here

@andreasgerstmayr
Copy link
Author

Hey @andreasgerstmayr, do you know if they have an estimated deadline for reviewing/merging the PR? I'm facing the same problem here

I don't know, I'd also like to get this PR merged :)

@octoth0rpe
Copy link

I would also love to see this merged. Is there anything we could do to help this along?

@Antti-Palola
Copy link

Antti-Palola commented Aug 8, 2024

@octoth0rpe was there something still missing from this PR?

This feature would be highly appreciated ❤️

Tested this PR locally and it seems to be working well!

@octoth0rpe
Copy link

octoth0rpe commented Aug 8, 2024

@octoth0rpe was there something still missing from this PR?

Nothing from my perspective, but I'm not an echarts maintainer 🤷 Just another user who wants this feature!

@Antti-Palola
Copy link

Antti-Palola commented Aug 8, 2024

@Ovilia, it seems this PR has been lost in the pile of PRs. I checked that you had contributed to the log scaling before. Can you check this or maybe think of someone who could help make progress in 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.

Thanks for the contribution!

There seems to be a bug with test/logScale.html, where the minimal value of the yAxis should not be a negative value since the data are all positive.

And please also add zero in the test case in bar-log-negative.

@Ovilia Ovilia added this to the 5.5.2 milestone Sep 14, 2024
@Antti-Palola
Copy link

@andreasgerstmayr how are things on your plate? Are you able to fix that test page?

@andreasgerstmayr
Copy link
Author

andreasgerstmayr commented Oct 22, 2024

@andreasgerstmayr how are things on your plate? Are you able to fix that test page?

@Antti-Palola I gave it a shot the other day but either the new test/bar-log-negative.html test works, or test/logScale.html, but not both.
I'm busy with other projects at the moment, if you're interested in this feature and have time, feel free to look into it.

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
5 participants