shiny-setters {vegawidget} | R Documentation |
Set information in a Vega chart from Shiny
Description
There are two ways to change a Vega chart: by setting
a signal or by setting a dataset; you can also
direct a Vega chart to re-run itself. Any signal or
dataset you set must first be defined and named in the vegaspec.
These functions are called from within
a Shiny server()
function, where they act like
shiny::observe()
or shiny::observeEvent()
.
Usage
vw_shiny_set_signal(outputId, name, value, run = TRUE, ...)
vw_shiny_set_data(outputId, name, value, run = TRUE, ...)
vw_shiny_run(outputId, value, ...)
Arguments
outputId |
|
name |
|
value |
reactive expression, e.g. |
run |
|
... |
other arguments passed on to |
Details
To see these functions in action, you can run a shiny-demo:
-
vw_shiny_set_signal()
: callvw_shiny_demo("signal-set-get")
-
vw_shiny_set_data()
: callvw_shiny_demo("data-set-get")
-
vw_shiny_run()
: callvw_shiny_demo("data-set-swap-run")
For the signal and data setters, in addition to the chart outputId
,
you will need to provide:
the
name
of the signal or dataset you wish to keep updatedthe
value
to which you want to set the signal or dataset; this should be a reactive expression likeinput$slider
orrct_dataset()
whether or not you want to
run
the Vega view again immediately after setting this value
If you do not set run = TRUE
in the setter-function,
you can use the vw_shiny_run()
function to control when
the chart re-runs. One possibility is to set its value
to a reactive
expression that refers to, for example, a shiny::actionButton()
.
Value
shiny::observeEvent()
function that responds to changes in the
reactive-expression value