Black Lives Matter. Please consider donating to Black Girls Code today.
Dash HoloViews is now available! Check out the docs.

Click event on a trace

Hello everyone,
i would like add an event when i click on a trace.
for exemple when i click on a trace, i show an alert “you click on trace X”.

Thanks everyone.

var gd = document.getElementById('graph')
Plotly.newPlot(gd, [], {})
gd.on('plotly_click', () => {})

should do the trick.

yes but this it’s if i click on a point .

here i would like that if i click on red trace there an alert but not on black point
image

Ha, we don’t expose a way to that at the moment.

You can subscribe to https://github.com/plotly/plotly.js/issues/145 for the most up-to-date development info.

Ok, thank for your help :slight_smile: