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

31 Коммитов

Автор 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 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 c7109df799 Rename for readability. 2011-04-11 12:55:27 -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 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 915be32ef7 Merge branch 'tree' 2011-04-10 18:44:45 -07:00
Mike Bostock f6975bb739 Fix prefix in private functions. 2011-04-10 18:28:59 -07:00
Mike Bostock 2c03029045 Compute wrap-around separation. 2011-04-10 13:56:34 -07:00
Mike Bostock ed1042f395 A tiny bit cleaner. 2011-04-10 13:15:15 -07:00
Mike Bostock 6e901439fd Move temporary state to node._tree. 2011-04-10 13:04:21 -07:00
Mike Bostock 111e8e53e6 More readability improvements. 2011-04-10 12:47:32 -07:00
Mike Bostock ca3c272d98 More readability improvements. 2011-04-10 12:36:58 -07:00
Mike Bostock 3571cc3845 Rewrite `firstWalk` for readability. 2011-04-10 12:16:26 -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
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
Michael Bostock 5f4e950002 Sticky treemap layouts!
The treemap layout can now be set to "sticky" mode, which preserves the row
arrangements from an earlier layout. This is particularly handy for animating
treemaps, as it avoids the temporary occlusion as nodes swap positions. Thanks
to @philogb and the New York Times for the inspiration!
2011-03-14 23:39:11 -07:00
Mike Bostock 52bf6c978a Expose d3.layout.hierarchy.sort.
Also, add nifty transitions to the sunburst example.
2011-03-12 21:14:07 -08:00
Michael Bostock abae3f9263 Add hierarchy & partition layouts.
Also, expose d3.rebind to make it a bit easier to compose classes.
2011-03-12 10:27:05 -08:00
Michael Bostock 166f8b5868 Expose d3.timer, for requestAnimationFrame.
This allows external classes to hook into D3's timer mechanism, such as the
iterative force-directed graph layout.
2011-03-08 23:29:59 -08:00
Michael Bostock 36e935a8c8 Add force & treemap to d3.layout. 2011-03-03 15:43:57 -08:00
Michael Bostock a29c802a77 Sort for layout, but don't reorder.
This fixes a bug in the pie layout sorting where we want the sort order to
affect the layout, but not the order in which arcs are rendered—and furthermore
we want the order of arcs to always match the order of data. (If you want to
sort the data, do that before it is passed to the layout.)
2011-02-24 14:36:57 -08:00
Michael Bostock ade083dd56 More convenient pies.
This adds d3.layout.pie, which can be used to compute the start and end angles
for arcs given an arbitrary array of data. In addition, d3.svg.arc now has a
`centroid` method that computes the center of the arc, useful for labeling.
Together these changes greatly simplify the donut & pie examples.

This commit also includes a `map` method for selections, which is similar to the
`filter` method. This allows you to map the data bound to the current selection.
I'm not currently using it, but it seems like a useful feature for those cases
where you want to rebind the current selection to different (but related) data.
2011-02-24 14:13:05 -08:00
Mike Bostock 59c32fc669 Fix subgroup sorting in chord layout. 2011-02-23 09:09:43 -08:00
Michael Bostock 65307730a3 Add d3.layout.stack, d3.min, d3.max. 2011-01-17 12:27:29 -08:00
Michael Bostock bdcb648849 Turn off the compiler's "advanced" optimizations.
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!
2011-01-05 11:35:39 -08:00
Michael Bostock bbcf25ef7d Fix a bug with zero-duration transitions.
Also, don't generate chords if both the source and target value are zero.
2010-11-28 16:28:48 -08:00
Mike Bostock 6307364a45 Add layout module, with layout.chord class. 2010-11-28 13:15:07 -08:00