Skip to main content

Module resolve

Module resolve 

Source
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 PlotView framing bounds with FIT_PADDING headroom added in scale space (per-axis, through xs/ys). Missing per-axis bounds fall back to a unit window (via PlotView::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 by gutter_left (from left_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 at GUTTER_LEFT_MIN. Measures the widest formatted Y tick label in the same font/size/count draw_ops draws them.
pad_y
Pad a (min, max) value span into an AxisView with FIT_PADDING headroom added in scale space (through the axis scale), 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_x is set (so streaming appends stay in view), then refit the Y axis to the visible data when autoscale_y is set. The caller passes the effective autoscale state per axis — spec.{x,y}_autoscale unless 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. scale selection lives on the spec; this only moves the windows.
visible_y
The (min, max) of y over every sample whose x lies within the horizontal window x — what Y::autoscale fits the value axis to each frame. None when no sample is in range.
x_scale
The horizontal-axis Scale of a spec (a convenience for the prepare pass / metrics).
y_scale
The vertical-axis Scale of a spec.