Learn R Programming

shinylight (version 1.1.2)

encodePlot: Renders a plot as a base64-encoded image

Description

Renders a plot as a base64-encoded image

Usage

encodePlot(device, mimeType, width, height, plotFn)

Value

list with two keys, whose values can each be NULL: 'plot' is a plot in HTML img src form and 'data' is a data frame or other non-plot result.

Arguments

device

Graphics device function, such as grDevices::png or grDevices::pdf

mimeType

Mime type for the data produced by device

width

Width of the plot in units applicable to device

height

Height of the plot in units applicable to device

plotFn

Function to call to perform the plot

Examples

Run this code
pdf <- encodePlot(grDevices::png, "image/png", 200, 300, function() {
  barplot(c(1, 2, 3, 4))
})
grDevices::png()  # workaround; you do not have to do this

Run the code above in your browser using DataLab