vol_widget: Render a payload as a widget

View source: R/widget.R

vol_widgetR Documentation

Render a payload as a widget

Description

Puts the viewer in an R Markdown document, a shiny application or the RStudio viewer, driving the same page that vol_standalone() writes.

Usage

vol_widget(
  payload,
  options = list(),
  panel = TRUE,
  width = NULL,
  height = NULL,
  elementId = NULL,
  inputId = NULL
)

Arguments

payload

A vol_payload, or the path of a payload directory.

options

Named list of viewer settings applied once the page has loaded. Any state key the page carries is reachable; see Details.

panel

Logical. Draw the control panel of the page, which is the default and is what shinyVolumr() shows, or hide it and leave the controls to the host, which is what a figure in a document wants.

width, height

Widget size, passed to htmlwidgets.

elementId

Optional element identifier.

inputId

Identifier under which the widget reports back to shiny. Set it to the output identifier when the widget is rendered with render_vol_widget(), so that the events below reach the server.

Details

Render a payload as a widget

The widget hosts the viewer in a frame of its own and talks to it with messages, so there is one renderer behind the file, the widget and the application, and no second copy to keep in step.

The settings options accepts are the ones the panel exposes: the camera as azim, elev, dist, panX and panY; the colour scale as vmin, vmax, gamma and cmapRow; the density as od and ow; the geometry as zex, d0, d1, x0, x1, y0, y1 and ortho; the depth slab as slab, slabT, slabZ and slabNorm; the motions as spin and sweep; the quality as steps and adaptive; and the appearance as light, showLand, showBox and panel.

Inside shiny the widget reports three events through shiny::observeEvent(): ⁠<inputId>_ready⁠ when the payload has loaded, carrying the grid and the depth span; ⁠<inputId>_camera⁠ whenever the camera settles; and ⁠<inputId>_snapshot⁠ when a snapshot has been taken.

Value

An object of class htmlwidget.

See Also

vol_payload() for the payload, vol_widget_output() and render_vol_widget() for the shiny pair, vol_snapshot() to save a PNG from the server, shinyVolumr() for the whole workflow.

Examples

w <- vol_widget(vol_example_payload(),
                options = list(slab = TRUE, slabT = 25, slabZ = 50))
class(w)
if (interactive()) w

volumr documentation built on Dec. 2, 2026, 5:07 p.m.