The stack layout can now operate on arbitrary data structures, rather than
requiring a specific input format. To do this, you can now specify functions to
access values per series, along with x- and y-coordinates.
One tricky thing is that the stack layout needs to be able to write the stacked
values back into the data; this is accomplished using the customizable `out`
function. This function takes three arguments: the current datum (d), the offset
value (y0), and the y value. The y value is unchanged unless the "expand" offset
is used.
This commit also allows you to specify arbitrary functions for order and offset
computation, in addition to the built-in methods supported previously.
This doesn't quite seem like the right place for it, but it seems to work when
using "touchstart", "touchmove" and "touchend" handlers without any adverse
effects on "true" mouse event handlers.
See <http://www.jasondavies.com/apollonian-gasket/> to see an example of
combined touch/mouse handlers working with this change.
This commit adds a d3_uninterpolate method (private, for now), which is
essentially the inverse of d3.interpolate. It's used to map a value in the
domain to the unit range [0,1], which can then be passed to an interpolator.
Mainly, I fixed a bug where the coordinates could get set to NaN if two
successive points have the same x-coordinate. But I also cleaned up the
implementation slightly, and compute the initial tangents using finite
differences.
We can take advantage of JavaScript's invisible hoisting of variables to set
them before they are defined. This simplifies the code for the various special
cases in the `classed` operator, such as for SVG elements and browsers that
support the tokenized class list.
This turns out to be slightly faster than using structs (`{}`) and is bit
cleaner. You can now also do:
d3.rgb(r, g, b).hsl()
and:
d3.hsl(h, s, l).rgb()
to convert between RGB and HSL.
Specifically, removal of a class wasn't working because the `className` property
for SVG elements is an SVGAnimatedString, which has no `replace` method.
It would be nice to have a unit test for this, but env-js doesn't use
SVGAnimatedString for this property.