Generate SVG paths for a line, d3-style.
Usage
line = svgLine()
Creates a new line generator.
line(points)
Given an array of points, return an SVG path string that you can then use
when setting a <path>
's d
attribute.
By default, each point is assumed to be an object with an x
and a y
coordinate, e.g. to create a 1x1 square:
var line =var svg = 'http://www.w3.org/2000/svg'var d =var square = documentsquare
line.x(getX)
Pass in a new function responsible for getting a point's x coordinate from a single element in the array.
The function is passed (d, i)
, where d
is the element and i
is its index
in the array.
For example:
var svg = 'http://www.w3.org/2000/svg'var line =x { return d0 }y { return d1 }var d =var square = documentsquare
line.y(getY)
Much like line.x
, pass in a new function responsible for getting a point's y
corrdinate from a single element in the array.
License
MIT. See LICENSE.md for details.