macro_rules! chart {
(&$ds:expr) => { ... };
($ds:expr) => { ... };
($( $(&)? $col:ident ),+ $(,)?) => { ... };
(@parse_col $res:ident, &$name:ident) => { ... };
(@parse_col $res:ident, $name:ident) => { ... };
}Expand description
A convenience macro to initialize a [Chart] with data.
The chart! macro supports two primary usage patterns:
§1. Direct Variable Mapping (Auto-Stringify)
Pass one or more local variables. The macro will automatically use the
variable names as column names in the underlying [Dataset].
ⓘ
let x = vec![1.0, 2.0, 3.0];
let y = vec![10.0, 20.0, 30.0];
// This creates a Dataset with columns "x" and "y"
chart!(x, y)?
.mark_point()?
.encode((alt::x("x"), alt::y("y")))?
.save("out.svg")?;§2. Existing Dataset
Pass a pre-constructed [Dataset] directly into the macro.
ⓘ
let ds = get_data_from_source()?;
chart!(ds)?
.mark_line()?
.encode((alt::x("x"), alt::y("y")))?
.save("out.svg")?;§Errors
Returns [ChartonError::Data] if the provided variables have inconsistent
row lengths when building a new dataset.
§Panics
The macro itself does not panic, but it propagates errors via the ? operator.