Expand description
Server-side ChartML rendering: spec → ChartElement → SVG → PNG.
This crate provides the final rendering step for chartml-rs, converting ChartElement trees into static PNG images without requiring a browser, DOM, or JavaScript runtime.
§Features
- SVG serialization (always available): converts
ChartElementtrees to SVG strings - PNG rasterization (requires
rasterizefeature, enabled by default): converts SVG to PNG
§Usage
use chartml_core::ChartML;
use chartml_render::render_to_png;
let chartml = ChartML::new();
// ... register renderers ...
let yaml = r#"
type: chart
version: 1
data:
provider: inline
rows:
- { x: "A", y: 10 }
- { x: "B", y: 20 }
visualize:
type: bar
columns: x
rows: y
"#;
let png_bytes = render_to_png(&chartml, yaml, 800, 400, 72).unwrap();Re-exports§
pub use error::RenderError;pub use rasterize::svg_to_png;pub use svg::element_to_svg;
Modules§
- error
- rasterize
- SVG string → PNG bytes rasterization using resvg.
- svg
- ChartElement tree → SVG string serialization.
Functions§
- element_
to_ png - Render a pre-built ChartElement tree to PNG bytes.
- render_
to_ png - Render a ChartML YAML spec to PNG bytes (synchronous).
- render_
to_ png_ async - Render a ChartML YAML spec to PNG bytes (async).