echarts icon indicating copy to clipboard operation
echarts copied to clipboard

feat(chart): support negative values in logarithmic axes

Open andreasgerstmayr opened this issue 3 years ago • 4 comments

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
  • [X] new feature
  • [ ] others

What does this PR do?

Supports negative values in logarithmic axes.

Fixed issues

  • #15558
  • #17459

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

andreasgerstmayr avatar Feb 19 '22 15:02 andreasgerstmayr

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.

echarts-bot[bot] avatar Feb 19 '22 15:02 echarts-bot[bot]

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.

echarts-bot[bot] avatar Feb 23 '24 20:02 echarts-bot[bot]

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

alexandrepola avatar Apr 01 '24 14:04 alexandrepola

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 :)

andreasgerstmayr avatar Apr 16 '24 10:04 andreasgerstmayr

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

octoth0rpe avatar Jun 10 '24 17:06 octoth0rpe

@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!

Antti-Palola avatar Aug 08 '24 12:08 Antti-Palola

@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!

octoth0rpe avatar Aug 08 '24 12:08 octoth0rpe

@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?

Antti-Palola avatar Aug 08 '24 12:08 Antti-Palola