Skip to content

[BUG] Clustering (#5827) breaks callback on the scattermapbox graph element #2341

Closed
@ghost

Description

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions