plotly.js icon indicating copy to clipboard operation
plotly.js copied to clipboard

if `hoverinfo` of trace is set to `skip` , any event has not occured.

Open Freddicola opened this issue 4 years ago • 3 comments

If hoverinfo of trace is set to skip , No event handler works. Please see it: https://codepen.io/freddicola/pen/vYRemyN

I cannot understand why the hoverinfo is related to the event handling. I think that is not related to anything.

var data = [
  {
    
    x: ['giraffes', 'orangutans', 'monkeys'],
    y: [20, 14, 23],
    type: 'bar',
    selected: {
      marker: {
        opacity: 1,
      },
    },
    unselected: {
      marker: {
        opacity: 0.2,
      },
    },
    hoverinfo: "skip",
  }
];

const config = {
  responsive: true,
}

const layout = {
  dragmode: "zoom",
  clickmode: "select+event",
};

const plot = document.getElementById('myDiv');

Plotly.newPlot(plot, data, layout, config);

plot.on("plotly_click", (data) => {
  alert(data);
});

plot.on("plotly_selected", (data) => {
  alert(data); // NO events are captured on here~!
});

image

Freddicola avatar Jul 27 '22 02:07 Freddicola

That's by design. If you set it to none you should still get the event even though Plotly.js will not handle it.

nicolaskruchten avatar Jul 27 '22 11:07 nicolaskruchten

Ah, my apologies: your CodePen is about click and selection events, not hover events, which is what I was referring to above. Yes this is indeed very strange!

nicolaskruchten avatar Jul 27 '22 11:07 nicolaskruchten

Ah, my apologies: your CodePen is about click and selection events, not hover events, which is what I was referring to above. Yes this is indeed very strange!

Thanks for your interest 👍, to avoid confusing, I'll depict that more : )

Freddicola avatar Jul 28 '22 07:07 Freddicola