Skip to main content

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//! - `kitty` rasterises the same spec to PNG and emits a kitty
13//!   graphics APC escape sequence via [`kitty::encode_png_apc`]. Implies
14//!   `adapters`.
15//!
16//! Everything shares the [`spec::ChartSpec`] intermediate representation.
17//! When `adapters` is enabled, [`adapters`] builds specs from server
18//! view projections; otherwise consumers construct specs directly (the
19//! WASM client does this by deserialising JSON from the server).
20
21#[cfg(feature = "adapters")]
22pub mod adapters;
23pub mod spec;
24
25#[cfg(any(feature = "svg", feature = "canvas", feature = "kitty"))]
26pub(crate) mod draw;
27#[cfg(any(feature = "svg", feature = "canvas", feature = "kitty"))]
28pub(crate) mod layout;
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 = "text")]
45pub mod text;
46
47#[cfg(feature = "kitty")]
48pub mod kitty;
49
50#[cfg(any(feature = "svg", feature = "canvas", feature = "kitty"))]
51pub use layout::DEFAULT_TEXT_PX;
52pub use spec::{ChartKind, ChartSpec, Series, SeriesPoint};