pathLength

Chart
stable

Compute the total Cartesian length of a polyline defined by an ordered array of `[x, y]` points. Used to seed `stroke-dasharray` / `stroke-dashoffset` for the chart line-drawing entrance animation.

API

Signature

Signature TypeScript complète, extraite du fichier util.

typescript

API

Paramètres

Paramètres d'entrée acceptés par cet util.

points
requis
Array<TPathPoint>
An ordered array of `[x, y]` coordinate pairs defining the polyline. Returns `0` for arrays with fewer than 2 points.

API

Valeur de retour

La valeur retournée par cet util.

Total Euclidean length of the polyline in SVG user units. Returns `0` when the array has fewer than 2 points.

Usage

Exemples

Extraits de code prêts à coller.

Measure a simple two-segment path

typescript