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

[BUG] scattermapbox traces do not update correctly when the figure template changes as of dash 2.7.0 #2343

Closed
AnnMarieW opened this issue Nov 29, 2022 · 4 comments
Labels
bug something broken regression this used to work

Comments

@AnnMarieW
Copy link
Collaborator

As of dash 2.7.0, px.scatter_mapbox traces do not update when the figure template is changed.

It might have something to do with this change?

Feature release 2.16.0 adds clustering to scattermapbox traces and restricted bounds to mapbox plots.

For example, in dash dash 2.6.2 it works correctly:
mapbox-dash-2 6 2

In dash 2.7.0, the traces are not updated but the legend and the hover info is correct for each template.

mapbox-dash2 7 0

from dash import Dash, dcc, html, Input, Output
import plotly.express as px
import dash_bootstrap_components as dbc

app = Dash(__name__, external_stylesheets=[dbc.themes.BOOTSTRAP])

carshare = px.data.carshare()

figure_templates = [
    "plotly",
    "ggplot2",
    "seaborn",
    "simple_white",
    "plotly_white",
    "plotly_dark",
    "presentation",
    "xgridoff",
    "ygridoff",
    "gridon",
    "none",
]

change_figure_template = html.Div(
    [
        html.Div("Change Figure Template"),
        dcc.Dropdown(figure_templates, figure_templates[0], id="template"),
    ],
    className="pb-4",
)


app.layout = dbc.Container(
    [
        dbc.Row(dbc.Col(change_figure_template, lg=6)),
        dbc.Row(dbc.Col(html.Div(id="graphs"))),
    ],
    className="dbc p-4",
    fluid=True,
)


@app.callback(
    Output("graphs", "children"),
    Input("template", "value"),
)
def update_graph_theme(template):

    return dcc.Graph(
        figure=px.scatter_mapbox(
            carshare,
            lat="centroid_lat",
            lon="centroid_lon",
            color="peak_hour",
            size="car_hours",
            size_max=15,
            zoom=10,
            mapbox_style="carto-positron",
            title=f"Carshare <br> {template} figure template",
            template=template,
        ),
        className="border",
    )


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


@archmoj
Copy link
Contributor

archmoj commented Nov 30, 2022

Thanks for the report. Regression confirmed: plotly/plotly.js#6382

@archmoj archmoj added regression this used to work bug something broken labels Nov 30, 2022
@rodrigoalatorre
Copy link

I've found a simmilar issue with graph_objects.Scattermapbox using 2.7.0

@archmoj
Copy link
Contributor

archmoj commented Dec 7, 2022

This bug is addressed by https://github.com/plotly/plotly.js/releases/tag/v2.16.4.
Until next dash release you could provide plotly.js bundle in the asset folder to have the fix.

@ned2
Copy link
Contributor

ned2 commented Dec 30, 2022

@AnnMarieW can confirm that your example is now working with Dash 2.7.1, which includes the Plotly 2.16.4 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug something broken regression this used to work
Projects
None yet
Development

No branches or pull requests

5 participants