Граф коммитов

207 Коммитов

Автор SHA1 Сообщение Дата
Mike Bostock fd804ce47f Better force layout.
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.
2011-04-19 12:39:37 -07:00
Mike Bostock 587b1bb494 Use x+y objects for quadtree points.
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.
2011-04-19 12:19:04 -07:00
Mike Bostock 43e2ccca41 Fix fill color for iOS. 2011-04-14 16:53:33 -07:00
Mike Bostock f028aa00d9 Add bubble chart example. 2011-04-14 14:20:07 -07:00
Mike Bostock de3d1c1a6c Remove examples/index.html.
This is no longer needed, as Python's SimpleHTTPServer does directory listing.
2011-04-13 23:59:15 -07:00
Mike Bostock d4e571eb88 Replace flare.json's with symlinks. 2011-04-13 23:58:46 -07:00
Mike Bostock 2eb4573f42 Merge branch 'box' into release 2011-04-13 23:53:59 -07:00
Mike Bostock 39dea0102f Merge branch 'cluster' into release 2011-04-13 23:51:29 -07:00
Mike Bostock 126e625d21 Add d3.svg.diagonal.
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.
2011-04-13 23:13:06 -07:00
Mike Bostock 8d7bd91080 Add `links` methods to cluster & tree.
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.
2011-04-13 22:41:30 -07:00
Mike Bostock 60b6a3d2e5 Simplify cluster layout.
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.
2011-04-13 22:04:11 -07:00
Mike Bostock c29d4dc1a7 Better box chart transitions.
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.
2011-04-13 17:44:20 -07:00
Jason Davies 12663738d9 Fix quartile calculation.
The outliers were being incorrectly excluded when computing the quartiles.  I've
also added a +/-1.5 IQR whiskers computation for the Morley-Michelson example,
so it replicates the R plot exactly.
2011-04-13 23:40:00 +01:00
Jason Davies f9569c5aac Minor optimisations. 2011-04-13 23:27:52 +01:00
Jason Davies a7b3c3265c Remove unused title svg:g. 2011-04-13 23:20:16 +01:00
Jason Davies 3477764db0 Fix randomize button. 2011-04-13 23:16:10 +01:00
Jason Davies 6c8cef1eef Add Michelson-Morley data for box plot example.
Source: R statistical project
Original source: A. J. Weekes (1986) A Genstat Primer. London: Edward Arnold.
2011-04-13 23:12:18 +01:00
Jason Davies 88eabf1969 Continue renaming "boxplot" to "box". 2011-04-13 22:33:15 +01:00
Jason Davies 0b8aa07ed2 Rename "boxplot" to "box". 2011-04-13 22:31:53 +01:00
Jason Davies d288e69016 Remove `outlierSymbol` property.
Circles are simpler.
2011-04-13 22:27:25 +01:00
Jason Davies 9721e6f045 Display outliers.
The symbol can be specified using the `outlierSymbol` property, which specifies
the `d` attribute for an SVG path.
2011-04-13 21:59:37 +01:00
Jason Davies 755529dba8 Add `whiskers` property to box plot.
This specifies a function that takes the sorted data array, and returns an array
of datum positions that should marked with whiskers.  The default implementation
is to return `[0, length-1]` i.e. the minimum and maximum.

Data outside of the whiskers are considered outliers, and are not included in
the quartile calculation.
2011-04-13 21:23:49 +01:00
Jason Davies 2e8cd200df Add boxplot chart. 2011-04-13 19:57:57 +01:00
Mike Bostock 776f332af6 More pretty Béziers. 2011-04-11 13:52:21 -07:00
Mike Bostock 0ca148d37e Add pretty Bézier curves. 2011-04-11 13:22:24 -07:00
Mike Bostock c5c6614d9e Simplify pack layout.
The pack layout now sorts nodes by ascending value by default. The `radius`
property is removed, as the radius is always computed from the node value. The
`spacing` property is also removed; it doesn't seem particularly useful. The
`radius` property is renamed to `r` to match `x` and `y`.

