pub struct ChartML { /* private fields */ }Expand description
Main ChartML instance. Orchestrates parsing, data fetching, and rendering. Maintains source and parameter registries that persist across render calls, matching the JS ChartML class behavior.
Implementations§
Source§impl ChartML
impl ChartML
Sourcepub fn with_defaults() -> Self
pub fn with_defaults() -> Self
Create with default built-in plugins. (No built-in renderers — those come from chartml-chart-* crates)
pub fn register_renderer( &mut self, chart_type: &str, renderer: impl ChartRenderer + 'static, )
pub fn register_data_source( &mut self, name: &str, source: impl DataSource + 'static, )
pub fn register_transform( &mut self, middleware: impl TransformMiddleware + 'static, )
pub fn set_datasource_resolver( &mut self, resolver: impl DatasourceResolver + 'static, )
Sourcepub fn register_component(&mut self, yaml: &str) -> Result<(), ChartError>
pub fn register_component(&mut self, yaml: &str) -> Result<(), ChartError>
Register a non-chart component (source, style, config, params) from a YAML string.
Sources are stored in the instance and available to all subsequent render calls.
This matches the JS chartml.registerComponent(spec) API.
Sourcepub fn register_source(&mut self, name: &str, data: DataTable)
pub fn register_source(&mut self, name: &str, data: DataTable)
Register a named source directly from a DataTable.
Sourcepub fn render_from_yaml(&self, yaml: &str) -> Result<ChartElement, ChartError>
pub fn render_from_yaml(&self, yaml: &str) -> Result<ChartElement, ChartError>
Parse a YAML string and render the chart component(s). Returns the ChartElement tree. Uses default dimensions (800x400) unless the spec overrides them.
Sourcepub fn render_from_yaml_with_size(
&self,
yaml: &str,
container_width: Option<f64>,
container_height: Option<f64>,
) -> Result<ChartElement, ChartError>
pub fn render_from_yaml_with_size( &self, yaml: &str, container_width: Option<f64>, container_height: Option<f64>, ) -> Result<ChartElement, ChartError>
Parse a YAML string and render with an explicit container size.
container_width overrides the default width (used when the spec doesn’t specify one).
container_height overrides the default height.
Sourcepub fn render_from_yaml_with_params(
&self,
yaml: &str,
container_width: Option<f64>,
container_height: Option<f64>,
param_overrides: Option<&ParamValues>,
) -> Result<ChartElement, ChartError>
pub fn render_from_yaml_with_params( &self, yaml: &str, container_width: Option<f64>, container_height: Option<f64>, param_overrides: Option<&ParamValues>, ) -> Result<ChartElement, ChartError>
Render with explicit param value overrides.
param_overrides are current interactive values that take priority over defaults.
Sourcepub fn render_chart(
&self,
chart_spec: &ChartSpec,
) -> Result<ChartElement, ChartError>
pub fn render_chart( &self, chart_spec: &ChartSpec, ) -> Result<ChartElement, ChartError>
Render a parsed ChartSpec into a ChartElement tree.
Sourcepub fn render_chart_with_size(
&self,
chart_spec: &ChartSpec,
container_width: Option<f64>,
container_height: Option<f64>,
) -> Result<ChartElement, ChartError>
pub fn render_chart_with_size( &self, chart_spec: &ChartSpec, container_width: Option<f64>, container_height: Option<f64>, ) -> Result<ChartElement, ChartError>
Render a parsed ChartSpec with explicit container dimensions. Spec-level width/height take priority; container size is the fallback.
Sourcepub async fn render_from_yaml_with_params_async(
&self,
yaml: &str,
container_width: Option<f64>,
container_height: Option<f64>,
param_overrides: Option<&ParamValues>,
) -> Result<ChartElement, ChartError>
pub async fn render_from_yaml_with_params_async( &self, yaml: &str, container_width: Option<f64>, container_height: Option<f64>, param_overrides: Option<&ParamValues>, ) -> Result<ChartElement, ChartError>
Async render with full parameter support — mirrors render_from_yaml_with_params
but uses the registered TransformMiddleware for ALL transforms (sql, aggregate, forecast).
Falls back to built-in sync transform only if no middleware is registered.
Sourcepub async fn render_from_yaml_with_data_async(
&self,
yaml: &str,
data: DataTable,
) -> Result<ChartElement, ChartError>
pub async fn render_from_yaml_with_data_async( &self, yaml: &str, data: DataTable, ) -> Result<ChartElement, ChartError>
Async render with external data — for integration tests and programmatic use. Data is used as fallback when spec has empty inline rows.
Sourcepub fn registry(&self) -> &ChartMLRegistry
pub fn registry(&self) -> &ChartMLRegistry
Get a reference to the internal registry.
Sourcepub fn registry_mut(&mut self) -> &mut ChartMLRegistry
pub fn registry_mut(&mut self) -> &mut ChartMLRegistry
Get a mutable reference to the internal registry.