Skip to main content

Crate chartml_render

Crate chartml_render 

Source
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 ChartElement trees to SVG strings
  • PNG rasterization (requires rasterize feature, 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).