plotting/lib.rs
1//! Chart intermediate representation plus renderers for the three report
2//! kinds (Balance, Activity, Category Breakdown).
3//!
4//! Consumers select a renderer through features:
5//!
6//! - `svg` pulls `plotters::SVGBackend` and exposes [`svg::render_svg`].
7//! Implies `adapters`.
8//! - `canvas` pulls `plotters-canvas` and exposes
9//! [`canvas::render_canvas`] for `wasm32` targets. Does **not** imply
10//! `adapters` — canvas consumers receive a pre-built [`ChartSpec`]
11//! over JSON.
12//! - `ratatui` exposes [`ratatui::render_ratatui`] for the TUI.
13//! Implies `adapters`.
14//! - `kitty` rasterises the same spec to PNG and emits a kitty
15//! graphics APC escape sequence via [`kitty::render_kitty`]. Implies
16//! `adapters`.
17//!
18//! Everything shares the [`spec::ChartSpec`] intermediate representation.
19//! When `adapters` is enabled, [`adapters`] builds specs from server
20//! view projections; otherwise consumers construct specs directly (the
21//! WASM client does this by deserialising JSON from the server).
22
23#[cfg(feature = "adapters")]
24pub mod adapters;
25pub mod spec;
26
27#[cfg(any(feature = "svg", feature = "canvas", feature = "kitty"))]
28pub(crate) mod draw;
29
30// Native only: on wasm32 the canvas backend shapes text through the browser, and
31// plotters gates `register_font` out of that target entirely.
32#[cfg(all(
33 not(target_arch = "wasm32"),
34 any(feature = "svg", feature = "canvas", feature = "kitty")
35))]
36pub(crate) mod font;
37
38#[cfg(feature = "svg")]
39pub mod svg;
40
41#[cfg(feature = "canvas")]
42pub mod canvas;
43
44#[cfg(feature = "ratatui")]
45pub mod ratatui;
46
47#[cfg(feature = "text")]
48pub mod text;
49
50#[cfg(feature = "kitty")]
51pub mod kitty;
52
53pub use spec::{ChartKind, ChartSpec, Series, SeriesPoint};