Redash: Y-axis autoscale fails when min == 0

Created on 8 Apr 2020  ·  7Comments  ·  Source: getredash/redash

Issue Summary

Y-axis auto scaling doesn't work if the user forces the minimum Y-axis value to a constant. It seems to be all-or-nothing: use auto for min and max or not at all.

I reproduced this issue in our preview instance.

Original Visualization

There are three traces. Fully auto scaled.

1_original

With full auto-scaling

I've clicked to hide the highest number (green line). The Y-axis re-scales to show more precision on the blue and red lines.

2_full_auto

With auto-scale max and min forced to 0

I've clicked to hide the highest number (green line). The Y-axis does not re-scale. So the lines are inexplicably flat compared to how they would appear if the green line were not there in the first place.

3_partial_auto

Steps to Reproduce

  1. Write a query that returns at least two lines
  2. Force the Y-axis to be minimum of 0
  3. Click the legend to hide the higher numbered line
  4. Observe that the Y-axis does not re-scale to accommodate the only line being displayed.

Technical details:

  • Redash Version: v9 Alpha
  • Browser/OS: FF and Chrome
  • How did you install Redash: SaaS
Frontend Visualizations Chart

Most helpful comment

Hey redash team. I’m new to the project but would love to help. Is someone already looking into this or could I help investigate further?

All 7 comments

Hey redash team. I’m new to the project but would love to help. Is someone already looking into this or could I help investigate further?

@reiff12 you're welcome to take a stab at this! Thanks 🙇

Hey @arikfr, so im getting started with this. Is it possible to hook into the preview backed in order to have populated data? I understand to connect the dev UI to an existing back-end use REDASH_BACKEND="http://preview-backend.redashapp.com" which i get to the login screen. I tried to create my own user using the preview admin account but when i follow the invite link the page is not found.

What would you recommend for a client dev env setup? Thanks for the help.

Creating user flow is a bit broken. You need to change the url you get in the invite. Replace the Netlify domain with http://preview-backend.redashapp.com.

Another option is to use one of the default users. Check the login page source to get the username/password. :)

Arik

On Fri, Apr 17 2020 at 6:38 AM, Tyler Reiff < [email protected] > wrote:

Hey @arikfr ( https://github.com/arikfr ) , so im getting started with
this. Is it possible to hook into the preview backed in order to have
populated data? I understand to connect the dev UI to an existing back-end
use REDASH_BACKEND="http://preview-backend.redashapp.com" which i get to
the login screen. I tried to create my own user using the preview admin
account but when i follow the invite link the page is not found.

What would you recommend for a client dev env setup? Thanks for the help.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub (
https://github.com/getredash/redash/issues/4784#issuecomment-615020894 ) ,
or unsubscribe (
https://github.com/notifications/unsubscribe-auth/AAAROLCX7TQPMQXBJELL7K3RM7FLFANCNFSM4MDO5N3A
).

Hello @arikfr and @susodapop , I believe I've narrowed down this issue to not generating a new plotlyLayout object when the "plotly_restyle" event is fired. My proposed fix is when the chart container fires the "plotly_restyle" event, create a new layout object with the data filtered for what is visible. Does this make sense as a fix? If so I'll make a PR for review.

i.e.

const nextPlotlyLayout = {
    ...plotlyLayout,
    ...prepareLayout(
        container,
        options,
        plotlyData.filter(i => i.visible === true)
    ),
};

updateData(plotlyData, options);
Plotly.relayout(container, nextPlotlyLayout);

The file in question client/app/visualizations/chart/Renderer/PlotlyChart.jsx Line: 46

The current handler supposed to take care of this, but I think something is indeed wrong with the implementation:

https://github.com/getredash/redash/blob/e99c37a36a8f091cac001af130937bcb267d55a5/client/app/visualizations/chart/Renderer/PlotlyChart.jsx#L49-L54

We call updateData (which does the visibility filtering) but ignore its results. @kravets-levko does it has some side effects we want to trigger here?

We call updateData (which does the visibility filtering) but ignore its results. @kravets-levko does it has some side effects we want to trigger here?

updateData updates series in place. Plotly also holds a reference to layout and series, so no need to pass new data after updating. Also, no need to filter out invisible series - Plotly uses visible flag to hide unused series.

I'll check what may be wrong there, maybe something has changed in new Plotly version, or maybe it didn't work properly even before - I cant tell yet.

Was this page helpful?
0 / 5 - 0 ratings