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

hoverinfo doesn't work with hoveron 'fill'

Open bcdunbar opened this issue 8 years ago • 5 comments

In v4.7.1.9000, hoverinfo = 'text' doesn't work when hoveron = 'fill'. That is, trace name is displayed instead of the text value.

p <- plot_ly() %>%
  add_trace(
    type = "scatter", 
    mode = "lines", 
    x = c(0,1,1,0,0), 
    y = c(0,0,1,1,0), 
    fill = "tonext", 
    fillcolor = "blue",
    hoveron = "fills", 
    hoverinfo = "text", 
    text = "testing"
  )

It works as expected in JS https://codepen.io/bcd/pen/vjQvvo

bcdunbar avatar May 18 '18 07:05 bcdunbar

Huh, this appears to work for me with both fill or fills (using efe5535). Could you try updating and confirm?

devtools::install_github('ropensci/plotly')

cpsievert avatar May 18 '18 14:05 cpsievert

It works! Didn't update recently 🙄

bcdunbar avatar May 21 '18 02:05 bcdunbar

hoverinfo can have different values like x, y or text. But it seems only text info is shown on hover. Don't know why. Should this issue still be closed?

ankuradhey avatar Sep 03 '18 09:09 ankuradhey

Using hoveron = "fills" gives me a very different result than hoveron = "fill" (while tooltip = "text" and hoverinfo = "text") With hoveron = "fills" I get some of the values in the text aesthetic that I want (but it's buggy - the tooltip text is a long list instead of a specific entry) With hoveron = "fill", I get the names of "fill" aesthetic instead.

I wanted to point out my fill aesthetic is discrete factors (5) and I seem to get only 5 distinct tooltips only, instead of an individual tooltip for every shape in my geom_sf.

ahcyip avatar Oct 06 '20 20:10 ahcyip

This SO question describes our problems with tooltips on maps with ggplotly: https://stackoverflow.com/questions/59310051/r-ggplotly-shows-wrong-tooltip-with-geom-sf-and-discrete-fill-scale

ahcyip avatar Oct 08 '20 06:10 ahcyip