Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Another approach to applying default filter/select settings on render #100

Draft
wants to merge 1 commit into
base: joe/feature/filter-select-default
Choose a base branch
from

Conversation

jcheng5
Copy link
Member

@jcheng5 jcheng5 commented Jun 10, 2021

Note: d3scatter needs to change as well, the renderValue method needs to end with:

        sel_handle.invokeChangeHandler();
        filter_handle.invokeChangeHandler();
library(shiny)
library(crosstalk)
library(d3scatter)

sd <- SharedData$new(iris)

ui <- fluidPage(
  filter_slider("petal_width", "Petal width", sd, column = "Petal.Width",
    selected = c(1, 2)),
  actionButton("show", "Show second scatterplot"),
  bscols(
    d3scatterOutput("scatter1"),
    uiOutput("ui")
  )
)

server <- function(input, output, session) {
  observeEvent(input$show, {
    output$ui <- renderUI({
      d3scatterOutput("scatter2")
    })
  }, once = TRUE)
  
  output$scatter1 <- renderD3scatter({
    d3scatter(sd, ~Petal.Length, ~Petal.Width)
  })
  
  output$scatter2 <- renderD3scatter({
    d3scatter(sd, ~Petal.Length, ~Petal.Width)
  })
}

shinyApp(ui, server)

@jcheng5 jcheng5 marked this pull request as draft June 10, 2021 19:14
@cpsievert cpsievert added this to the Next release milestone Jun 10, 2021
jcheng5 added a commit to jcheng5/d3scatter that referenced this pull request Jun 24, 2021
@cpsievert cpsievert force-pushed the joe/feature/filter-select-default-2 branch from b420e9f to b4ea77d Compare June 29, 2021 22:02
@cpsievert cpsievert force-pushed the joe/feature/filter-select-default-2 branch from b4ea77d to 5a894aa Compare June 29, 2021 22:10
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