export interface PlotMargins { top: number; right: number; bottom: number; left: number; } export interface PlotRect { x: number; y: number; width: number; height: number; } export interface PlotLayoutOptions { hasXLabel: boolean; hasYLabel: boolean; hasLegend: boolean; /** * Additional CSS-pixel height reserved at the bottom of the plot for a * hierarchical / rotated categorical X axis. Overrides the default 24px * tick band. The axis-label allowance from `hasXLabel` is preserved. */ bottomExtra?: number; /** * Total CSS-pixel width reserved at the left of the plot for a * hierarchical categorical Y axis. Overrides the default `55 + * hasYLabel*16` left gutter. The axis-label allowance from `hasYLabel` * is preserved. */ leftExtra?: number; /** * Total CSS-pixel width reserved at the right of the plot. Overrides * the default (`80` when `hasLegend`, else `16`). Faceted cells * without axes (treemap / sunburst in grid mode) pass `0` to make * adjacent cell plot rects flush; axis-bearing charts leave it * unset to keep the default breathing-room margin. */ rightExtra?: number; /** * Absolute canvas-coordinate offset for this layout's plot origin. * When set, `cssWidth` / `cssHeight` describe the *outer* canvas, and * `originX` / `originY` name the top-left corner of the cell this * layout represents. The cell's own width/height come from * `cellWidth` / `cellHeight`. `margins` are computed relative to the * cell then shifted into canvas-absolute space so projection * matrices, scissor, and `dataToPixel` all operate in full-canvas * coordinates without branching per-facet. * * When any of these fields is unset, the layout is single-plot: the * cell occupies the whole canvas and `originX` / `originY` default * to 0. */ originX?: number; originY?: number; cellWidth?: number; cellHeight?: number; } /** * Coordinates margins and coordinate transforms between WebGL and Canvas2D. * All measurements are in CSS pixels (not physical/DPR-scaled pixels). */ export declare class PlotLayout { readonly margins: PlotMargins; readonly plotRect: PlotRect; readonly cssWidth: number; readonly cssHeight: number; paddedXMin: number; paddedXMax: number; paddedYMin: number; paddedYMax: number; constructor(cssWidth: number, cssHeight: number, options: PlotLayoutOptions); /** * Build an orthographic projection matrix that maps data coordinates * [xMin..xMax, yMin..yMax] to the plot area sub-region of clip space [-1, 1]. * * The matrix bakes margin offsets into the transform so that gl.viewport * remains full-canvas and no scissor/sub-viewport is needed. * * `clamp`, when set, names the axis that carries the *value* (as * opposed to categorical / positional) data. Today it only affects * `requireZero`; both axes always receive symmetric `padRatio` padding. * * `requireZero`, when true, guarantees that the unpadded value `0` * falls inside the clamped axis's final domain. For all-positive * data the axis minimum is pinned at `0` (the baseline sits on the * axis line); for all-negative data the maximum is pinned at `0`; * for data that already straddles zero, nothing changes. Pairs with * `clamp`, and is a no-op when `clamp` is unset. * * `padRatio` controls the symmetric cosmetic pad on both axes * (default 2%). Charts that want plot edges flush with the axes * (e.g. heatmap, whose cell rects already span the exact domain) * pass `0`. */ buildProjectionMatrix(xMin: number, xMax: number, yMin: number, yMax: number, clamp?: "x" | "y", requireZero?: boolean, padRatio?: number, xOrigin?: number, yOrigin?: number): Float32Array; /** * Convert data coordinates to CSS pixel coordinates on the overlay canvas. * Uses the padded domain from the last `buildProjectionMatrix` call so * that pixel positions align exactly with the WebGL projection. */ dataToPixel(dataX: number, dataY: number): { px: number; py: number; }; }