rdom_charts/lib.rs
1//! # rdom-charts
2//!
3//! Terminal charts for [rdom](https://github.com/miskun/rdom), the
4//! browser-faithful DOM for terminal applications: a time-series line
5//! chart, a sparkline, a bar chart, and a rich gauge.
6//!
7//! Each chart paints onto a `<canvas>` element through rdom-tui's public
8//! API — sub-cell rasterized (a 2×4 **braille** dot grid for lines, eighth
9//! **block** glyphs for bars) — and never reaches into rdom internals, so
10//! the crate evolves independently of the substrate. A `*View` handle
11//! mounts a chart on a canvas and lets the app update it between frames:
12//!
13//! ```no_run
14//! use rdom_charts::{Series, DataPoint, TimeSeriesChart, TimeSeriesView};
15//! use rdom_tui::TuiDom;
16//!
17//! let chart = TimeSeriesChart::new_static(vec![Series::line(
18//! "cpu",
19//! (0..120).map(|i| DataPoint::new(i as f64, (i as f64 * 0.1).sin() * 40.0 + 50.0)).collect(),
20//! )]);
21//! let view = TimeSeriesView::new(chart);
22//! let mut dom = TuiDom::new();
23//! let canvas = view.mount(&mut dom); // a <canvas> NodeId — append + size it
24//! # let _ = canvas;
25//! ```
26//!
27//! Components: [`TimeSeriesChart`] / [`TimeSeriesView`] (with [`Guideline`]
28//! threshold lines, EMA smoothing, follow/zoom/pan), [`Sparkline`],
29//! [`BarChart`], [`Gauge`] (+ [`GaugeZone`]). See the `examples/` for
30//! runnable demos.
31
32#![deny(missing_docs)]
33
34mod chart;
35pub mod palette;
36
37pub use chart::{
38 Bar, BarChart, BarChartView, ConnectPolicy, DataPoint, Gauge, GaugeView, GaugeZone, Guideline,
39 Series, SeriesStyle, Sparkline, SparklineView, TimeRange, TimeSeriesChart, TimeSeriesView,
40 XAxisConfig, YAxisConfig,
41};