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

700 Коммитов

Автор SHA1 Сообщение Дата
Mike Bostock fdd6c62050 Support both open & closed polygons.
Rather than converting closed polygons to open polygons on input (which could
potentially be destructive), tweak the polygon methods slightly so that they
work on either input.

This commit also changes d3.geom.polygon to use a prototype, much like
d3.selection, rather than creating every method as a closure. This makes it much
faster to construct a polygon.
2013-06-28 08:31:16 -07:00
Mike Bostock 5596e4fbc3 Standardize on open polygons. Fixes #443.
If you try to create a d3.geom.polygon with a closed polygon, it is now
automatically converted to an open polygon by stripping the closing coordinate.
2013-06-27 13:29:38 -07:00
Mike Bostock 673c630ee0 Allow console.warn from tests. 2013-06-27 13:28:52 -07:00
Mike Bostock 5b8322aa18 Merge pull request #1339 from trinary/diagonal-test
Adds tests for d3.svg.diagonal
2013-06-26 08:04:35 -07:00
Mike Bostock d524fe5843 Merge branch 'drag-suppress' into 3.2.2 2013-06-25 17:06:36 -07:00
Erik Cunningham 40f5215710 clean up leading whitespace 2013-06-24 16:37:28 -06:00
Erik Cunningham 995c70cf6f simple test coverage of d3.svg.diagonal 2013-06-24 16:35:06 -06:00
Erik Cunningham aa18d82258 test setup for svg.diagonal 2013-06-24 15:28:54 -06:00
Mike Bostock 0b83ad6315 Add tests for transition.{size,node}. 2013-06-20 08:52:00 -07:00
Mike Bostock 61bd91158f Merge branch 'brush-clamp' into 3.2.1 2013-06-19 10:53:03 -07:00
Mike Bostock 301b6d3b42 Restore undefined behavior for d3.bisect.
Rather than return NaN, this change restores the previous undefined behavior
when an unorderable value is used for bisection. After discussing with Jason, I
think this is more consistent given that d3.bisect also requires that the input
array is sortable, and therefore only contains orderable values. Thus, it is the
responsibility of the caller to check that the search value is defined before
doing bisection, and so this commit fixes the threshold scale rather than the
bisect method. (Also, this is consistent with the existing quantile scale.)
2013-06-18 16:16:47 -07:00
Mike Bostock 0edad18326 Return undefined, not NaN.
Since the quantile scale allows arbitrary values in the range, there’s no reason
the return value for unorderable input needs to be a number.
2013-06-18 15:59:16 -07:00
Mike Bostock aad1b18865 Fixes for non-orderable values.
In addition to NaN, which is not equal to itself, you can have objects that are
not orderable due to defined valueOf functions which return NaN. For example:

  var o = new Number(NaN);

Here, o == o is true, but o <= o is false. Therefore it was possible for d3.min,
d3.max and d3.extent to observe these non-orderable values rather than ignore
them as intended. The fix is to check !(o <= o) rather than o == o.

This commit also fixes d3.bisect when the search value is non-orderable.
Previously, bisectLeft returned lo for non-orderable values, and bisectRight
returned hi. However, if the search value is non-orderable, then this return
value does not satisfy the conditions of bisection. This commit changes the
bisection methods to return NaN when the search value is non-orderable.

As a side-effect, the fix to d3.bisect now causes d3.scale.threshold to return
undefined when passed a non-orderable value, such as undefined. (Previously, a
threshold scale would return the highest value in the range, because it used
bisectRight internally.)
2013-06-18 10:27:27 -07:00
Jason Davies 85d156c3f7 brush.clamp: return null if there are no scales.
Similarly, if there are no scales, setting a clamp does nothing.

For consistency with brush.extent.
2013-06-14 10:10:00 +01:00
Mike Bostock f6108db93b Add tests for variable scale.nice. 2013-06-13 15:23:39 -07:00
Mike Bostock a8952189ad Add pack.radius for explicit radius.
Fixes #857. By default, the radius of each circle in the pack layout is derived
from the square root of the node’s value, which is then scaled according to the
bounding box of all circles and the layout’s size. By specifying a radius
function, you can now explictly control the radius, disabling automatic scaling.

