facett_plotters/lib.rs
1//! **facett-plotters** — the chart types [`egui_plot`](https://docs.rs/egui_plot)
2//! (→ `facett-plot`) *lacks*, painted in **immediate mode** directly on an
3//! [`egui::Painter`]. `egui_plot` already covers line/scatter/bar/histogram with
4//! zoom/pan; this crate adds a self-contained, theme-categorical [`ChartView`]
5//! (line/bar/scatter with a derived legend/axes/tooltip, no `egui_plot` dep) plus
6//! the analytics long-tail Plotly defines:
7//!
8//! - [`ChartView`] — line/bar/scatter over named series, series-coloured from the
9//! validated [categorical palette](palette) in fixed slot order
10//! - [`BoxPlotView`] — quartiles + 1.5·IQR whiskers + outliers
11//! - [`ViolinView`] — Gaussian-KDE density silhouette
12//! - [`HeatmapView`] — a matrix as a colour grid with a gradient legend
13//! - [`CandlestickView`] — OHLC bars (wick + body)
14//! - [`TreemapView`] — weighted slice-and-dice rectangles
15//!
16//! ## Why hand-rolled, not the `plotters` crate
17//! The `plotters` crate is **retained + raster/SVG-backend driven**: its egui
18//! integration renders to a bitmap and blits a texture every frame, with no
19//! immediate-mode hit-testing, no live theming, and no hover model. facett's
20//! charts must read [`facett_core::theme`] live (re-skin on theme switch),
21//! expose cheap hover-readouts, and implement the [`Facet`](facett_core::Facet)
22//! contract (`caps()` + `copy()` → CSV). Hand-painting on the egui `Painter`
23//! (the same path `facett-core`/`facett-map` use) is the lighter, better-fitting
24//! choice — so `plotters` is *not* a dependency.
25//!
26//! ## Theme-derived colour ramps
27//! No palette is hardcoded. [`ramp::Ramp`] builds a **sequential**
28//! (`bg`→`accent`→`glow`) or **diverging** (`accent`→`text_dim`→`glow`) ramp
29//! purely from the active [`Theme`](facett_core::Theme), so heatmaps/treemaps
30//! follow whatever theme is set.
31//!
32//! Each view is a [`Facet`](facett_core::Facet): it declares
33//! `caps().themeable().copyable().resizable()`, paints itself, and `copy()`
34//! emits the underlying data as CSV. The data→geometry math (quartiles, KDE
35//! bins, OHLC mapping, heatmap cell layout, treemap squarify) lives in **pure,
36//! tested functions** that need no GPU.
37
38pub mod boxplot;
39pub mod candlestick;
40pub mod chart;
41pub mod heatmap;
42pub mod palette;
43pub mod ramp;
44pub mod treemap;
45pub mod violin;
46
47pub use boxplot::{BoxPlotEffect, BoxPlotMsg, BoxPlotState, BoxPlotView, Quartiles};
48pub use chart::{ChartEffect, ChartKind, ChartMsg, ChartState, ChartView, Series};
49pub use palette::{series_color, series_palette};
50pub use candlestick::{
51 CandlestickEffect, CandlestickMsg, CandlestickState, CandlestickView, Ohlc, OhlcLayout,
52};
53pub use heatmap::{HeatmapEffect, HeatmapMsg, HeatmapState, HeatmapView};
54pub use ramp::Ramp;
55pub use treemap::{Tile, TreemapEffect, TreemapMsg, TreemapState, TreemapView};
56pub use violin::{Density, ViolinEffect, ViolinMsg, ViolinState, ViolinView};