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

1411 Коммитов

Автор SHA1 Сообщение Дата
Mike Bostock 74aaf245d0 Use d3_numeric for !isNaN. 2014-10-16 23:20:36 -07:00
Mike Bostock 57e07f9211 Rename `array1` to `numbers`. 2014-10-16 23:15:57 -07:00
Mike Bostock ad7e17d4a9 Merge branch 'axis-finite' into 3.4.13 2014-10-16 23:04:51 -07:00
Mike Bostock f1bb569074 Merge branch 'fix-format' into 3.4.13 2014-10-16 23:04:11 -07:00
Mike Bostock 2af1d30640 Merge branch 'interpolate-precision' into 3.4.13 2014-10-16 23:03:41 -07:00
Mike Bostock 669b934fac Merge branch 'stack-empty' into 3.4.13 2014-10-16 23:02:59 -07:00
Mike Bostock c4870f4e72 Merge branch 'fix-falsey-dsv-accessor' into 3.4.13 2014-10-16 23:02:25 -07:00
Mike Bostock 4c62314c3d Merge branch 'fix-hcl-lab' into 3.4.13 2014-10-16 23:01:34 -07:00
Mike Bostock a18b3f33dc Merge branch 'fix-mean-string' into 3.4.13 2014-10-16 23:00:51 -07:00
Mike Bostock 84e242f9e9 Merge branch 'optimize-axis' into 3.4.13 2014-10-16 23:00:20 -07:00
Mike Bostock a64f6df7b2 set.add should return the string-coerced value. 2014-10-16 22:24:52 -07:00
Mike Bostock a7cb015ce8 Object.defineProperty is now required.
Since d3.map and d3.set now rely on Object.create(null), we also now rely on
Object.defineProperty to create non-enumerable properties.
2014-10-16 22:16:51 -07:00
Mike Bostock d9f6288c24 Always escape __proto__ in d3.{map,set}.
Rather than conditionally checking for it and changing the class definition,
just be pessimissitic and assume that it’s a bad idea to set __proto__.
2014-10-16 22:07:48 -07:00
Mike Bostock 09f43b1b4f Merge branch 'optimize-data' into optimize-map-create-null
Conflicts:
	src/selection/data.js
2014-10-16 22:00:33 -07:00
Mike Bostock cd21deaf80 Consolidate duplicate code. 2014-10-16 21:40:06 -07:00
Mike Bostock eaed66d4b6 Coerce quantile scale domain to numbers.
Also only coerce values to numbers once in d3.{mean,median}.
2014-10-16 21:17:40 -07:00
Jason Davies d3ed04db68 Fix d3.format with explicit "-" sign.
The default behaviour is to only use a minus sign for negative numbers.
However, when this behaviour was explicitly specified using "-", this
caused positive numbers to become negative.

Fixes #2072.
2014-10-17 00:14:57 +01:00
Jason Davies 4e5deb09aa Fix d3.median: coerce strings to numbers.
Fixes #2069.
2014-10-16 09:44:25 +01:00
Jason Davies dd1e9165c9 Fix d3.mean: coerce strings to numbers.
Fixes #2067.
2014-10-16 09:16:21 +01:00
Mike Bostock 4c14f5ff6a Fix for "__proto__" in Object.create(null).
Blech.
2014-10-15 10:20:56 -07:00
Mike Bostock 9bcc57c7ab Use Object.create(null) for maps. 2014-10-15 09:53:45 -07:00
Mike Bostock 85e4c50b67 Reformat slightly. 2014-10-14 10:20:43 -07:00
Mike Bostock 067de6dfea Slight simplification. 2014-10-14 10:15:10 -07:00
Mike Bostock 9a3de7d775 Optimize d3.{map,set}.
Rather than always escaping keys with a null-prefix, only escape keys that can
conflict with built-in properties (either on Object, d3_Map or d3_Set). By only
prefixing these special keys, we can avoid the cost of constructing new strings
in the common case.

