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] Clustering (#5827) breaks callback on the scattermapbox graph element #2341

Open
TimMFraunhofer opened this issue Nov 29, 2022 · 3 comments

Comments

@TimMFraunhofer
Copy link

Describe your context
I'm trying to use the clustering feature for that was introduced to plotly in the latest update (see documentation).

In the following example you can test it by commenting out fig.update_traces(cluster=dict(enabled=True)). Clicking dots without clustering will display the click data in the seconds div.

import plotly.graph_objects as go  # or plotly.express as px
import plotly.express as px
import pandas as pd

import dash
from dash import dcc
from dash import html
from dash.dependencies import Input, Output

df = pd.read_csv(
    "https://raw.githubusercontent.com/plotly/datasets/master/2011_february_us_airport_traffic.csv"
)
fig = px.scatter_mapbox(df, lat="lat", lon="long",
                        size="cnt", zoom=3, mapbox_style="open-street-map")
fig.update_traces(cluster=dict(enabled=True))

app = dash.Dash()
app.layout = html.Div([
    html.Div([
        dcc.Graph(figure=fig, id="map")
    ], style={"width": "500px", "height": "500px"}),
    html.Div(id='my-div', className='col-12')
])


@ app.callback(
    Output('my-div', 'children'),
    Input('map', 'clickData')
)
def display_clicked_content(clickData):
    return repr(clickData)


app.run_server(debug=True, use_reloader=False)
  • replace the result of pip list | grep dash below
dash                      2.7.0
dash-bootstrap-components 1.2.1
dash-core-components      2.0.0
dash-draggable            0.1.2
dash-html-components      2.0.0
dash-table                5.0.0
  • if frontend related, tell us your Browser, Version and OS

    • OS: Windows 11 Pro - Version 10.0.22000 Build 22000
    • Browser: Firefox
    • Version 107.0 (64 Bit)

Describe the bug

When using the clustering feature on a scattermap calbacks that use inputs of the map no longer work. The error shown in the browser looks like this.

Expected behavior

Clicking on markers on the map should trigger callbacks that e.g. use clickData as an Input.

@alexcjohnson
Copy link
Collaborator

Possibly related to #2343 (cc @AnnMarieW) - @archmoj would you be able to look into this?

@archmoj
Copy link
Contributor

archmoj commented Nov 30, 2022

Possibly related to #2343 (cc @AnnMarieW) - @archmoj would you be able to look into this?

OK. Let me see if I could replicate the bug using plotly.js.

@ned2
Copy link
Contributor

ned2 commented Dec 30, 2022

I suspect this issue is independent of #2343, as I just tested and found that issue to be fixed with the plotly.js version bump in Dash 2.17.1, however the problem described in this issue still persists with 2.7.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants