Rename `ticks` to `bins` to match numpy, matplotlib, and Protovis. Also allow
the bins to be specified simply as a count, in which case the range is divided
uniformly into the specified number of bins.
The histogram layout now also takes a `range` property, which specifies the
minimum and maximum value of the histogram rather than implicitly computing it
from the values, which is nice if you expect values to fall in a specific range,
such as [0,1].
This is similar to pv.search, but more closely modeled after Python's bisect
methods to provide the desired flexibility in searching slices of arrays. This
includes good tests for bisect, and better tests for polylinear and quantile
scales (both of which now use bisect).
Simplify the implementation of parallel merge-sort, so that we have one pass per
swap across chunks. Use a data join so that the elements are translated rather
than rotated, since this better conveys the underlying sort. Auto-play the
animation in parallel, and restart a few seconds after it finishes.
Inspired by the phrase "reminiscent of wind gusting over tall grasses" in
<http://vis.stanford.edu/protovis/ex/sort.html>.
It seemed abominable not to animate the swaying tall grasses!
There will always be a single <path> element, so no need to handle enter, update
and exit cases. WebKit seems to erroneously warn (in the error console) that it
can't parse `d=""`. I can't see anything in the SVG spec disallowing an empty
`d` attribute so I think this is safe to ignore.
I've dropped path transitions on Mike's recommendation as D3 doesn't have smart
path interpolation at the moment so they don't work too well.
I've also fixed some issues with data joins.
If the simulation cools and stops, we need to restart it, rather than just
resetting the alpha parameter. So, it is useful to have both `resume` and
`start` methods on the force layout. This commit also fixes a bug where
mousedown events on draggable nodes would continue to propagate, interfering
with other events (such as clicking to add a node).
You can now register the "drag" behavior on nodes multiple times, and the
correct behavior will result. In addition, the gravitational force now handles
coincident nodes, computing a small random force to separate the nodes rather
than setting the position to NaN.
To demonstrate the new support for dynamic graphs, this commit includes a fun
example where you can click to add new nodes. Any existing nodes within a fixed
distance to the cursor on click will be linked to the new node.
Rather than applying gravity to the entire graph, we now apply it to individual
nodes, such that disconnected nodes and subgraphs still have a tendency to drift
towards the center. In addition, rather than using a standard gravitational
force that drops quadratically with distance, we use a weak spring who force
increases with distance. This makes the gravitational effect less noticeable
near the center, and also makes the effect stronger the more the nodes drift
from the center. To balance the center "gravity" with the repulsive charge
force, we also normalize the strength of the gravity based on the number of
nodes in the graph.
Use Barnes-Hut criterion (a fast multipole method) for approximating repulsive
charge forces between nodes. This replaces the previous approach using Floyd-
Warshall to compute the graph theoretic distance between all nodes, eliminating
O(n^3) initialization time. Additionally, the charge force is now O(n lg n) per
iteration rather than O(n^2).
Using the center of mass of the graph, apply gravitional attraction towards the
graph center (based on the layout size). This encourages the graph to stay near
the center rather than drifting away.
This makes the quadtree implementation more compatible with the force layout.
This change is backwards-compatible; if the points are not specified as x+y
objects, they are assumed to be tuples and converted to objects.
This is a utility for creating a Bézier curve between opposite corners of a
rectangle. This is commonly used to draw smooth curves connecting parent and
child nodes in a hierarchical node-link diagram. A projection may be specified
which allows the curve to be transformed from polar coordinates.
This commit also changes the semantics of the recently-added `links` method,
such that the objects have `source` and `target` properties that match the
default diagonal format.
This method can be used to generate an array of parent+child objects for a given
array of nodes. This is convenient for drawing paths from parent to child in
node-link diagrams.
The `cluster` layout is now more similar to the `tree` layout, using a
separation function rather than a group property. In addition, the breadth and
depth properties are replaced with x and y, respectively, and scaled according
to the size of the layout.
I've updated the examples to make them more consistent, as well, including the
pretty Bézier curves. In a future commit I'd like to take some of the duplicate
code in the examples and move that into reusable methods.
Preserving object constancy across transitions is tricky! For example, what
happens if we remove the whiskers in a transition? How do we join outliers? This
commit makes a few assumptions explicit:
1. The `quartiles` function must return exactly three elements. This property
must be specified as a function.
2. The `whiskers` function must return exactly 2 elements, or null if no
whiskers are to be displayed. This property must be specified as a function.
3. The `domain` function must return exactly 2 elements, or null if the default
domain should be used. This property can be specified either as a constant or as
a function.
We could generalize this chart to support more than two whiskers, but it doesn't
seem urgent, and it would complicate the transition if the number of whiskers
changes. In a related change, the `whiskers` function does not receive a third
argument containing the quartiles; instead, this is made available by the
`quartiles` property on the values array (the first argument).
The outliers are joined using the `Number` key function. The outlier data is now
stored as indices; this allows reasonable object constancy across transitions
with outliers. Similarly, the tick labels for the quartiles are whiskers are now
separated, such that the whisker labels can be added or removed without spurious
transition.