createLinearScale()
function createLinearScale(domain, range): LinearScale;Defined in: packages/core/src/chart/linear-scale.ts:16
Builds a linear value -> pixel mapping over domain and range.
range is given in draw order, so a y-scale is constructed with its
range reversed ([bottomPx, topPx]) and the SVG y-flip falls out of the
arithmetic rather than being re-derived at every call site.
A degenerate domain (every value identical, including the all-zero case
a scoreless race chart produces) maps everything to range[0]. For a
y-scale that is the baseline, which is where a flat zero line belongs;
returning NaN from the division, or splitting the difference to the
middle of the range, would both draw a line the data doesn't support.
Parameters
| Parameter | Type |
|---|---|
domain | readonly [number, number] |
range | readonly [number, number] |