Skip to content

No Click event on category label (xticks) of bar chart #1751

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
patilkun opened this issue Jun 1, 2017 · 4 comments
Closed

No Click event on category label (xticks) of bar chart #1751

patilkun opened this issue Jun 1, 2017 · 4 comments

Comments

@patilkun
Copy link

patilkun commented Jun 1, 2017

I am not getting click event on click of category label (xticks) of bar chart. I am using 'plotly_click'.
Below is the code

HTML -

<head>
  <!-- Plotly.js -->
  <script src="https://cdn.plot.ly/plotly-latest.min.js"></script>
</head>

<body>
  
  <div id="myDiv" style="width: 480px; height: 400px;"><!-- Plotly chart will be drawn inside this DIV --></div>
  <script>
    <!-- JAVASCRIPT CODE GOES HERE -->
  </script>
</body>

Javascript -

var trace1 = {
  x: ['giraffes', 'orangutans', 'monkeys'], 
  y: [20, 14, 23], 
  name: 'SF Zoo', 
  type: 'bar'
};

var trace2 = {
  x: ['giraffes', 'orangutans', 'monkeys'], 
  y: [12, 18, 29], 
  name: 'LA Zoo', 
  type: 'bar'
};

var data = [trace1, trace2];

var layout = {barmode: 'group'};

Plotly.newPlot('myDiv', data, layout);
var myDiv = document.getElementById('myDiv');
myDiv.on('plotly_click', function(data){
    alert('chart clicked');
});

I am able to get click event on actual bars but I am looking for click event on category label under bar.
In below image I am looking for click event on 'giraffes'. Thanks for the help in advance.
image

@etpinard
Copy link
Contributor

etpinard commented Jun 1, 2017

That's the desired behavior. plotly_ are only triggered within the plot area (i.e. inside the axes).

@patilkun
Copy link
Author

patilkun commented Jun 1, 2017

Thanks @etpinard for quick response. Is there any other event triggered on click of the labels?

@etpinard
Copy link
Contributor

etpinard commented Jun 1, 2017

Is there any other event triggered on click of the labels?

Not at the moment. See #145 for more event proposals.

In any case, this is a duplicate of #65; closing this ticket.

@etpinard etpinard closed this as completed Jun 1, 2017
@sardbaba
Copy link

#65 (comment)

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

3 participants