Skip to content

graph should handle the case where the display area is significantly small #4155

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

Open
byronz opened this issue Aug 28, 2019 · 10 comments
Open
Labels
bug something broken P3 backlog

Comments

@byronz
Copy link
Contributor

byronz commented Aug 28, 2019

I got an error in the console when trying to increase the size of chrome dev tools

bug
Screen Shot 2019-08-28 at 2 05 18 PM

@byronz
Copy link
Contributor Author

byronz commented Aug 28, 2019

code to reproduce with 1.2.0

import dash
import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output
import pandas as pd
import numpy as np

df = pd.DataFrame(np.random.randn(50, 50))

app = dash.Dash(__name__)


figure = {
    "data": [
        {"x": df.columns, "y": df.index, "z": df.values, "type": "heatmap"}
    ],
    "layout": {"xaxis": {"scaleanchor": "y"}},
}

app.layout = html.Div(
    style={
        "backgroundColor": "red",
        "height": "100vmin",
        "width": "100vmin",
        "overflow": "hidden",
        "position": "relative",
    },
    children=[
        dcc.Loading(
            children=[
                dcc.Graph(
                    id="graph",
                    figure=figure,
                    style={
                        "position": "absolute",
                        "top": 0,
                        "left": 0,
                        "backgroundColor": "blue",
                        "width": "100%",
                        "height": "100%",
                        "overflow": "hidden",
                    },
                )
            ]
        )
    ],
)


@app.callback(Output("graph", "figure"), [Input("graph", "relayoutData")])
def selected_df_figure(selection):
    figure["data"][0]["x"] = df.columns
    figure["data"][0]["y"] = df.index
    figure["data"][0]["z"] = df.values
    return figure


if __name__ == "__main__":
    app.run_server(debug=True)

@alexcjohnson
Copy link
Collaborator

@etpinard @antoinerg this has come up before... can you think of a reasonable way to deal with this kind of undersize condition at the plotly.js level? That seems preferable to trying to handle it on the dash side.

@etpinard
Copy link
Contributor

this has come up before... can you think of a reasonable way to deal with this kind of undersize condition at the plotly.js level?

We could instead of throwing ⚾

if(!isFinite(ax._m) || !isFinite(ax._b) || ax._length < 0) {
fullLayout._replotting = false;
throw new Error('Something went wrong with axis scaling');
}

Lib.warn something and "skip" rendering past that point.

@alexcjohnson
Copy link
Collaborator

Possibly... but I feel like we had a discussion at some point about catching this kind of situation much earlier in the process. The issue I believe is that the sum of top and bottom margins is more than the height (or similar l+r>w) - could we detect an all-margin situation before attempting to draw anything, and just display an empty graph?

@alexcjohnson alexcjohnson transferred this issue from plotly/dash-core-components Aug 29, 2019
@alexcjohnson
Copy link
Collaborator

Transferred to plotly.js, as it looks like we'll try to fix it here.

@alexcjohnson alexcjohnson added the bug something broken label Aug 29, 2019
@etpinard
Copy link
Contributor

cc #2704 - it might play nicely into an updated auto-margin pipeline.

@Sabarish-Vasudevan
Copy link

Has this issue been fixed?

@sebastian-raubach
Copy link

Any update on this?

@archmoj
Copy link
Contributor

archmoj commented Dec 3, 2020

Is this still happening if you use v1.58.0?

@dylangrandmont
Copy link

Still an issue on v2.26.2. I think the suggestion above to warn and skip rendering is preferable here to throwing an uncaught exception

@gvwilson gvwilson self-assigned this Jul 8, 2024
@gvwilson gvwilson removed their assignment Aug 2, 2024
@gvwilson gvwilson changed the title [Graph] - should handle the case where the showing area is significantly small graph should handle the case where the display area is significantly small Aug 9, 2024
@gvwilson gvwilson added the P3 backlog label Aug 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug something broken P3 backlog
Projects
None yet
Development

No branches or pull requests

8 participants