Created
April 12, 2017 21:56
-
-
Save cpsievert/5b0bb95260e4fd890de37ae620e11c4a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(crosstalk) | |
library(htmltools) | |
m <- SharedData$new(mtcars) | |
set_values <- function(w, sharedData, values) { | |
script <- sprintf( | |
"HTMLWidgets.addPostRenderHandler(function() { return crosstalk.group('%s').var('%s').set(%s); })", | |
sharedData$groupName(), "filter", jsonlite::toJSON(values) | |
) | |
# TODO: attach htmlwidgets dependency to w? | |
browsable(tagList( | |
tags$head(tags$script(script)), w | |
)) | |
} | |
s <- set_values( | |
filter_select("id", "Select a car", m, m$key()), | |
m, row.names(mtcars)[1:4] | |
) | |
bscols(s, plotly::plot_ly(m, x = ~wt, y = ~mpg)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment