Learn R Programming

g2r (version 0.1.0)

convert: Convert

Description

Convert chart to a dataURL or an image.

Usage

to_dataURL(proxy)

download_image(proxy, name = "g2r")

Arguments

proxy

A g2r proxy as returned by g2Proxy

name

Name of file.

Examples

Run this code
# NOT RUN {
library(shiny)

ui <- fluidPage(
  actionButton("dl", "download"),
  g2Output("chart")
)

server <- function(input, output) {
  output$chart <- renderG2({
    g2(cars, asp(speed, dist)) %>% 
      fig_point()
  })

  observeEvent(input$dl, {
    g2Proxy("chart") %>% 
      download_image()
  })
}

# }
# NOT RUN {
shinyApp(ui, server)
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab