I am trying to embed a ggvis plot in shiny with a hover element, but it seems that it doesn't render in shiny (the hover element that is). Below are the Server and UI components:
server.R:
library(choroplethrAdmin1)
library(choroplethr)
library(ggvis)
library(dplyr)
jor<-get_admin1_map("jordan")
jor$total <- runif(983) * 100
jor %>% ggvis(~long, ~lat) %>%
layer_paths(data = jor %>% group_by(name),
strokeWidth := 0, fill = ~total) %>%
hide_axis("x") %>% hide_axis("y") %>%
add_tooltip(function(data){paste("Gov: ", data$name, "<br>", "Total: ", as.character(data$lat))}, "hover")
shinyServer(function(input, output) {
jor%>%
ggvis(~long, ~lat) %>%
layer_paths(data = jor %>% group_by(name),
strokeWidth := 0, fill = ~total) %>%
hide_axis("x") %>% hide_axis("y") %>%
bind_shiny("p")
})
ui.R
library(shiny)
library(ggvis)
shinyUI(fluidPage(
titlePanel("Hello Shiny!"),
mainPanel(
ggvisOutput("p")
)
))
Is there something wrong in the code, or is that natural? It would be a real disappointment if the interactivity of ggvis is lost in shiny. If that is the case, are there any alternatives?