myPlot.on(‘plotly_click’, function(data){
console.log(data)
for(var i=0; i<data.points.length; i++){
annotate_text = 'x = '+data.points[i].x +' y = '+data.points[i].y.toPrecision(4);
annotation = {
text: annotate_text,
x: data.points[i].x,
y: parseFloat(data.points[i].y.toPrecision(4))
}
annotations = self.layout.annotations || [];
annotations.push(annotation);
Plotly.relayout('myDiv',{annotations: annotations})
}
});
how to use plotly_click event in reactjs?