I also optimized the implementation slightly, and namespaced temporary state
under the prefix `_pack_`.
2011-04-11 12:44:17 -07:00
Jason Davies 5ef525385a Add cluster-radial to examples index. 2011-04-11 11:25:19 +01:00
Jason Davies 6ebe9e5779 Add cluster (dendogram) layout.
Based on the Protovis version.  The only difference is that I've dropped
the `orient`, `innerRadius` and `outerRadius` properties so that the D3
version is more flexible.
2011-04-11 11:19:59 +01:00
Jason Davies ccfbb06729 Add circle-packing layout.
Based on the Protovis layout.  I've kept the convention of using `size`
for the width/height and `separation` for the spacing.  The Protovis
layout had a `size` property but this was used to compute the radius.
I've left this out as I've assumed it's straightforward enough to pass
in the appropriate `radius` function instead.  Likewise, I think the
existing hierarchy `sort` property can handle situations that `order`
was intended for in the Protovis version.
2011-04-11 10:01:11 +01:00
Mike Bostock 9f71e4e211 Fix a bug in cardinal-closed interpolation. 2011-04-10 23:26:35 -07:00
Mike Bostock ca3585ec97 Move tree examples into div#chart. 2011-04-10 18:59:41 -07:00
Mike Bostock 597443b3b0 Rotate text by 180 when upside-down. 2011-04-10 18:37:23 -07:00
Mike Bostock 2c03029045 Compute wrap-around separation. 2011-04-10 13:56:34 -07:00
Mike Bostock 7151746fbe Add tree-radial example. 2011-04-10 13:29:32 -07:00
Mike Bostock 0c88813f56 Generalizing tree layout.
Rather than specifying an orientation, compute the layout in normalized space. In a future change,
I'd also like to clean up the temporary state that is stored on tree nodes, and record dx and dy
attributes per node that could be used to compute a space-filling layout.
2011-04-10 12:07:17 -07:00
Mike Bostock dfd0ad354d Render links below nodes and labels. 2011-04-10 10:45:51 -07:00
Jason Davies f208a5be09 Add Reingold-Tilford tree layout.
This is based on the Protovis layout; virtually no changes were needed
to the code aside from handling of previous and next siblings.
2011-04-10 16:20:51 +01:00
Mike Bostock bf180dc9af Fix a transition bug in bullet chart.
We were computing the tick join based on the (new) format function, but doesn't
produce the desired effect: the new format is applied on the old data. Thus, the
wrong join occurs if, say, the value 0.5 with the new format results in "0". The
correct join compares the old text content to the new format value.
2011-04-09 13:56:28 -07:00
Mike Bostock d9d85f0e03 No initial transition. 2011-04-09 13:00:38 -07:00
Mike Bostock 40be541c4c Restructure bullet chart example. 2011-04-09 12:38:48 -07:00
Jason Davies ef7b5ccb3c Push bullet chart state into ticks element data.
This means chart state (the original x-scale) is no longer bound to the
chart instance, so a single instance can be reused on multiple elements.
2011-04-09 16:41:26 +01:00
Michael Bostock e8b345d0f8 Make randomizer a bit more exciting. 2011-04-08 16:42:43 -07:00
Michael Bostock 448b72622c Rename var. 2011-04-08 16:36:16 -07:00
Michael Bostock 17259b94ff Add another bullet example.
This example shows how to preserve scales across multiples using a single chart
instance, as opposed to bullet-multiples which uses distinct chart instances to
supply separate scales. I still think it'd be better to use a single chart
instance in both cases, but then I need a different place to hide the scale
state.
2011-04-08 16:03:01 -07:00
Michael Bostock 4fda3a3ebf Use separate charts for bullet-multiples.
This way, we get separate scales for the small multiples, which makes sense
given our data. However, I'm not totally convinced this is the right way to
implement separate scales, because it's a bit awkward to create separate chart
instances that look identical. Also, it's unfortunate that the charts are
stateful; it'd be better to somehow store the scale as data on the nodes, so
that chart specifications could be more easily reused. Then, there might be a
method to fix the domain rather than computing the domain per-chart.
2011-04-08 15:46:14 -07:00
Michael Bostock 33260423a3 Extract title & subtitle from bullet chart.
It's nice, but I think it's a bit more flexible to not have it as part of the
chart specification. This way, people can define titles however they like. It
might be nice to take a similar approach with reference ticks in the future.
2011-04-08 14:40:29 -07:00
Jason Davies 598f47e1c9 Simplify bullet charts as per Mike's suggestions. 2011-04-08 18:37:59 +01:00
Jason Davies 0f82a4d047 Simplify bullet multiples example.
Thanks Mike!
2011-04-08 18:25:08 +01:00
Jason Davies 21c7ec3c26 Bullet charts: title and subtitle support. 2011-04-08 11:24:51 +01:00
Jason Davies 202205fa5e Add some missing semicolons. 2011-04-08 10:56:41 +01:00