new_plot_block | R Documentation |
Blocks for data visualization using base R graphics can be created via
new_plot_block()
.
new_plot_block(server, ui, class, ctor = sys.parent(), ...)
new_scatter_block(x = character(), y = character(), ...)
server |
A function returning |
ui |
A function with a single argument ( |
class |
Block subclass |
ctor |
String-valued constructor name or function/frame number (mostly for internal use or when defining constructors for virtual classes) |
... |
Forwarded to |
x , y |
Columns to place on respective axes |
Due to the current block evaluation procedure, where block evaluation is
separated from block "rendering" (via shiny::renderPlot()
) integration of
base R graphics requires some mechanism to achieve this decoupling. This
is implemented by adding a plot
attribute to the result of
block_eval()
, generated with grDevices::recordPlot()
and containing the
required information to re-create the plot at a later time. As part of
block_output()
, the attribute is retrieved and passed to
grDevices::replayPlot()
. Consequently, any block that inherits from
plot_block
is required to support this type of decoupling.
All blocks constructed via new_plot_block()
inherit from
plot_block
.
Mainly for demonstration purposes, this block draws a scattter plot using
base::plot()
. In its current simplistic implementation, apart from axis
labels (fixed to the corresponding column names), no further plotting
options are available and for any "production" application, a more
sophisticated (set of) block(s) for data visualization will most likely be
required.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.