1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
//! Terminal plotting: a small grammar of marks, honest axes, millions of points.
//!
//! Eight marks ([`Line`], [`Points`], [`Bars`], [`Area`], [`Cells`], [`Range`],
//! [`Rule`], [`Text`]) compose over shared scales into the basic chart catalog;
//! presets like [`line()`], [`hist`], [`box_plot`], and [`violin`] are one-line fronts
//! over that grammar. Large series aggregate to the raster before drawing (M4 —
//! pixel-exact for lines), axes use extended-Wilkinson tick placement with
//! exact-decimal labels, and everything renders to a plain `String` — colored for
//! your terminal via [`Frame::detect`], deterministic via [`Frame::plain`].
//!
//! ```
//! use malevich::{Frame, Line, Plot, Rule};
//!
//! let steps: Vec<f64> = (0..100).map(f64::from).collect();
//! let loss: Vec<f64> = steps.iter().map(|s| 4.0 * (-0.05 * s).exp() + 0.4).collect();
//! let chart = Plot::new()
//! .layer(Line::xy(&steps[..], &loss[..]).label("loss"))
//! .layer(Rule::h(0.5).label("target"))
//! .title("training");
//! println!("{}", chart.render(&Frame::plain(60, 14)));
//! ```
//!
//! A plot is a plain value: `Clone + Send + Sync`, no global state, rendering is a
//! pure function of plot and frame. [`Plot::render`] never fails — it sheds what it
//! cannot draw — so building a plot inline needs no error handling. For a spec that
//! arrives from deserialization or configuration, [`Plot::validate`] and
//! [`Plot::try_render`] report the first problem as a typed [`Error`] instead.
//!
//! # Failure model
//!
//! Functions that return [`Result`] are the strict boundary: invalid data shapes,
//! configuration, numeric domains, and bounded resource requests return a typed
//! [`Error`] rather than asserting. A `try_` name distinguishes that checked twin
//! when the same operation also has a convenience form, such as
//! [`Cells::matrix`] / [`Cells::try_matrix`] and [`Plot::render`] /
//! [`Plot::try_render`]. The `_with` suffix means “configured with an options
//! value”; its return type, not the suffix, states whether the call is fallible.
//! Plain mark constructors and one-call presets may panic on their documented
//! programmer invariants, such as unequal paired channels. Infallible rendering is
//! intentionally different: it sheds malformed retained content and excessive
//! output instead of panicking.
//!
//! The modules follow the concepts (each defined in
//! the repository's `docs/terminology.md`): [`mark`] for the primitives, [`stat`] for
//! online accumulators, reducers, and batch transforms,
//! [`scale`] for ticks and colormaps, [`render`] for the subpixel surface and
//! charsets, [`stream`] for live charts, [`data`] for the ingestion rim.
//!
//! The gallery in `EXAMPLES.md` shows every chart type with its source, and
//! `cargo run --example showcase` renders a colored tour in your terminal.
//!
//! # Features
//!
//! - `evcxr` — rich display for Evcxr Jupyter notebooks through
//! [`Plot::evcxr_display`] and the [`evcxr`] module, whose stdout protocol and
//! card colors let a crate draw its own types on the same background. The
//! cards themselves need no feature: [`Plot::to_html`] and [`Plot::to_svg`]
//! render the cell grid for any host that draws with HTML or SVG.
//! - `ndarray` — one-dimensional arrays and views plot directly; contiguous
//! storage is zero-copy.
//! - `pixel` — the plot panel as a real image (sixel, kitty graphics, or iTerm2
//! inline PNG) with text chrome around it: [`Plot::render_pixels`],
//! [`Plot::to_svg_pixels`] for an SVG host, the
//! [`pixel::Capabilities`] query API, and [`Plot::render_best`] picking the
//! best tier the terminal offers.
//! - `ratatui` — [`PlotWidget`], a `ratatui` widget rendering any plot into a
//! `Buffer`; rendered stateful with a [`PlotState`], it becomes interactive:
//! hit-testing through the cached [`Mapping`], zoom and pan through a
//! [`Viewport`], and default mouse gestures fed via [`PlotState::on_mouse`].
//! Combined with `pixel`, the widget draws its panel as a real image
//! ([`PlotWidget::graphics`], emitted by
//! [`Graphics::present`](pixel::Graphics::present)) with the interaction
//! chrome rendered into the image itself.
//! - `serde` — every spec type (plots, marks, scales, themes, frames)
//! round-trips through serde; `Document` is the versioned persistent envelope,
//! gaps survive JSON as `null`, and function-backed lines refuse to serialize
//! rather than lie.
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use Scale;
pub use Theme;