Brush by selecting points in first plot to color, hover in any to display values

show with app
shinyServer(function(input, output) {

  library(mdsr)
  library(ggvis)
  library(lubridate)
  library(shiny)
  
  library(macleish)
  occ <- whately_2015 %>%
    mutate(id = seq_len(nrow(.)))
  
  set.seed(5000)
  
  all_values <- function(x) {
    if (is.null(x)) return(NULL) 
    row <- occ[occ$id == x$id, ]
    paste0(names(row), ": ", format(row), collapse = "<br />")
  }

  mtc <- reactive({ domainval <- c(ymd_hms(paste("2015-", input$startmonth, "-01 00:00:00", sep="")), 
                      ymd_hms(paste("2015-", input$endmonth, "-01 00:00:00", sep="")))
    occ2 <- occ %>% filter(when > domainval[1] & when < domainval[2])
  })
  

  lb <- linked_brush(keys = 1:nrow(occ), "red")
  # Change the colour of the points, then click on the stop sign
  occ %>%
    ggvis(~temperature, ~rainfall, key := ~id) %>%
    layer_points(fill := lb$fill, size.brush := 100) %>%
    add_tooltip(all_values, "hover") %>%
    lb$input() %>%
    bind_shiny("ggvis1", "ggvis_ui1")
  
  reactive({
    smallocc <- mtc()
    smallocc %>%
      ggvis(~when, ~wind_speed, key := ~id) %>%
      layer_points(size.brush := 100) %>%
      add_tooltip(all_values, "hover") %>%
      layer_points(fill := "red", data = reactive(occ[lb$selected(), ])) 
  }) %>%
    bind_shiny("ggvis2", "ggvis_ui2")
  
  occ %>% 
    ggvis(y = ~temperature, x = ~when, key := ~id) %>%
    layer_points() %>%
    add_tooltip(all_values, "hover") %>%
    layer_points(fill := "red", data = reactive(occ[lb$selected(), ])) %>%
    bind_shiny("ggvis3", "ggvis_ui3")
})
library(ggvis)
shinyUI(bootstrapPage(
  p("Brush by selecting points in first plot to color, hover in any to display values"),
  
  numericInput("startmonth", "Enter starting month (between 1 and 11)",
               value=1, min=1, max=11, step=1),
  numericInput("endmonth", "Enter ending month (between 2 and 12)",
               value=12, min=2, max=12, step=1),
  uiOutput("ggvis_ui1"),
  ggvisOutput("ggvis1"),
  
  uiOutput("ggvis_ui2"),
  ggvisOutput("ggvis2"),
  
  uiOutput("ggvis_ui3"),
  ggvisOutput("ggvis3")

))