The radius function takes the value as input and returns the corresponding
radius. If no radius function is specified, automatic scaling is enabled; this
is the default. Conveniently, d3.scale.sqrt can be used as a radius function.
2013-06-12 13:22:48 -07:00
Jason Davies 864e0da147 Use additional precision for accumulating area.
This uses double the available floating point precision, so that
small floating point errors do not accumulate too quickly.

Fixes #1305.
2013-06-11 10:18:25 +01:00
Jason Davies fff9123f26 Add support for parsing weekdays and week numbers.
Also includes support for parsing "%" literals.
2013-06-08 20:06:31 +01:00
Jason Davies f86be42781 Use point-in-polygon test for winding order.
This point-in-polygon algorithm uses the same area calculation as
d3.geo.area, inlined for performance.

Fixes #1300.
2013-06-08 19:03:16 +01:00
Mike Bostock 3952ae4683 Add missing import. Fixes #1292. 2013-06-03 18:13:28 -07:00
Jason Davies 492215ad42 Add area-weighted geographic polygon centroids.
This generalises the centre of mass formula given in:

  J. E. Brock, The Inertia Tensor for a Spherical Triangle,
  J. Applied Mechanics 42, 239 (1975)

In addition, centroids of zero-extent features now fall back to the
centroid of the feature treated as a lower dimension, i.e. polygons →
lines → points.

Specifically, if the centroid of a polygon or multipolygon feature is
ambiguous, it will treat it as a set of lines.  Similarly (but not
exactly the same), if a line or set of lines has zero length, it will be
treated as a set of points.

This also applies to d3.geo.path.centroid, except that the fallback
always occurs if the feature has zero extent (area or length).  For
geographic polygons, it was simpler to fall back if the centroid was
undefined, as area is not tracked in a simple fashion.

Fixes #1011.

Optimised d3_acos, and used d3_asin and d3_acos where appropriate
instead of Math.min and Math.max.
2013-06-02 10:52:43 +01:00
Mike Bostock c26475a205 Add voronoi.clipExtent; fixes #1267.
This deprecates voronoi.size.
2013-05-30 14:23:50 -07:00
Mike Bostock 1221458a73 Add selection.size. Fixes #1177. 2013-05-30 12:26:24 -07:00
Mike Bostock d976c80449 Merge branch 'quantize-invert' of github.com:scottcheng/d3 into invert-extent 2013-05-30 12:15:22 -07:00
Mike Bostock 34633ae1d4 Add threshold scale invertExtent. Related #1201. 2013-05-30 12:04:35 -07:00
Mike Bostock ae83209409 Merge branch 'fix-centroid' into 3.2 2013-05-30 11:48:44 -07:00
Mike Bostock 12875f46b2 Merge branch 'add-step-middle' of github.com:iterion/d3 into 3.2 2013-05-30 11:45:08 -07:00
Mike Bostock fbf8880a6f Merge branch 'master' of github.com:jisaacks/d3 into 3.2 2013-05-30 11:38:07 -07:00
Mike Bostock 26bbf05a67 Merge branch 'resample-min' into 3.2 2013-05-30 11:34:47 -07:00
Mike Bostock d3c949de52 Merge branch 'quadtree-extent' into 3.2 2013-05-30 11:30:42 -07:00
Mike Bostock c4e4927dd4 Merge branch 'fix-log-tick-format' into 3.2 2013-05-30 11:29:09 -07:00
Mike Bostock f5b72cb5cf Merge branch 'bounds-null' into 3.2 2013-05-30 11:26:43 -07:00
Mike Bostock cffb119746 Merge branch 'fix-time-format-bc-year' into 3.2 2013-05-30 11:26:14 -07:00
Mike Bostock 54dc1d8a16 Merge branch 'fix-voronoi-points' into 3.2 2013-05-30 11:25:12 -07:00
Mike Bostock 8a964987d3 Return ambiguous, rather than undefined, centroid.
This is a fix for #1039, and related to #1037 #1011.
2013-05-30 10:36:04 -07:00
Jason Davies a53c8512e3 Avoid drawing redundant points when resampling. 2013-05-30 10:14:03 -07:00
Jason Davies 77aedd59a9 Enforce minimum sample interval for resampling.
The minimum sample interval is somewhat arbitrarily set to 16 × δ, where
δ is the Douglas–Peucker threshold.  This fixes cases where resampling
stops too early due to the perpendicular distance being below the
threshold; particularly for points that are far apart and whose
great-circle arc is projected to an S-shape.  The midpoint lies along a
straight line, failing the Douglas–Peucker check, but further resampling
produces an S-shape.

