Skip to main content

Module plot

Module plot 

Source
Expand description

Backend-neutral data and interaction state for the 2D plot widget: polished, hardware-accelerated 2D plots and graphs (time series, scatter, and — as the feature lands — area and bar charts).

Scope and rationale live in docs/PLOT2D_PLAN.md. The short version: a 2D plot’s data marks are a degenerate 3D scene (orthographic, all geometry at z = 0), so plot reuses the shipped scene GPU pipelines — screen-pixel anti-aliased lines and points, offscreen MSAA, color-managed linear blending, and the versioned-handle upload cache — rather than adding a parallel 2D renderer. This module owns the data and interaction state the widget carries; the pipelines that render it live in the backend crates, never here.

§API layering

The surface is layered so a simple plot is a one-liner while a power user can build a custom plotting system from the same pieces:

  1. plot([...marks]) — the common case; auto-scaled axes, pan/zoom, and a crosshair for free.
  2. Scale + axis configuration — override the warp (linear/time/log), ticks, and formatting per axis.
  3. The public primitives — Scale and PlotView (here), plus the series handle and data op — compose a bespoke chart with no plot() at all.

Re-exports§

pub use decimate::Decimation;
pub use request::PlotRequest;
pub use scale::Scale;
pub use scale::Tick;
pub use series::Sample;
pub use series::SeriesBounds;
pub use series::SeriesHandle;
pub use spec::Axis;
pub use spec::LegendPosition;
pub use spec::LineMark;
pub use spec::Mark;
pub use spec::PlotControls;
pub use spec::PlotSpec;
pub use spec::PlotStyle;
pub use spec::ScatterMark;
pub use spec::line;
pub use spec::scatter;
pub use view::AxisView;
pub use view::PlotView;

Modules§

decimate
Down-sampling an over-dense series to the pixel budget — the library-side half of the data-density story (the plan’s decision 5).
lower
Lowering plot samples to scene geometry.
palette
The default series colour cycle — the colours auto-assigned to marks that don’t set their own (line(&h) with no .color(...)).
request
Programmatic plot() view commands — the plot counterpart of crate::viewport::ViewportRequest.
resolve
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).
scale
Axis scales: the continuous, invertible warp from data space to scale space, plus tick generation and value formatting.
series
The app-owned, versioned data handle a plot mark reads from, and the sample type it holds.
spec
The declarative description of a plot: its marks, axes, and styling.
view
The plot’s pan/zoom view state: a visible data-space window per axis, plus the projection, pan, and zoom algebra that maps between data space and the pixels of the plot’s data rect.