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!)