-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Closed
Description
I want the plot to respond with an alert message when the user selects some data(zoom in), but the following example does not responds with user selection.
<!DOCTYPE html>
<html>
<head>
<script src="https://cdn.plot.ly/plotly-1.2.0.min.js"></script>
</head>
<body>
<div id = "tester_1"></div>
<script>
TESTER_1 = document.getElementById('tester_1');
var trace1 = {
x: [1,2,3,4,5,6,7,8,9,10,11],
y: [1,2,3,3,4,4,4,5,5,5,5],
mode: 'lines'
};
var data = [trace1]
var layout = {
displaylogo:false,
xaxis: {
title: 'x'
},
yaxis: {
title:'y'
}
}
Plotly.newPlot( TESTER_1, data, layout, {modeBarButtonsToRemove: ['toImage','sendDataToCloud','hoverCompareCartesian','pan2d',
'zoom2d','select2d','lasso2d','resetScale2d','hoverClosestCartesian',],displaylogo:false})
document.getElementById('tester_1').on('plotly_selected', function(data){
console.log('clicked')
alert('Clicked');
})
</script>
</body>
</html>
Also, I wonder if there's a function to detect which modebar button the user clicked. For example, if the user clicks the autoscale button, the plots shows an alert message "Autoscale finished!".
Thanks
Metadata
Metadata
Assignees
Labels
No labels