shiny - ggvis, tooltip for bar plots -
i trying create tooltip bar plot. tried same code on layer_points, , works fine. however, when switch layer_bars, function not work anymore. tooltip not show case. can please help? here code:
the data using contains x: index, , ss.plus: positive numbers
ui.r:
library(ggvis) shinyui(fluidpage("test", fluidrow( plotoutput("realdata", height = "200") ), sidebarlayout( sidebarpanel( sliderinput("range.real", label="select range of view", min=1, max=1808, value=c(1, 50) ) ), mainpanel( ggvisoutput("barplus") ) ) ))
server.r:
library(ggvis) shinyserver(function(input, output, session){ sub.data <- reactive({ real.data[input$range.real[1]:input$range.real[2],] }) on_hover <- function(x){ if(is.null(x)) return(null) paste0(x$x, ",", x$ss.plus) } sub.data %>% ggvis(~x, ~ss.plus) %>% layer_bars(width=0.8) %>% add_tooltip(on_hover, "hover") %>% bind_shiny("barplus") })
Comments
Post a Comment