While making the reproducible example, I realized that the elements missing the customdata are not “lines” but rather the trace itself, which is clickable when the lines form a closed component. Also, not only the customdata, but also text is missing as well. Seems that “CurveNumber” is the only attribute that shows up. Please check the code below:
import dash
from dash.dependencies import Input, Output
import dash_core_components as dcc
import dash_html_components as html
import plotly.graph_objs as go
app = dash.Dash(__name__)
somedata = ['p1', 'p2', 'p3', 'p4']
app.layout = html.Div([
dcc.Graph(
figure={
'data': [go.Scatter(
x=[1, 1, 2, 2, 1],
y=[1, 2, 2, 1, 1],
mode='lines',
name='this_trace_is_a_box',
customdata=somedata,
text=somedata,
fill='toself',
line={
'width': 1,
'color': 'black',
},
)],
'layout': go.Layout(
xaxis={'range': [0, 3]},
yaxis={'range': [0, 3]},
hovermode='closest'
)
},
id='graph'
),
html.H3(id='clickdata-output')
])
@app.callback(
Output('clickdata-output', 'children'),
[Input('graph', 'clickData')]
)
def on_click(click_data):
return str(click_data)
if __name__ == '__main__':
app.run_server(debug=True)
I guess the issue is then a little different, but it would be nice to be able to add customdata to anything you can click, such as the trace here. Is this something that’s already possible or is it not currently possible in Dash/Plotly itself?