Skip to content

Using "plotly_selected" failed #1793

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wilsonandusa opened this issue Jun 16, 2017 · 1 comment
Closed

Using "plotly_selected" failed #1793

wilsonandusa opened this issue Jun 16, 2017 · 1 comment

Comments

@wilsonandusa
Copy link

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

@etpinard
Copy link
Contributor

Selection box and lasso are not available for mode: 'lines' scatter traces at the moment.

So, this issue is a duplicate of #170

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants