Skip to content

Utilities

Utility exports cover coordinate conversion, domain calculation, tick generation, and small typing helpers used by the components.

The detailed API pages are generated from JSDoc in src/components/utils.ts. Use this page as a map to the generated reference.

Types

ExportDescription
PlotPoint<T = unknown>Data-space point with x, y, and optional typed source data.
PlotPaddingPlot insets: { top, right, bottom, left }.
PlotDomainData-space bounds: { xMin, xMax, yMin, yMax }.
PlotSizeOuter SVG size: { width, height }.
PlotAreaDrawable SVG area after padding.
SvgPointSVG-space point: { x, y }.
ScaleOne-dimensional scale function.
MaybeArray<T>Scalar-or-array helper type: T | T[].

Constants

ExportDescription
defaultPlotPaddingDefault padding used when no padding prop is supplied.

Layout And Scales

ExportDescription
getPlotAreaReturns the drawable plot area after subtracting padding.
createLinearScaleCreates a linear data-space to SVG-space scale.
pointToSvgMaps one data-space point into SVG coordinates.
pointsToSvgFilters and maps finite data-space points into SVG coordinates.
polarToCartesianConverts a polar coordinate into SVG-space cartesian coordinates.

Domains And Ticks

ExportDescription
getDataDomainCalculates a padded domain from finite point coordinates.
getNiceTicksGenerates readable tick values between two bounds.
formatTickFormats a tick label for display.

Scalar Or Array Props

ExportDescription
getMaybeArrayReads either a scalar value or an indexed array value.

Vue3 Plots keeps its utility layer intentionally small. For heavier data preparation, prefer established packages and pass their output into the components.

PackageUse it forNotes
d3-arraySummaries, grouping, sorting, bins, bisectors, and tick helpers.Good when getDataDomain and getNiceTicks are not enough for your data pipeline.
d3-scaleLinear, time, log, symlog, ordinal, band, point, quantile, quantize, threshold, sequential, and diverging scales.Use when you need scale types beyond createLinearScale.
d3-formatNumeric label formatting.Useful when formatTick is too simple for locale, SI-prefix, percentage, or fixed-precision labels.
d3-time and d3-time-formatTime intervals and date formatting.Pair with d3-scale time scales for temporal plots.
simple-statisticsDescriptive statistics, regression, classification, and sampling helpers.A focused option for statistical preprocessing before rendering.

These packages should usually live in the consuming application, not inside this component library.