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

126 Коммитов

Автор SHA1 Сообщение Дата
Mike Bostock 6804a60fe4 Fix a bug with empty children arrays. 2011-09-29 21:53:22 -07:00
Mike Bostock 612d23780c Fix a bug when charge forces are zero.
This was causing a divide by zero in the center-of-charge calculation.
2011-09-20 12:19:04 -07:00
Mike Bostock 0a7af55aa9 Fix variable charges for force layout. 2011-09-17 20:32:04 -07:00
Mike Bostock ee10316d97 Merge branch 'pack' of https://github.com/jasondavies/d3 into release 2011-09-17 20:05:09 -07:00
Mike Bostock 76b718092a Remove unused code.
The hierarchy layout is abstract; the nodes method is defined on subclasses.
2011-09-17 19:19:23 -07:00
Jason Davies ab525c4784 Fix empty children handling for revalue.
Also, fix empty children handling for cluster layout.

Tests included.
2011-09-08 08:58:29 +01:00
Jason Davies d024c3f82c Treat nodes with empty children arrays as leaves.
Fixes #286.
2011-09-08 00:26:44 +01:00
Jason Davies 5a69dc80aa Minor optimisation. 2011-09-07 08:55:37 +01:00
Jason Davies 833bc5dddf Fix previous optimisation and add test. 2011-09-03 22:24:10 +01:00
Jason Davies 1e4b11546b Minor optimisation. 2011-09-03 21:48:19 +01:00
Jason Davies d237320c39 Handle zero-valued nodes in d3.layout.pack.
Also fixed handling of empty children array.

Fixes #281.
2011-09-02 11:52:24 +01:00
Mike Bostock 5390ac3f85 Improve stability of charge forces.
Previously, we were modifying the node's x & y position as we were computing
the charge forces. Unfortunately, this causes drift because those positions are
subsequently used to compute other forces. Now we modify the node's previous
position in the opposite direction, which has the same ultimate effect but
improves the stability of the calculation.

This commit also optimizes the force layout such that gravity and charge forces
are not calculated if the corresponding constants are zero.
2011-08-28 09:32:52 -07:00
Mike Bostock 864c3e9114 Fix a bug in link strength scaling.
There was a bug in the previous fix to increase the stability of link
relaxation; the strength of a link would decrease relative to the link degree of
the connected nodes. Instead of decreasing link strength, we should instead bias
the relaxation so that the lighter node moves more than the heavier node, while
preserving the strength of the link.
2011-08-27 11:49:32 -07:00
Jason Davies 04d2d546cf Fix negatively-sized rectangles in treemap.
Includes unit test!

Fixes #136.
2011-08-26 18:46:01 +01:00
Mike Bostock 545e9de74c Merge branch 'drag' of https://github.com/jasondavies/d3 into release
This also fixes a few bugs in the new implementation, restoring support for the
offset between the mouse and the dragged element by reporting a delta rather
than an absolute offset. Also, this fixes an infinite loop when an element is
removed from the DOM.
2011-08-23 12:47:46 -07:00
Mike Bostock b275d26e38 Weight nodes according to number of links.
The previous implementation was very unstable if a large number of nodes were
connected to a single node (a single node connecting many). The problem was that
the single node in the center would be moved many times for each connected node,
never converging to a stable solution. The fix is to weight each node according
to the number of links; in effect, the Gauss-Seidel relaxation then becomes the
average of the connected links, rather than relaxing each link individually.
2011-08-22 13:43:41 -07:00
Mike Bostock 12c5de92bc If fixed is set externally, make it sticky.
Previously, if you set a node to be `fixed`, it was forgotten on mouseover. Now
the preference is sticky. This changes the fixed attribute from a boolean to a
two-bit integer, but truthiness remains for backwards compatibility.
2011-08-22 12:40:45 -07:00
Jason Davies 2ddc0f62e3 Add d3.behavior.drag.
Extracted from d3.layout.force.  Fires "dragstart", "drag" and "dragend"
events, with a "position" property.  Note: this introduces a dependency
on d3.behavior to d3.layout.force if used (in addition to the existing
dependency on d3.geom).

Fixes #249.
2011-08-22 20:30:31 +01:00
Mike Bostock 3c0f29943c Add test for tree layout.
For now, test the bug we just fixed.
2011-08-19 11:01:12 -07:00
Mike Bostock 43aeb6018d Merge branch 'tree-empty-children' into release 2011-08-19 10:57:46 -07:00
Mike Bostock bb289bbdf3 Fix for empty children with tree layout. 2011-08-19 10:10:29 -07:00
Jason Davies 2440287d45 Don't trigger mousemove on mouseup in force layout.
Avoids a spurious layout restart if the mouse hasn't moved.

