Proxy to dynamically interact with the chart in shiny.
g2_proxy(id, ..., data = NULL, session = shiny::getDefaultReactiveDomain())
id | Id of chart to interact with. |
---|---|
... | Aspects, see |
data | Data.frame containing data to plot. |
session | A valid shiny session. |
library(shiny) dataset <- data.frame(x = 1:100, y = runif(100, 1, 100)) ui <- fluidPage( g2Output("plot"), actionButton("add", "Add figure") ) server <- function(input, output, session) { output$plot <- renderG2({ g2(dataset, asp(x, y)) %>% fig_point() }) observeEvent(input$add, { df <- data.frame(x = 1:100, y = runif(100, 1, 100)) g2_proxy("plot", data = df) %>% fig_point(asp(x, y)) %>% render() }) } if (interactive()) { shinyApp(ui, server) }