Learn R Programming

dqshiny (version 0.0.3)

dq_render_svg: Render ggplot2 figure as svg

Description

Returns ggplot2 svg image for shiny::imageOutput

Usage

dq_render_svg(gg, path = NULL, width = 1200, height = 500,
  alt = "", pdf = FALSE, png = FALSE, delete_file = TRUE)

Arguments

gg

reactive or non-reactive ggplot2 object

path

directory where images are stored (optional, default = NULL, creates tmp files)

width

plot width (optional, default = 1200)

height

plot height (optional, default = 500)

alt

alternative image title (optional, default = "")

pdf

boolean variable controlling if pdf output is generated (optional, default = FALSE)

png

boolean variable controlling if png output is generated (optional, default = FALSE)

delete_file

parameter for shiny::renderImage function

Value

list containing ggplot2 figure information

Examples

Run this code
# NOT RUN {
## Only run examples in interactive R sessions
if (interactive()) {

library(shiny)
shinyApp(
  ui = fluidPage(
    selectInput("select","Number of bars", choices=c(4,5,6)),
    br(),
    imageOutput("plot")
  ),
  server = function(input, output) {
    gf <- reactive({L <- as.integer(input$select)
                    gg <- ggplot2::ggplot(data=data.frame(x=seq(L), y=seq(L)),
                      ggplot2::aes(x=x, y=y)) + ggplot2::geom_bar(stat = "identity")
    })
    output$plot <- dq_render_svg(gf)
  }
)

}
# }

Run the code above in your browser using DataLab