Expand description
ChartModel<T> — concrete reactive multi-series chart data model.
ChartModel<T> owns an ordered collection of named series, each holding a
Vec<ChartDatum<T>> (a category: T paired with a numeric value: f32),
in a flat SlotMap arena — the same shape as crate::TreeModel. Every
mutation (series add/remove/move/rename/recolor/show-hide, point
push/insert/remove/update/replace) emits a ChartChange to all
registered observers and bumps one of two reactive version signals:
ChartModel::style_version (color changes only — a paint-only signal a
chart can bind at BindingLevel::RepaintOnly) or
ChartModel::structure_version (everything else — series/point shape,
bound at BindingLevel::Relayout/Rebuild). Series identity is a stable,
versioned SeriesId (a SlotMap key) that is never reused after removal.
Cloning produces a second handle to the same data — all handles share
series/points and receive the same change notifications. Register
observers via observe_changes; the
returned ObserverHandle is RAII — dropping it unregisters the callback.
For a bounded “last N points” streaming view use
ChartWindow. For bucketed/rolled-up display use
ChartAggregate. For point-level selection use
ChartSelection.
let model = ChartModel::from_series_vec(vec![
ChartSeries::new("Revenue").data(vec![
ChartDatum::new("Q1".to_string(), 10.0),
ChartDatum::new("Q2".to_string(), 20.0),
]),
]);
assert_eq!(model.series_count(), 1);
let s = model.series_id_at(0).unwrap();
assert_eq!(model.point_count(s), 2);
model.push_point(s, "Q3".to_string(), 30.0);
assert_eq!(model.point_count(s), 3);Structs§
- Chart
Datum - One numeric data point at a category/x-axis position, with an optional per-point color that overrides the series color (bar charts only).
- Chart
Model - A concrete reactive multi-series chart data model.
- Chart
Series - A named series of data points with an optional explicit color and a
visibility flag, used to construct a
ChartModel(viaChartModel::from_series_vec) or to describe one series’ desired shape. Unlike the model,visiblehere is a plainbool— reactivity lives in the model’sChartModel::structure_version/ChartModel::style_versionsignals, not in this construction DTO. - Series
View - A read-only, borrowed view over one series — returned by
ChartModel::with_series_view/ChartModel::with_all_series.