draw() is the single low-level entry point for every rendering backend in
rtemis.draw. It is an S7 generic that dispatches on the option object – the
complete, validated render spec for one backend – so the right JS binding is
selected purely by type, with no ambiguity:
Usage
draw(
option,
theme = NULL,
width = NULL,
height = NULL,
element_id = NULL,
filename = NULL,
animation = NULL,
...
)Arguments
- option
EChartsOption, SigmaOption, or named list: Render spec to draw.
- theme
Optional Theme, list, or
NA: Theme override.NULLenables light/dark auto-detection;NAdisables theming. Applied to every backend.- width
Optional Character or Numeric: Widget width.
- height
Optional Character or Numeric: Widget height.
- element_id
Optional Character: Explicit element ID.
- filename
Optional Character: If provided, the widget is also written to this file via
save_drawing()(ECharts only; other backends reject static export requests). Extension determines the format (currently only.svg).- animation
Optional Logical: Whether ECharts animates the chart.
NULL(default) leaves ECharts' own default in place.FALSEdisables animation, which matters for charts with many points, where animating every interactive update is expensive. Ignored by the Sigma and MapLibre backends, which have no ECharts animation to disable.- ...
Backend-specific arguments, which must be named. ECharts accepts
renderer(Character {"canvas", "svg"}) andmeta(named list of extra payload fields, used internally e.g. bydraw_heatmap()). Any other name is an error rather than a silent no-op, so a typo cannot quietly change what is drawn.Two
metafields are read by the ECharts JS binding and are part of its contract, because they need the container width, which only the browser knows:squareCells: seedraw_heatmap().aspect: a named list withratio(required grid height / grid width),widthPx(preferred grid width; the box shrinks below this only when the container is too narrow), andleftPx,rightPx,topPx,botPx(padding to reserve outside the grid). The binding solves for the grid box on render and on resize, and sets the container height to match. Use it for charts whose pixel geometry carries meaning – most often equal axis scaling, where one data unit must be the same number of pixels on both axes andratiois therefore the y range over the x range. ECharts has no equal-aspect option, and R cannot know the container width, so neither side can enforce this alone.
Details
EChartsOption -> ECharts (
rtemis-drawwidget)SigmaOption -> Sigma.js (
rtemis-graphwidget)
A plain named list is treated as a raw ECharts option (back-compatible with
the original draw()).
Theme handling is uniform across backends and lives on draw(), not on the
option object: pass NULL (default) for light/dark auto-detection (from VS
Code, RStudio, or the browser's prefers-color-scheme), NA for no theme
(raw backend defaults), or a Theme / list to force one.