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

[charts] Area Chart does not allow logarithmic scale #13759

Closed
nickroh15 opened this issue Jul 8, 2024 · 5 comments · Fixed by #13791
Closed

[charts] Area Chart does not allow logarithmic scale #13759

nickroh15 opened this issue Jul 8, 2024 · 5 comments · Fixed by #13791
Labels
bug 🐛 Something doesn't work component: charts This is the name of the generic UI component, not the React module!

Comments

@nickroh15
Copy link

nickroh15 commented Jul 8, 2024

Steps to reproduce

Link to live example: (required)

Steps:

  1. In the example you can see that the lines with 'area=true' are not rendered if the scale is set to 'log'

Current behavior

When using a log Scale in conjunction with an area chart, the area is not displayed.

Expected behavior

The Area should be displayed?

Context

Working on a charting app, where I want to dynamically configure different charts, including line and area charts. The app should also support are charts with a log y-axis scale.

Your environment

No response

Search keywords: Line Chart Area Chart logScale logarithmic Scale

@nickroh15 nickroh15 added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Jul 8, 2024
@JCQuintas
Copy link
Member

Hi @nickroh15 it indeed looks like a bug.

This seems to only affect axis.type = log, sqrt works fine.

We will add it to our list, thanks for reporting 💪

@JCQuintas JCQuintas added bug 🐛 Something doesn't work component: charts This is the name of the generic UI component, not the React module! and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Jul 8, 2024
@alexfauquette
Copy link
Member

The issue with area+log scale is that the area needs a baseline which is for now the 0. As you can guess having a 0 in a log scale can only cause troubles 😁

To make it work, you will need 2 part

  • fix the min/max of the y-axis to ùmake sure it does not touch 0. In your example nothing get plot because the y-axis is asked to generate a log-scale that maps 0 -> 150 which is impossible.
  • Add an area baseline in the definition of the log scale to let the area plot know which value should be used instead of the default 0

@alexfauquette alexfauquette changed the title Area Chart does not allow logarithmic scale? [charts] Area Chart does not allow logarithmic scale Jul 9, 2024
@nickroh15
Copy link
Author

The issue with area+log scale is that the area needs a baseline which is for now the 0. As you can guess having a 0 in a log scale can only cause troubles 😁

To make it work, you will need 2 part

  • fix the min/max of the y-axis to ùmake sure it does not touch 0. In your example nothing get plot because the y-axis is asked to generate a log-scale that maps 0 -> 150 which is impossible.
  • Add an area baseline in the definition of the log scale to let the area plot know which value should be used instead of the default 0

First of all: thank you very much. This makes sense, but I am not sure how I can define a "baseline" for my logScale? I cannot find anything like that in the documentation..

@alexfauquette
Copy link
Member

alexfauquette commented Jul 10, 2024

I am not sure how I can define a "baseline" for my logScale

Sorry for the lack of clarity. This baseline does not exist. It's more a note for the person who will take care of this issue

After a second look, it seems we can solve the issue without introducing a new params.

In the following line, we do a distinction between areas and lines when computing the extremums.

const getValues: GetValuesTypes = isArea ? (d) => d : (d) => [d[1], d[1]]; // Since this series is not used to display an area, we do not consider the base (the d[0]).

We should modify this such that area with a log scale is treated the same way as a line.

I proposed a PR to fix that

image

Copy link

⚠️ This issue has been closed. If you have a similar problem but not exactly the same, please open a new issue.
Now, if you have additional information related to this issue or things that could help future readers, feel free to leave a comment.

@nickroh15: How did we do? Your experience with our support team matters to us. If you have a moment, please share your thoughts in this short Support Satisfaction survey.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something doesn't work component: charts This is the name of the generic UI component, not the React module!
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants