-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Closed
Description
My environment
dash 2.9.2
dash-bootstrap-components 1.4.1
dash-core-components 2.0.0
dash-html-components 2.0.0
dash-table 5.0.0
The bug
This bug is very similar to another one that was fixed last year, described here https://github.com/plotly/dash/issues/1663 .
I want to retrieve a custom identifier (a string) linked to a scatter object, by clicking on it. As per documentation of go.Scatter, customdata is meant for this task, but it is not behaving as expected.
Here is a sample code:
import dash
from dash import html,dcc
from dash.dependencies import Input, Output
import plotly.express as px
import plotly.graph_objects as go
import json
app = dash.Dash(__name__)
fig=go.Figure(data=[go.Scatter(x=[0, 1, 1, 0, 0],y=[1, 1, 2, 2, 1],mode='lines',fill='toself',customdata=["obj-1"]),
go.Scatter(x=[3, 4, 4, 3, 3],y=[4, 4, 5, 5, 4],mode='lines',fill='toself',customdata=["obj-2"])])
app.layout = html.Div([
dcc.Graph(id="scatter-object", figure=fig),
dcc.Textarea(id='textArea')
])
@app.callback(
Output("textArea", "value"),
Input('scatter-object', 'clickData'))
def handleClick(clickData):
return json.dumps(clickData,indent=2)
app.run_server(debug=True)
Expected behavior
clickData should contain the customdata defined in the constructor of go.Scatter. Unfortunately it doesn't.
Screenshots
As one can see on the screenshot below, when clicking on an object, clickData contains its point values, but not the custom data information:
Metadata
Metadata
Assignees
Labels
No labels