dq_render_svg: Render ggplot2 figure as svg

Description Usage Arguments Value Author(s) Examples

View source: R/dq_render_svg.R

Description

Returns ggplot2 svg image for shiny::imageOutput

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
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

Author(s)

david.breuer

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
## 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)
  }
)

}

daqana/dqshiny documentation built on Sept. 1, 2020, 4:31 p.m.