Standard htmlwidgets output/render helpers so a vellumwidget widget can appear in
a Shiny app or an interactive R Markdown document.
Usage
vellumwidgetOutput(outputId, width = "100%", height = "400px")
renderVellumwidget(expr, env = parent.frame(), quoted = FALSE)Value
vellumwidgetOutput(): a Shiny output UI element. renderVellumwidget(): a Shiny
render function.
Reading interactions server-side
A widget rendered as vellumwidgetOutput("plot") reports the user's interactions back
to the server as reactive inputs, keyed by the output id. All values are the
element data keys (the data_id a vellumplot mark declares); map them back to
your data by that key.
input$plot_selectedCharacter vector of the currently selected keys (click / brush / keyboard, and any selection arriving from a linked widget). Updates as state — re-selecting the same set is a no-op.
character(0)when nothing is selected.input$plot_clickA list
list(key=)for each click;keyisNULLfor a click on empty space. An event input — fires on every click, even the same mark twice.input$plot_hoverThe hovered key, or
NULLwhen the pointer leaves a mark. Updates as state (re-fires only when the hovered key changes).input$plot_brushA list
list(keys=, x0=, y0=, x1=, y1=)when a brush (or lasso) gesture completes: the selected keys and the region's bounding rectangle in the scene's device-pixel (viewBox) coordinates. A lasso gesture also carrieslasso = TRUE. When the plot carries a cartesian scale (avellumplotplot), it also carries the region's data-space boundsx0d,y0d,x1d,y1dand thepanelname. An event input.input$plot_colorfilterA length-2 numeric
c(lo, hi)— the value range selected on a continuous colorbar (see the interactive colorbar filter);NULLwhen the full range is shown. State input.input$plot_zoomA list
list(x=, y=, w=, h=, zoomed=)— the current view (the SVGviewBoxin device-pixel coordinates) plus azoomedflag (is the view narrower/shorter than the full extent). For a single-panel cartesian plot it also carriesdata = list(x=c(lo,hi), y=c(lo,hi), panel=), the visible range in data coordinates. Updates as state when a zoom/pan settles (wheel, drag-pan release, pinch, keyboard, reset, zoom-to-selection, or a proxyvw_zoom()).
Data-space coordinates (x0d/… and zoom$data) come from the per-panel scale
descriptors vellumplot attaches to the scene; a raw vellum scene or a
non-cartesian coordinate system carries none, and only the device-pixel fields
are reported. Some specifics:
They describe the visual axes:
x0d/x1d(andzoom$data$x) are the horizontal axis. Undercoord_flip()that is the plot'syaesthetic.Date/time axes report the numeric epoch (days for
Date, seconds forPOSIXct); map back withas.Date()/.POSIXct().A discrete axis reports fractional band positions (category i sits at
i), not the level labels.Axes built with a custom
scales::transform_*()object (anything beyond identity / log10 / sqrt / reverse) can't be inverted client-side, so that axis is omitted from the data-space fields (device-pixel fields still report).
These are emitted only inside a live Shiny session; a static render (knitr,
pkgdown, htmltools::save_html()) produces identical output and no input
traffic. To drive the widget from the server — set the selection, cross-filter
it, or zoom it without a re-render — use vellumwidget_proxy().
