Skip to main content

ChartML

Struct ChartML 

Source
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

Source

pub fn new() -> Self

Create a new empty ChartML instance.

Source

pub fn with_defaults() -> Self

Create with default built-in plugins. (No built-in renderers — those come from chartml-chart-* crates)

Source

pub fn register_renderer( &mut self, chart_type: &str, renderer: impl ChartRenderer + 'static, )

Source

pub fn register_data_source( &mut self, name: &str, source: impl DataSource + 'static, )

Source

pub fn register_transform( &mut self, middleware: impl TransformMiddleware + 'static, )

Source

pub fn set_datasource_resolver( &mut self, resolver: impl DatasourceResolver + 'static, )

Source

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.

Source

pub fn register_source(&mut self, name: &str, data: DataTable)

Register a named source directly from a DataTable.

Source

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.

Source

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.

Source

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.

Source

pub fn render_chart( &self, chart_spec: &ChartSpec, ) -> Result<ChartElement, ChartError>

Render a parsed ChartSpec into a ChartElement tree.

Source

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.

Source

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.

Source

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.

Source

pub fn registry(&self) -> &ChartMLRegistry

Get a reference to the internal registry.

Source

pub fn registry_mut(&mut self) -> &mut ChartMLRegistry

Get a mutable reference to the internal registry.

Trait Implementations§

Source§

impl Default for ChartML

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.