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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
//! Composed figures — thin, in-crate compositions of scale + coord + mark
//! + guide. Each figure is a pure `render(&self, ctx, rect, theme)` (V1)
//! or `render_with(&self, ctx, rect, theme, overlay: &FigureOverlay)` (V2)
//! over borrowed data; a figure never retains interaction state itself —
//! [`FigureOverlay`] is borrowed per-frame input, not owned (design law #3).
//! A real registry/IR (mlc's `ChartTypeDef`+`DrawOps` two-table pattern)
//! is a later milestone — see the crate-root docs.
//!
//! `pie`/`waterfall`/`heatmap` (V4, business-chart set) apply the FT/
//! Economist chart-hygiene rules from
//! `nemo/docs/uzor-engines/research_dataviz_sota_2026.md` §6 as DEFAULT
//! behavior, not opt-in flags — see each module's own docs.
//!
//! `scatter`/`boxplot`/`kpi` (typography-gap WAVE 4, statistical/business
//! set) round out the crate: [`scatter::ScatterFigure`] (x/y point cloud,
//! deterministic uniform-stride thinning — NOT LTTB, see its own module
//! docs for why), [`boxplot::BoxplotFigure`] (Tukey `1.5 * IQR` quartile
//! summary), and [`kpi::KpiFigure`] (dashboard number tile) — all three
//! opt into [`crate::guide::annotation`]'s reference lines/bands/callouts
//! where applicable (curve/bars gained the SAME opt-in `annotations`
//! field this wave).
//!
//! `dag` (arc B wave 2 shelf item): [`dag::DagFigure`] — a layered DAG
//! figure over [`dag::layering`], the CANONICAL Kahn longest-path +
//! barycenter layering algorithm for this workspace (this crate must not
//! depend on `uzor-graph` — see `dag`'s own module docs for the full
//! provenance and its documented v1 scope boundaries). `uzor-graph`
//! re-points its own `layout::layering` onto this module (2026-07-22)
//! instead of keeping a duplicate copy.
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use KpiFigure;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
use ;
use Rect;
use crateFocusSet;
use crateCategoricalScale;
use crateFigureTheme;
/// Borrowed per-frame interaction state a figure may optionally react to.
/// The default (`hover_px: None, brush: None, focus: None`) reproduces
/// exactly the old stateless V1 render — `render(ctx, rect, theme)` is
/// literally `render_with(ctx, rect, theme, &FigureOverlay::default())`.
/// How a figure's own auto-computed Y domain treats the zero baseline —
/// shared vocabulary so a caller reasons about "does this figure force
/// zero" identically regardless of which figure it's configuring.
/// [`crate::figure::CurveFigure::with_y_domain_policy`] is currently the
/// only builder exposing it (default [`YDomainPolicy::ForceZero`]
/// reproduces this crate's own pre-existing forced-zero behavior
/// byte-for-byte — see that builder's own doc comment for why zero
/// forcing was never actually optional before this).
///
/// [`crate::figure::ScatterFigure`]/[`crate::figure::BoxplotFigure`]'s own
/// Y domains are ALREADY, unconditionally, [`YDomainPolicy::FitData`]
/// (their own module docs explain why a bar/area's height-from-zero
/// convention doesn't apply to a point/box's position) — named here as
/// the SAME vocabulary for documentation purposes; neither figure has a
/// builder to change it, since nothing today asks for the opposite on
/// either.
/// How a figure sizes its own fixed axis-gutter margin (e.g.
/// `CurveFigure`'s `MARGIN_LEFT`) against what its actual tick labels
/// would measure — shared vocabulary, same role [`YDomainPolicy`] plays
/// for the zero-baseline question.
///
/// Unlike every other policy enum in this crate (which defaults to
/// reproducing OLD behavior, because the alternative is a genuine render
/// CHANGE), [`MarginPolicy::Measured`] is the default here: it computes
/// `max(fixed constant, measured widest label extent)`, so the margin can
/// only GROW past its own fixed floor, never shrink or shift below it — a
/// figure that never had a clipping label renders byte-identically to
/// [`MarginPolicy::Fixed`]. It carries none of the "silently changes
/// existing output" risk this crate's binding doctrine reserves for a
/// real default flip, because it can only fix an already-broken case (a
/// label that would otherwise draw past the plot rect's own edge — see
/// the audit's own B2 finding), never touch a render that wasn't already
/// broken.
/// How a figure resolves the tick COUNT it requests from its own
/// continuous scale(s) — shared vocabulary for the
/// `TARGET_X_TICKS`/`TARGET_Y_TICKS` constants named in the audit's B3
/// finding. Unlike [`MarginPolicy`], [`TickCountPolicy::Adaptive`] DOES
/// change rendered output relative to today's flat constant (a wider plot
/// requests more ticks) — so, following this crate's binding doctrine,
/// [`TickCountPolicy::Fixed`] (at each figure's own pre-existing constant)
/// stays the default; a caller opts into `Adaptive` explicitly.
/// Minimum px budget per tick under [`TickCountPolicy::Adaptive`] — e.g. a
/// 600px-wide plot allows `600 / 70 ≈ 8` ticks before clamping to `max`.
pub const MIN_PX_PER_TICK: f64 = 70.0;
/// Resolve a target tick count from `policy` and `available_px` (the
/// plot rect's own width for an X axis, height for a Y axis) — the
/// generic entry point a figure's own `render_with` calls in place of
/// reading a flat `TARGET_X_TICKS`/`TARGET_Y_TICKS` constant directly.
///
/// [`TickCountPolicy::Fixed`] ignores `available_px` entirely (today's
/// behavior, reproduced byte-for-byte). [`TickCountPolicy::Adaptive`]
/// derives `available_px / MIN_PX_PER_TICK`, floored at `1`, then clamps
/// to `[min, max]` (both floored at `1` too — a degenerate `min: 0` still
/// requests at least one tick, matching every scale's own "an axis with
/// data still draws something" convention).
/// Resolve category `index`'s own color: `Some(palette)` routes through
/// [`CategoricalScale::color_for`] (Wave 4a's opt-in colour-blind-safe
/// categorical identity — see that type's own doc comment); `None`
/// reproduces this crate's pre-existing `theme.palette[index %
/// theme.palette.len()]` indexing byte-for-byte, guarded the SAME way
/// every pre-existing "degenerate empty theme.palette" check in this
/// crate already is (falls back to `theme.label_color`, never divides by
/// zero). Shared by every figure exposing an OPT-IN
/// `with_category_palette` builder ([`BarFigure`]/[`PieFigure`]/
/// [`DagFigure`]/[`SankeyFigure`]) — per this crate's own binding
/// doctrine, a new categorical color identity is a real, explicit option;
/// every figure's own DEFAULT (`None`) renders EXACTLY as before this
/// item, nothing changes silently.
pub
/// Left inset (px) of a figure's own title from `rect.x` — see
/// [`draw_title`]'s own doc comment for why this is larger than the
/// pre-existing `8.0`.
const TITLE_LEFT_INSET: f64 = 14.0;
/// Top inset (px) of a figure's own title from `rect.y`.
const TITLE_TOP_INSET: f64 = 6.0;
/// Shared title-bar draw shared by every figure in this module — top-left,
/// one line, `theme.label_font`/`theme.label_color`.
///
/// **Owner defect report investigated (report, not silently fixed by
/// guesswork):** "the scatter figure's title has its first glyph(s)
/// clipped by the figure rect's left edge" at high PDF zoom. Root-caused
/// via a pixel-level decode of the regenerated raster proof PNGs (this
/// crate's own `figures_scatter.png`, and an isolated `uzor-typeset`
/// repro matching the showcase's exact heading+spacer+figure block
/// sequence) — in BOTH, the title's own ink starts with a clean,
/// unclipped gap before the figure rect's left edge (verified by decoding
/// the PNG's own raw pixel rows: no ink at all in the pre-title columns).
/// **No literal glyph-clipping bug exists in this code path.** The
/// pre-existing `8.0`px inset was nonetheless visibly TIGHTER than every
/// other left-side chrome margin this crate's figures use (`MARGIN_LEFT`
/// on an axis-bearing figure runs 48-90px; even the annotation guide's own
/// `REFERENCE_LABEL_GAP` inside the plot is a comparable few px past a
/// much larger existing inset) — at the zoom level a "crop tightly around
/// just the figure" screenshot implies, an 8px gap reads as "hugging the
/// edge," which is almost certainly what prompted the report. Bumped to a
/// named, more generous constant for real visual breathing room, not a
/// blind "add a few more px" guess.
pub