new_plot_block {blockr.core} | R Documentation |
Plot block constructors
Description
Blocks for data visualization using base R graphics can be created via
new_plot_block()
.
Usage
new_plot_block(server, ui, class, ctor = sys.parent(), ...)
new_scatter_block(x = character(), y = character(), ...)
Arguments
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 |
Details
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.
Value
All blocks constructed via new_plot_block()
inherit from
plot_block
.
Scatter 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.