Skip to main content

render_canvas

Function render_canvas 

Source
pub fn render_canvas(
    spec: &ChartSpec,
    canvas: &HtmlCanvasElement,
) -> Result<(), JsValue>
Expand description

Render spec into canvas via plotters-canvas. Sizes the backing canvas to device_pixel_ratio so the chart stays crisp on HiDPI screens; the caller is expected to set the CSS width/height to the logical size before calling.

ยงErrors

Returns Err(JsValue) when the canvas element cannot be wrapped (missing 2D context or the shared drawing dispatch fails).