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

Y-Axis Zoom not working in stacked bar chart with positive and negative values in one stack #4814

Open
Loahrs opened this issue Nov 15, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@Loahrs
Copy link

Loahrs commented Nov 15, 2024

Description

I am using a stacked bar chart to show two data series. The values of one of them are multiplied with -1 to go into the negative direction of the y-axis. The purpose is to compare two series.
However:
I noticed that the Y-Axis scaling is not working as expected when using a stacked bar chart. When setting stacked: false the Y-Axis works as expected, but this gives not the visualization that I want to get out of the chart.

Steps to Reproduce

  1. Open Codepen: https://codepen.io/Loahrs/pen/BaXbgma
  2. Zoom into [ (x=129, y=81), (x=129, y=-634)]
  3. The Y-Axis won't scale properly.
  4. Remove "stacked: true" from the config
  5. Zoom into [ (x=129, y=81), (x=129, y=-634)]
  6. The Y-Axis is properly scaled in both directions.

Expected Behavior

I would like to have the Y-Axis to scale in the positive and negative range correctly on a stacked bar chart.

Actual Behavior

The Y-Axis is not scaling correctly in both directions,

Screenshots

Non-stacked:
firefox_mZalQC2dJE

Stacked:
firefox_WLkvb2lt4y

I would expect to see the same Y-Axis that is shown in the non-stacked Version when using a stacked bar chart.

Reproduction Link

https://codepen.io/Loahrs/pen/BaXbgma

@Loahrs Loahrs added the bug Something isn't working label Nov 15, 2024
@TobiEls
Copy link

TobiEls commented Nov 15, 2024

I looked a bit deeper into this problem and it seems its this particular line/function:

this._setStackedMinMax()

Only for stacked charts new MinMax values are calculated (because of the stacking). But in calculating those values, the whole range of the chart is used. This way the global maximum is used to calculate the maximum of the y-axis.

For the minimum, the value in the relevant window is saved into lowestYInAllSeries in line 256 und reapplied in the next block in line 279 since it's a bar chart.

It seems the function/function call has te be changed in a way to only work with the selected x-axis indices.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants