inst/examples/proxy-update-serie-line.R

#  ------------------------------------------------------------------------
#
# Title : Update serie
#    By : Victor
#  Date : 2018-09-09
#
#  ------------------------------------------------------------------------



library(shiny)
library(apexcharter)



ui <- fluidPage(
  tags$h2("Radomly update serie"),
  apexchartOutput(outputId = "graph", width = "600px"),
  actionButton(inputId = "update", label = "Update data")
)

server <- function(input, output, session) {
  
  output$graph <- renderApexchart({
    apexchart() %>% 
      ax_chart(type = "line") %>% 
      ax_plotOptions(line = list(curve = "smooth")) %>% 
      ax_dataLabels(enabled = FALSE) %>% 
      ax_series(
        list(
          name = "rnorm",
          data = round(rnorm(20), 3)
        )
      )
  })
  
  observeEvent(input$update, {
    apexchartProxy(shinyId = "graph") %>% 
      ax_proxy_series(newSeries = list(data = round(rnorm(20), 3)))
  })
  
}

shinyApp(ui, server)

Try the apexcharter package in your browser

Any scripts or data that you put into this service are public.

apexcharter documentation built on July 9, 2023, 7:55 p.m.