To check whether a key is special, we check whether it is in an empty map
instance. In addition, keys that are already null-prefixed must be prefixed a
second time to correctly unescape.
2014-10-14 10:13:12 -07:00
John Firebaugh acfbdd4946 Optimize selection.data(values, key)
Preallocate the keyValues array and use a single Map with the
sentinel value `true` to represent a previously seen key.

Before:

selection.data(values, key) (enter) 1.5ms/op.
selection.data(values, key) (update) 1.7ms/op.

After:

selection.data(values, key) (enter) 0.81ms/op.
selection.data(values, key) (update) 1.1ms/op.
2014-10-13 18:20:40 -07:00
Mike Bostock b6b80f7270 Fix d3.lab(d3.hcl(…)).
Due to the tests using two different copies of d3 (one loaded via require, and
the other via smash), the instanceof check in the d3.lab constructor was
returning false when testing for d3.hcl, and this constructor was therefore
never tested.
2014-10-13 14:34:12 -07:00
Jason Davies 037063c41c Save a whopping 12 bytes! 2014-10-10 19:12:44 +01:00
Mike Bostock 9592f9b8fd No d3_zero. 2014-10-10 10:59:49 -07:00
Jason Davies 1531870f0c Slightly simpler version using d3_zero.
As suggested by @mbostock.  Note that we preserve the behaviour for
ranges that are coerced to NaNs.
2014-10-10 17:53:19 +01:00
Mike Bostock 35e26d58b7 Fix #2010 - check for nully, not falsey. 2014-10-10 09:21:20 -07:00
Jason Davies d21da02fd2 Fix d3.layout.stack for empty input array.
Fixes #2004.
2014-10-10 11:04:30 +01:00
Jason Davies a4429fa041 Fix #2039: improve [un]interpolateNumber precision.
* uninterpolate:

The use of a reciprocal in d3_uninterpolateNumber to avoid division
results in a small loss of precision (the following is a paraphrase):

  function d3_uninterpolateNumber(a, b) {
    var k = b - a ? 1 / (b - a) : 0;
    return function(x) { return (x - a) * k; };
  }

For x = a, there is no problem, since u = (a - a) * k = 0 * k = 0 as
expected.  For x = b, we have u = (b - a) * k, and since k cannot
represent 1 / (b - a) exactly, we don’t get u = 1, but something very
close to 1.

Instead, if we perform the division within the generated function, we
can ensure we always get u = 1 for x = b:

  function d3_uninterpolateNumber(a, b) {
    var k = b - a || Infinity;
    return function(x) { return (x - a) / k; };
  }

Again, for x = a, we simply have u = (a - a) / k = 0.  For x = b, we
have u = (b - a) / k = (b - a) / (b - a) = 1.

* interpolate:

Similarly, for d3_interpolateNumber, we have a small loss of precision,
this time due to subtraction.  Paraphrased:

  function d3_interpolateNumber(a, b) {
    var d = b - a;
    return function(t) { return a + t * d; };
  }

There is no issue for t = 0, because we always get i = a + 0 * d = a.
However, for t = 1, we get i = a + d, which might not be exactly equal
to b as desired.  The following will return precisely b for t = 1:

  function d3_interpolateNumber(a, b) {
    return function(t) { return a * (1 - t) + b * t; };
  }
2014-10-10 10:40:59 +01:00
Jason Davies 28c65bb9ba Fix group formatting and padding.
Very small or large numbers use exponent notation when converted to
strings.  If grouping is enabled and there is no decimal, the exponent
wasn’t being ignored, so the group separator was in the wrong place.

This also fixes a bug relating to padding and thousands grouping: the
padding calculation assumed a grouping of [3].

