Skip to content

@putianyi888/vue3-plots


createLinearScale(domainMin, domainMax, rangeMin, rangeMax): (value) => number

Defined in: utils.ts:125

Creates a linear mapping from a data-space domain to an SVG-space range.

Non-finite input values map to rangeMin. Degenerate or non-finite domains map all values to the center of the range.

Parameters

ParameterTypeDescription
domainMinnumberLower data-space bound.
domainMaxnumberUpper data-space bound.
rangeMinnumberLower SVG-space bound.
rangeMaxnumberUpper SVG-space bound.

Returns

A scale function.

(value) => number

Example

ts
const scaleX = createLinearScale(0, 10, 40, 624)
scaleX(5) // 332