curveNumber
is the index of the object/dict/“trace” inside figure.data
. The names are set with the name
property, i.e.
app.layout = html.Div([
dcc.Graph(id='graph', figure={
'data': [
{'x': [1], 'y': [3], 'name': 'This is Trace 1'},
{'x': [1], 'y': [3], 'name': 'This is Trace 2'}
]})
])
One way to access it would be to index the element directly inside the callback:
@app.callback(...)
def respond_to_hover_data(hoverData):
curve_number = hoverData[...]
trace_name = app.layout['graph'].figure['data'][curve_number]['name']