Search code examples
rshinyggvis

ggvis in R: Change color when mouse hover


Is there a code that can realize the first example picture on the GGVIS homepage?

https://ggvis.rstudio.com/

enter image description here

The function I want is that the color changes when I hover over the bar.

Thanks.


Solution

  • Try the fill.hover argument:

    library(ggvis)
    
    faithful %>% 
    ggvis(~eruptions, fill := "#fff8dc", fill.hover := "#fcb5a2") %>%
      layer_histograms(width = 0.25)