Fixes #207.
2011-08-19 11:13:22 +01:00
Mike Bostock 37a84d9117 Merge branch 'feature/division-by-zero-in-partition' of https://github.com/maoe/d3 into release 2011-08-15 16:39:11 -07:00
Mike Bostock 67ab76bcc1 Add test for layout.treemap.
Woot! Caught another bug in propagation of NaN node values.
2011-08-15 14:12:17 -07:00
Mitsutoshi Aoe 23d11dadc1 Make combined scripts 2011-08-11 17:22:18 +09:00
Mike Bostock 94f4ed23be Simplify check for zero-area treemap cells. 2011-07-31 16:09:13 -07:00
Jason Davies 7c3adbd771 Fix handling of zero-sized nodes.
Previously, negative or zero sizes were short-circuiting the worst()
function by always returning Infinity, instead of being ignored for the
score computation.

Fixes #233.
2011-07-27 18:22:00 +01:00
Mike Bostock 9af66f9acd Fix a bug in histogram.frequency.
The logic was inverted. Oops! But now there are tests. Yay!
2011-07-20 15:21:09 -07:00
Mike Bostock 6ff9103ef1 Handle padding overflow in treemap layout. 2011-07-20 15:11:07 -07:00
Jason Davies 3c2cb84b95 Fix typo and add padding tests. 2011-07-20 08:07:44 +01:00
Jason Davies 8ed5d42955 Don't add padding to root node.
Also, optimise internal scale() function slightly.
2011-07-19 23:45:15 +01:00
Jason Davies de9d623169 Add some tests for 0, negative or NaN values. 2011-07-19 23:07:05 +01:00
Jason Davies 55b24ff985 Be smart about padding. Thanks, @mbostock. :) 2011-07-19 22:45:57 +01:00
Jason Davies 4b5cd90c1d Improvements to padding, thanks to @mbostock. 2011-07-19 21:58:44 +01:00
Jason Davies 62bcec0998 Add support for padding to treemap layout.
The new "padding" property is an array of [top, right, bottom, left], or a
function that returns such an array for a given node.
2011-07-19 21:35:19 +01:00
Mike Bostock 3d6eba8d19 Merge branch 'force-rangeerror' of https://github.com/jasondavies/d3 into release 2011-07-16 20:40:29 -07:00
Mike Bostock c31902dd3a Merge branch 'treemap' of https://github.com/jasondavies/d3 into release 2011-07-16 20:39:09 -07:00
Mike Bostock 25aa1d4df6 Update generated files. 2011-07-16 20:37:08 -07:00
Jason Davies 54a14c7c68 Prevent RangeError in Safari.
For very large force layouts, Safari was throwing "RangeError: Maximum call
stack size exceeded".  I think this is due to Safari having a smaller call stack
than Chrome and FireFox.  In any case, this fix replaces forEach with a while
loop, which should be faster in all browsers as well as reducing the call stack
size needed and thus fixing the Safari issue.
2011-07-14 10:02:43 +01:00
Jason Davies 45d376dbff Better protection against NaN and negative values.
Also, a more symmetric prevention of NaN in the scoring function from Mike:
"rmax is 0 if and only if s is 0, so it is equivalent".
2011-07-12 18:29:55 +01:00
Jason Davies 006bdfe9b8 Better fix for zero-area nodes.
Instead of filtering them out, we fix the root of the issue instead, which is
that the scoring function "worst" was returning NaN due to calculating 0/0,
instead of Infinity.
2011-07-12 17:32:20 +01:00
Jason Davies ae6ce3f373 Ignore negative areas in treemap layout. 2011-07-12 16:48:27 +01:00
Jason Davies da1006c501 Ignore zero-area nodes in treemap layout. 2011-07-12 16:42:12 +01:00
Mike Bostock aa928b6c3e Merge branch 'jasondavies/force-touch' into release
I simplified the implementation to only support single-touch. I also opted not
to include touch support in the force-dynamic example (and other examples), just
because it complicates the examples too much. Touch is nice but I don't want it
to interfere with people learning the basics.

This merge also has an extra bonus fix: you can now have multiple force layouts
with dragging on the same page, and the drag behavior will do the direct the
event to the appropriate force layout.
2011-07-09 15:55:44 -07:00
Mike Bostock 5c0d8651da Fix offset when dragging large nodes. 2011-07-08 22:39:08 -07:00
Jason Davies 7f8db7fd14 Remove force.gravityCenter.
Simpler to perform gravity calculations in a custom tick handler.
2011-07-09 00:24:17 +01:00
Jason Davies ca8870778a Add per-node gravity: force.gravityCenter.
This allows the Dorling/Demers cartograms to be slightly closer to the real
geography.

Also, fix the Dorling collision detection as self-collisions were previously
being detected.  Thanks, Mike!

Lastly, I've removed the variable per-link distance as this is no longer needed.
2011-07-08 23:23:50 +01:00
Jason Davies 71490ced64 Add missing force.linkStrength property.
Also update examples to use force.linkDistance instead of force.distance.
2011-07-08 21:23:41 +01:00
Jason Davies 6a40609624 Add variable link strength (alpha) to force layout.
Also, rename force.distance to force.linkDistance, but keep force.distance as an
alias for backwards-compatibility.

Fixes #211.
2011-07-08 21:20:38 +01:00
Jason Davies 210fb82616 Replace "new Array" with "[]".
See <http://jsperf.com/new-array-vs-literal/8>.
2011-07-08 21:11:34 +01:00