Learn R Programming

g2r (version 0.1.0)

change-size: Change Size

Description

Change size of chart.

Usage

change_size(proxy, width, height)

change_width(proxy, width)

change_height(proxy, height)

Arguments

proxy

A g2r proxy as returned by g2Proxy

width, height

New dimensions of chart.

Examples

Run this code
# NOT RUN {
library(shiny)

ui <- fluidPage(
  sliderInput("width", "width", min = 100, max = 700, value = 250),
  g2Output("chart")
)

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

  observeEvent(input$width, {
    g2Proxy("chart") %>% 
      change_width(input$width)
  })
}

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

Run the code above in your browser using DataLab