Expand description
Resolving a PlotSpec against its data and laid-out rect: the
data-space bounds of its marks, the auto-fit and Y-autoscale view, and
the data rect (the inner area marks draw into, inside the axis gutters).
These are the pure pieces the per-frame prepare pass
(UiState::prepare_plots) uses to seed and
update each plot’s PlotView before draw_ops reads it. Kept here,
separate and unit-tested, rather than buried in the state walk.
Constants§
- FIT_
PADDING - Fractional headroom added around the data when auto-fitting a view,
measured in scale space (so a log axis pads by ratio — see
AxisView::fit). - GUTTER_
LEFT_ MIN - Floor for the adaptive left gutter — it never shrinks below this even when the Y labels are narrow (keeps a tidy axis margin).
Functions§
- autofit
- An auto-fit
PlotViewframingboundswithFIT_PADDINGheadroom added in scale space (per-axis, throughxs/ys). Missing per-axis bounds fall back to a unit window (viaPlotView::fit). - data_
bounds - The union of every mark’s series bounds — the full data extent of the plot, used to auto-fit the initial view.
- data_
rect - The data rect for a plot laid out at
node_rect, inset bygutter_left(fromleft_gutter) and the fixed bottom/top/right gutters. Clamped to non-negative size. - left_
gutter - The left gutter needed to fit
view’s Y tick labels without clipping, floored atGUTTER_LEFT_MIN. Measures the widest formatted Y tick label in the same font/size/countdraw_opsdraws them. - pad_y
- Pad a
(min, max)value span into anAxisViewwithFIT_PADDINGheadroom added in scale space (through the axisscale), nudging a degenerate span to a unit scale-space window. - resolve_
view - Resolve the view for a plot this frame: start from the persisted view
(or an auto-fit if there is none), refit the X axis to the full data
extent when
autoscale_xis set (so streaming appends stay in view), then refit the Y axis to the visible data whenautoscale_yis set. The caller passes the effective autoscale state per axis —spec.{x,y}_autoscaleunless the user has taken manual control of that axis (an X gesture, or box-zooming the value axis), which opts the plot out until reset.scaleselection lives on the spec; this only moves the windows. - visible_
y - The
(min, max)ofyover every sample whosexlies within the horizontal windowx— whatY::autoscalefits the value axis to each frame.Nonewhen no sample is in range. - x_scale
- The horizontal-axis
Scaleof a spec (a convenience for the prepare pass / metrics). - y_scale
- The vertical-axis
Scaleof a spec.