Fixes #1972, #1994.
2014-10-10 09:41:24 +01:00
Mike Bostock c3ac0e9eb0 Oops, too short. 2014-10-09 09:13:04 -07:00
Mike Bostock 5ad5ddde19 Shorten. 2014-10-09 09:10:51 -07:00
Jason Davies 2e56709361 d3.svg.axis: avoid setting invalid transform attr.
Fixes #1968.  For example, when switching from a linear scale to a
logarithmic scale, some of the exiting ticks might be positioned at
Infinity in the new scale (zero and negative numbers).  This can cause a
warning to be logged in the console due to the resulting invalid
transform attribute.  The warning doesn’t prevent the rest of the axis
from functioning normally (even though it is logged as an “error”), but
it is preferable to avoid setting invalid attributes.
2014-10-09 15:14:29 +01:00
Mike Bostock ac7fb154fa Bump version. 2014-10-08 08:09:42 -07:00
Mike Bostock 9b747deb23 Merge branch 'fix-zoom-touch-chrome' into 3.4.12 2014-10-08 08:04:33 -07:00
Mike Bostock 6b61f60e26 Save two minified bytes. 2014-10-08 08:03:32 -07:00
Mike Bostock 056c488350 Merge remote-tracking branch 'origin/fix-imports' into 3.4.12 2014-10-08 07:58:29 -07:00
Mike Bostock 98e7d4bde2 Merge remote-tracking branch 'origin/slice' into 3.4.12 2014-10-08 07:49:11 -07:00
Mike Bostock 3bbcd57b99 Merge remote-tracking branch 'origin/fix-xhr-notext' into 3.4.12 2014-10-08 07:47:58 -07:00
Mike Bostock d62f3d44db Merge remote-tracking branch 'origin/fix-timezone-parse' into 3.4.12 2014-10-08 07:46:42 -07:00
Jason Davies a35000b744 Fix #2043: selection.enter.size. 2014-10-03 22:05:25 +01:00
Jason Davies 08353a40bc Fix #2040: parsing time zone offsets.
There was a bug when parsing positive time zone offsets with a non-zero
number of minutes: the use of Math.floor on negative numbers rounded in
the wrong direction.  Replacing Math.floor with (x | 0) correctly
truncates positive and negative values.
2014-09-30 00:07:18 +01:00
Jason Davies 61e469388a Workaround for Chrome touchmove issue 412723.
Fixes #2013.
2014-09-10 12:00:54 +01:00
Jason Davies 519f258ff4 Replace substring with slice.
Slice is shorter and more intuitive: negative arguments are treated as
being relative to the end of the string, similar to arrays.

The only place it made sense to keep substring was in
d3_locale_numberFormat, where the first argument can be negative but
substring automatically treats this as zero.
2014-08-06 17:55:22 +01:00
Jason Davies 03e74cbe72 Fix a few imports. 2014-08-05 20:55:48 +01:00
Jason Davies f7d39bac48 Fix InvalidStateError for non-text local files.
Fixes a regression introduced when XDomainRequest support was added in
2eeb2057b2.  XDomainRequest only supports
request.responseText, not request.response, but XMLHttpRequest throws an
error if request.responseText is read for non-text response types.

A status code of 0 can mean either a local file was accessed, or there
was an error.  The response is checked to see if the error flag was set:

* In the case of request.responseType being "text" or "",
  request.responseText should be "".  Unfortunately it’s impossible to
  distinguish between an empty local text file and an error state, but
  wanting to load empty local files seems rare.
  XDomainRequest doesn’t have a responseType and it only has
  responseText, so we handle it here too.

* For other response types, request.response should be null.  At the
  moment, Safari 7.0.5 doesn’t respect this, e.g. the response will be a
  zero-length blob for the "blob" response type if the local file wasn’t
  found, but this seems to be fixed as of WebKit r171650.
2014-07-29 18:20:08 +01:00
Mike Bostock 48ad44fdee Merge branch 'fix-transverse-mercator-center' 2014-07-17 15:58:17 -07:00