encodePlotAs {shinylight}R Documentation

Renders a plot as a base64-encoded PNG

Description

The result can be set as the src attribute of an <img> element in HTML.

Usage

encodePlotAs(format, plotFn)

Arguments

format

An object specifying the output, with the following members: format$type is "png", "pdf" or "csv", and format$width and format$height are the dimensions of the PDF (in inches) or PNG (in pixels) if appropriate.

plotFn

Function to call to perform the plot

Details

You will not need to call this function unless you want to return more than one plot per call, as the last plot produced will be returned in the plot property of the result from shinylight.call anyway.

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.

A list with an element named plot containing the plot encoded as required either for an HTML image element's src attribute, or a element's href attribute. If the function returns a matrix or data frame, this will be returned in the list's data element.

See Also

rrpcServer

Examples

pdf <- encodePlotAs(list(type="pdf", width=7, height=8), function() {
  barplot(c(1, 2, 3, 4))
})
grDevices::png()  # workaround; you do not have to do this

[Package shinylight version 1.2 Index]