Skip to content

Conversation

wch
Copy link
Contributor

@wch wch commented Nov 5, 2020

To be merged after ramnathv/htmlwidgets#391.

This makes renderPlotly work with shiny::bindCache in the dev version of shiny. For example:

library(shiny)
library(plotly)

ui <- fluidPage(
  selectizeInput(
    inputId = "cities", 
    label = "Select a city", 
    choices = unique(txhousing$city), 
    selected = "Abilene",
    multiple = TRUE
  ),
  plotlyOutput(outputId = "p")
)

server <- function(input, output, ...) {
  output$p <- renderPlotly({
    message("Computing p: ", paste(input$cities, collapse = ", "))
    Sys.sleep(2)
    plot_ly(txhousing, x = ~date, y = ~median) %>%
      filter(city %in% input$cities) %>%
      group_by(city) %>%
      add_lines()
  }) %>% 
    bindCache(input$cities)

}

shinyApp(ui, server)

@wch wch changed the title Add support for shiny::withCache Add support for shiny::bindCache Nov 13, 2020
@cpsievert cpsievert merged commit e6725e6 into master Nov 16, 2020
@cpsievert cpsievert deleted the wch-withcache branch November 16, 2020 16:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants