Expand description
facett-plotters — the chart types 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 fills the analytics long-tail Plotly defines:
BoxPlotView— quartiles + 1.5·IQR whiskers + outliersViolinView— Gaussian-KDE density silhouetteHeatmapView— a matrix as a colour grid with a gradient legendCandlestickView— 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
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, so heatmaps/treemaps
follow whatever theme is set.
Each view is a 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.
Re-exports§
pub use boxplot::BoxPlotEffect;pub use boxplot::BoxPlotMsg;pub use boxplot::BoxPlotState;pub use boxplot::BoxPlotView;pub use boxplot::Quartiles;pub use candlestick::CandlestickEffect;pub use candlestick::CandlestickMsg;pub use candlestick::CandlestickState;pub use candlestick::CandlestickView;pub use candlestick::Ohlc;pub use candlestick::OhlcLayout;pub use heatmap::HeatmapEffect;pub use heatmap::HeatmapMsg;pub use heatmap::HeatmapState;pub use heatmap::HeatmapView;pub use ramp::Ramp;pub use treemap::Tile;pub use treemap::TreemapEffect;pub use treemap::TreemapMsg;pub use treemap::TreemapState;pub use treemap::TreemapView;pub use violin::Density;pub use violin::ViolinEffect;pub use violin::ViolinMsg;pub use violin::ViolinState;pub use violin::ViolinView;
Modules§
- boxplot
- Box plot — quartiles + whiskers + outliers, one box per named group.
The data→geometry math (
Quartiles::from_sorted/Quartiles::compute) is a pure function with its own tests;BoxPlotViewis the themeable [Facet] that paints it and emits the underlying data as CSV/JSON. - candlestick
- Candlestick (OHLC) chart. Each bar is an open/high/low/close tuple drawn
as a wick (high→low) + a body (open↔close), coloured up/down from theme
colours. The price→pixel mapping (
OhlcLayout) is a pure function with tests so the geometry is verifiable headlessly. - heatmap
- Heatmap — a
rows × colsmatrix painted as a colour grid using a theme-derivedRamp, with a gradient legend. The cell-layout math (cell_rect) is a pure function with tests so the grid geometry can be verified headlessly. - ramp
- Theme-derived colour ramps. No hardcoded palette: a sequential ramp is
built from the theme’s
bg→accent→glow, and a diverging ramp fromaccent(low) through a neutral midpoint toglow(high). Charts callRamp::atwith a normalisedt ∈ 0..=1to map a scalar to a colour. - treemap
- Treemap — weighted rectangles, area ∝ value, laid out by a deterministic
slice-and-dice algorithm that alternates split direction by depth-of-cut
so the tiling stays readable. The layout (
squarify) is a pure function returning(index, Rect)pairs, tested independently of any painter. Tile fills come from a theme-derived sequentialRamp. - violin
- Violin plot — a mirrored kernel-density silhouette per group. The KDE
(
kde) is a pure function (Gaussian kernel, Silverman bandwidth) sampled on an evenly-spaced grid;ViolinViewpaints the mirrored density as a filled polygon and overlays the median line.