Exports a widget created by draw() (or any of the draw_*
functions) to a static file. Supports .svg for ECharts, Sigma networks,
MapLibre maps, and Pele diagrams via Node.js server-side rendering, including
complete draw_panels() figures. Requires
a Node.js (>= 18) node binary on PATH.
Arguments
- widget
htmlwidget: A widget returned by
draw()or adraw_*function.- filename
Character scalar: Nonempty output path with an extension.
- width
Optional Numeric scalar
(0, Inf): Finite image width in pixels. Unset uses the widget's numeric width, or 800 for a relative/unspecified width.- height
Optional Numeric scalar
(0, Inf): Finite image height in pixels. Unset uses the widget's numeric height, or 600 for a relative/unspecified height.
Details
Zoom controls (sliders and inside zoom) and toolbox buttons are omitted, and
the band reserved for a zoom slider returns to the plot; the export shows the
full data range. Callbacks under tooltips and axis pointers are omitted.
Other JavaScript callbacks are rejected because discarding them
could change visible content. Built-in Gantt, dendrogram, and boxplot point renderers are
shared with the browser widget and use JSON parameters. Networks share their
deterministic layout and styles with the interactive widget. Maps share
geometry, location joins, and color scales and use a Mercator projection.
Exports show the initial configured view; browser camera changes and hover
states are not stored in the R widget. SVG text remains editable. Network
labels are fitted to the page and suppressed when they overlap. Diagrams
export at their natural size, so width and height do not apply to them;
their colors are written as literal values. Diagram labels are measured in
the first installed font of the theme's font stack, read with the
'systemfonts' package, and the file names that font followed by Helvetica.
When the stack reaches a generic family such as system-ui first, or
'systemfonts' is not installed, labels are measured and written in Helvetica
or a font with the same metrics.