robs_update {robservable} | R Documentation |
Update robservable
through robservableProxy
Description
Update robservable
through robservableProxy
Usage
robs_update(robs = NULL, ...)
Arguments
robs |
|
... |
named arguments to represent variables or inputs to update |
Value
robservable_proxy
Examples
if(interactive()) {
# change color with update through proxy
library(shiny)
library(robservable)
ui <- tagList(
robservableOutput("bar")
)
server <- function(input, output, session) {
robs <- robservable(
"@d3/bar-chart",
include = "chart",
input = list(color = "red", height = 700)
)
output$bar <- renderRobservable({
robs
})
# set up a proxy to our bar robservable instance
# for later manipulation
robs_proxy <- robservableProxy("bar")
observe({
invalidateLater(2000, session)
# update with random color
robs_update(
robs_proxy,
color = paste0(
"rgb(",
paste0(col2rgb(colors()[floor(runif(1,1,length(colors())))]),collapse=","),
")"
)
)
})
}
shinyApp(ui, server)
# change data using update with proxy
library(shiny)
library(robservable)
ui <- tagList(
actionButton("btnChangeData", "Change Data"),
robservableOutput("bar")
)
server <- function(input, output, session) {
robs <- robservable(
"@d3/bar-chart",
include = "chart",
input = list(color = "red", height = 700)
)
output$bar <- renderRobservable({
robs
})
# set up a proxy to our bar robservable instance
# for later manipulation
robs_proxy <- robservableProxy("bar")
observeEvent(input$btnChangeData, {
robs_update(
robs_proxy,
data = data.frame(
name = LETTERS[1:10],
value = round(runif(10)*100)
)
)
})
}
shinyApp(ui, server)
# add an observer through proxy
library(shiny)
library(robservable)
ui <- tagList(
robservableOutput("bar")
)
server <- function(input, output, session) {
robs <- robservable(
"@d3/bar-chart",
include = "chart",
input = list(color = "red", height = 700)
)
output$bar <- renderRobservable({
robs
})
# set up a proxy to our bar robservable instance
# for later manipulation
robs_proxy <- robservableProxy("bar")
robs_observe(robs_proxy, "color")
observeEvent(input$bar_color, {
print(input$bar_color)
})
observe({
invalidateLater(2000, session)
# update with random color
robs_update(
robs_proxy,
color = paste0(
"rgb(",
paste0(col2rgb(colors()[floor(runif(1,1,length(colors())))]),collapse=","),
")"
)
)
})
}
shinyApp(ui, server)
}
[Package robservable version 0.2.2 Index]