The data join is now specified as a single function of data, as with all other
properties. This allows the key to be computed on the previously-bound data,
rather than requiring the key to be serialized into the DOM (say, as an
attribute). In the case that there is no previously-bound data, it is still
possible to access the associated node as the `this` context.
The `enter` operator no longer performs an append. For symmetry with the `exit`
operator, you must call `append` after obtaining the entering selection. This
requires a tiny bit more code, but should make the code more clear. Also, it
provides an opportunity to use a different instantiation operator, such as the
new `insert` operator. This takes a second argument, which is a selector for the
insert-before reference element. For example, the selector ":first-child" will
prepend nodes.
The `empty` operator allows you to query whether a selection is empty (i.e.,
contains zero matching nodes).
You can now override the scale interpolator by calling the `interpolate` method.
One particularly useful interpolator is the new `d3.interpolateRound`, which is
like `interpolateNumber`, except that it returns integers. This makes it easier
to produce a scale that outputs exact pixel values, and avoid antialiasing
artifacts.
For convenience, the quantitative scales have a `rangeRound` method which sets
the range and the interpolator at the same time. Similarly, a `rangeRoundBands`
has been added to the ordinal scale.
Adds support for contours (d3.geom.contour) and cardinal spline interpolation.
I've extended cardinal spline interpolation to d3.svg.area, and added closed
basis spline interpolation. The spline tension is now set using a named
method, and closed splines can be generated using basis-closed and
cardinal-closed, respectively.
This commit also includes Jeff's nifty clustered force-directed graph example!
If the same element were selected multiple times, then the transition would be
cleared on the associated node, causing `tx` to be undefined. We now abort the
transition in this case, rather than causing a JavaScript error.
The renaming of attributes is totally not worth the hassle of maintaining an
externs file (or using the awkward `foo["bar"]` syntax). The file size
reduction from the advanced optimizations was negligible, besides!
This computes the projected area (in square pixels) of the given GeoJSON
object. This is useful for producing choropleth maps that area normalized to
the visible area.
Two new XHR utilities are included in this commit for fetching XML and HTML
data. The latter can be used to scrape data from websites that don't support a
more suitable API (such as JSON or XML), conveniently using the W3C DOM API
including selectors.
Parsing HTML is surprisingly tricky, as browser support for it is poorly
standardized. It's possible to embed the HTML in the current document or an
iframe, but that runs embedded scripts and loads external resources (images,
stylesheets), which is a security hazard!
Our approach uses the DOM Level 2 Range API, and the nonstandard
createContextualFragment method, which is supported by major browsers.
Strangely, WebKit (Chrome & Safari) can only access the body of the loaded
HTML document, whereas Firefox parses the whole document.
We now use the same property accessors (startAngle, endAngle and radius) for
two source and target objects. Note that you don't have to structure your data
hierarchically; you can define a source and target accessor that restructures
the data on the fly.
These are symmetric operators for splitting and merging (blending) arrays. The
split operator is useful for line and area charts where some of the data
points may be undefined; split the data into subarrays and render each as its
own line or area. This commit also fixes a bug in d3.svg.line when the data
array is empty.
I'll add support for other types of splines shortly. These classes now also
support constants for the various x and y properties. Also, the area class can
now be used with a variable baseline (y0) for creating streamgraphs. I will
update the current streamgraph demo to use d3.svg.area in a future commit.
Transitions created within the end event of an earlier transition now reuse
the same transition ID, which allows staged transitions to continue in
parallel even if the a later transition has been scheduled. Now that
transitions support remove, we can dispatch transition end events even if the
active transition does not own the element.
It's probably best to assume that if the attr is being set, it's changing, and
therefore we shouldn't check the original value. The caller can now use the
filter operator to optimize, if needed.
Also, change svg.mouse so that it returns an array [x, y] rather than {x, y};
this makes it easier to convert to a string, e.g., for SVG's transform
attribute. Also, optimize selection.attr so that it checks the attribute value
before setting the attribute. (I thought it would be slower to check, but
surprisingly it's not!)