Your browser sucks, JavaScript disabled! Gunnar's console needs JavaScript and WebAssembly. Git over SSH on port 2222 does not.

nordisk/facett

facett-plotters/src/lib.rs

//! **facett-plotters** — the chart types [`egui_plot`](https://docs.rs/egui_plot)
//! (→ `facett-plot`) *lacks*, painted in **immediate mode** directly on an
//! [`egui::Painter`]. `egui_plot` already covers line/scatter/bar/histogram with
//! zoom/pan; this crate adds a self-contained, theme-categorical [`ChartView`]
//! (line/bar/scatter with a derived legend/axes/tooltip, no `egui_plot` dep) plus
//! the analytics long-tail Plotly defines:
//!
//! - [`ChartView`] — line/bar/scatter over named series, series-coloured from the
//!   validated [categorical palette](palette) in fixed slot order
//! - [`BoxPlotView`] — quartiles + 1.5·IQR whiskers + outliers
//! - [`ViolinView`] — Gaussian-KDE density silhouette
//! - [`HeatmapView`] — a matrix as a colour grid with a gradient legend
//! - [`CandlestickView`] — OHLC bars (wick + body)
//! - [`TreemapView`] — weighted slice-and-dice rectangles
//!
//! ## Why hand-rolled, not the `plotters` crate
//! The `plotters` crate is **retained + raster/SVG-backend driven**: its egui
//! integration renders to a bitmap and blits a texture every frame, with no
//! immediate-mode hit-testing, no live theming, and no hover model. facett's
//! charts must read [`facett_core::theme`] live (re-skin on theme switch),
//! expose cheap hover-readouts, and implement the [`Facet`](facett_core::Facet)
//! contract (`caps()` + `copy()` → CSV). Hand-painting on the egui `Painter`
//! (the same path `facett-core`/`facett-map` use) is the lighter, better-fitting
//! choice — so `plotters` is *not* a dependency.
//!
//! ## Theme-derived colour ramps
//! No palette is hardcoded. [`ramp::Ramp`] builds a **sequential**
//! (`bg`→`accent`→`glow`) or **diverging** (`accent`→`text_dim`→`glow`) ramp
//! purely from the active [`Theme`](facett_core::Theme), so heatmaps/treemaps
//! follow whatever theme is set.
//!
//! Each view is a [`Facet`](facett_core::Facet): it declares
//! `caps().themeable().copyable().resizable()`, paints itself, and `copy()`
//! emits the underlying data as CSV. The data→geometry math (quartiles, KDE
//! bins, OHLC mapping, heatmap cell layout, treemap squarify) lives in **pure,
//! tested functions** that need no GPU.

pub mod boxplot;
pub mod candlestick;
pub mod chart;
pub mod heatmap;
pub mod palette;
pub mod ramp;
pub mod treemap;
pub mod violin;

pub use boxplot::{BoxPlotEffect, BoxPlotMsg, BoxPlotState, BoxPlotView, Quartiles};
pub use chart::{ChartEffect, ChartKind, ChartMsg, ChartState, ChartView, Series};
pub use palette::{series_color, series_palette};
pub use candlestick::{
    CandlestickEffect, CandlestickMsg, CandlestickState, CandlestickView, Ohlc, OhlcLayout,
};
pub use heatmap::{HeatmapEffect, HeatmapMsg, HeatmapState, HeatmapView};
pub use ramp::Ramp;
pub use treemap::{Tile, TreemapEffect, TreemapMsg, TreemapState, TreemapView};
pub use violin::{Density, ViolinEffect, ViolinMsg, ViolinState, ViolinView};