renkun-ken / formattable

Formattable Data Structures
Other
695 stars 78 forks source link

Can we use crosstalk with formattable? #124

Open shashj opened 4 years ago

shashj commented 4 years ago

Hi, I had a query, don't know where to ask. Can we use formattable with crosstalk? Is it also possible to use datatables, crosstalk and formattable together?

@renkun-ken

daattali commented 1 year ago

For context: The {crosstalk} package allows different shiny widgets on a page to interact with each other

Here is an example of code that should work once crosstalk is enabled:

library(shiny)

df <- crosstalk::SharedData$new(cars)

ui <- fluidPage(
  crosstalk::filter_slider("speed", NULL, df, "speed"),
  d3scatter::d3scatterOutput("plot"),
  formattable::formattableOutput("table")
)

server <- function(input, output, session) {
  output$plot <- d3scatter::renderD3scatter({
    d3scatter::d3scatter(df, ~speed, ~dist)
  })
  output$table <- formattable::renderFormattable({
    formattable::formattable(df)
  })
}

shinyApp(ui, server)