Ideally, resampling should also detect cases where an intermediate point
does not need to be drawn, i.e. where there truly is a straight line.
This fix causes points to be drawn at the minimum sample interval, and
thus may degrade performance slightly due to drawing redundant points.

Fixes #1162.
2013-05-30 10:12:43 -07:00
Jason Davies 00d3f44ebd Add benchmark for separate U.S. counties. 2013-05-29 21:13:53 +01:00
Jason Davies 736cad7fbc Cache projection stream in d3.geo.path.
The performance difference seems quite small in V8, but perhaps this
will be more substantial in other browsers, and it should reduce garbage
collection at any rate, which this benchmark does not check thoroughly.

Benchmark, drawing one small circle (10,000 samples):

Old: 0.091ms.
New: 0.084ms.

Fixes #1258.
2013-05-29 19:59:26 +01:00
Mike Bostock 93b8e9d4c8 Merge branch 'fix-voronoi-points' of github.com:notlion/d3 into fix-voronoi-points 2013-05-29 10:49:37 -07:00
Mike Bostock 8dce4f0b88 Format years correctly when negative. Fixes #1254. 2013-05-29 01:08:30 +01:00
Jason Davies 14b17b3329 Fix d3.geo.bounds for null geometries.
This fixes an error that would be thrown if no defined bounds were
found.  It also ensures that undefined bounds are returned as
[[NaN, NaN], [NaN, NaN]], for consistency with d3.extent, which returns
[undefined, undefined] for an empty array.

Fixes #1154.
2013-05-29 00:49:18 +01:00
Ryan Alexander 398b283275 Add test for voronoi links with custom accessors 2013-05-28 16:23:53 -07:00
Mike Bostock 32b1369c99 Merge branch 'fix-xhr-response' into 3.1.10 2013-05-28 15:55:57 -07:00
Mike Bostock 662ff02696 Accept string as log scale tickFormat.
Commit d0441e6 introduced specifying the linear scale tick format as a string,
as by `axis.ticks(10, "%")`. This extends this pattern to log scales for
consistency.
2013-05-28 15:42:29 -07:00
Mike Bostock 00cfa946d0 Remove comment now that order is defined. 2013-05-28 13:57:26 -07:00
Mike Bostock a694b96a3c Fix assumed tween order for transition tests. 2013-05-28 13:50:04 -07:00
Mike Bostock 2e1b96a8e2 Insert new tasks on the end.
This is a partial fix to #1245 whereby timer tasks are now invoked in the order
in which they were registered, rather than in the reverse order. However, a
better fix remains, which is to invoke tasks in the order of their start time
rather than their registration time.
2013-05-28 13:31:23 -07:00
Mike Bostock 64f300141d If xhr.response errors, callback with error.
Fixes #1263. Previously, if d3.json was used to load invalid JSON, a SyntaxError
would be thrown. Now an error is reported to the callback instead, in the same
manner as if a network error occurred. This allows the caller to handle the
invalid response, rather than throwing an asynchronous error.
2013-05-22 17:02:51 -07:00
Mike Bostock eb384180d0 Revert "Define rangeBand in context of rangePoints."
This reverts commit b7f5f30570, which broke the
behavior of the axis component for ordinal scales by changing the meaning of
rangeBand.
2013-05-20 13:36:44 -07:00