Skip to content

Commit

Permalink
Merge branch '3.4.6'
Browse files Browse the repository at this point in the history
  • Loading branch information
mbostock committed Apr 14, 2014
2 parents 624f21c + 55dc3a2 commit 49ba8af
Show file tree
Hide file tree
Showing 14 changed files with 34 additions and 37 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "d3",
"version": "3.4.5",
"version": "3.4.6",
"main": "d3.js",
"scripts": [
"d3.js"
Expand Down
2 changes: 1 addition & 1 deletion component.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"animation",
"canvas"
],
"version": "3.4.5",
"version": "3.4.6",
"main": "d3.js",
"scripts": [
"d3.js"
Expand Down
16 changes: 7 additions & 9 deletions d3.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
!function() {
var d3 = {
version: "3.4.5"
version: "3.4.6"
};
if (!Date.now) Date.now = function() {
return +new Date();
Expand Down Expand Up @@ -91,13 +91,13 @@
return x != null && !isNaN(x);
}
d3.mean = function(array, f) {
var n = array.length, a, m = 0, i = -1, j = 0;
var s = 0, n = array.length, a, i = -1, j = n;
if (arguments.length === 1) {
while (++i < n) if (d3_number(a = array[i])) m += (a - m) / ++j;
while (++i < n) if (d3_number(a = array[i])) s += a; else --j;
} else {
while (++i < n) if (d3_number(a = f.call(array, array[i], i))) m += (a - m) / ++j;
while (++i < n) if (d3_number(a = f.call(array, array[i], i))) s += a; else --j;
}
return j ? m : undefined;
return j ? s / j : undefined;
};
d3.quantile = function(values, p) {
var H = (values.length - 1) * p + 1, h = Math.floor(H), v = +values[h - 1], e = H - h;
Expand Down Expand Up @@ -2675,7 +2675,7 @@
return n ? (date.y = d3_time_expandYear(+n[0]), i + n[0].length) : -1;
}
function d3_time_parseZone(date, string, i) {
return /^[+-]\d{4}$/.test(string = string.substring(i, i + 5)) ? (date.Z = +string,
return /^[+-]\d{4}$/.test(string = string.substring(i, i + 5)) ? (date.Z = -string,
i + 5) : -1;
}
function d3_time_expandYear(d) {
Expand Down Expand Up @@ -7703,9 +7703,7 @@
}
scale.domain = function(x) {
if (!arguments.length) return domain;
domain = x.filter(function(d) {
return !isNaN(d);
}).sort(d3_ascending);
domain = x.filter(d3_number).sort(d3_ascending);
return rescale();
};
scale.range = function(x) {
Expand Down
10 changes: 5 additions & 5 deletions d3.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "d3",
"version": "3.4.5",
"version": "3.4.6",
"description": "A small, free JavaScript library for manipulating documents based on data.",
"keywords": [
"dom",
Expand Down
12 changes: 6 additions & 6 deletions src/arrays/mean.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import "../math/number";

d3.mean = function(array, f) {
var n = array.length,
var s = 0,
n = array.length,
a,
m = 0,
i = -1,
j = 0;
j = n;
if (arguments.length === 1) {
while (++i < n) if (d3_number(a = array[i])) m += (a - m) / ++j;
while (++i < n) if (d3_number(a = array[i])) s += a; else --j;
} else {
while (++i < n) if (d3_number(a = f.call(array, array[i], i))) m += (a - m) / ++j;
while (++i < n) if (d3_number(a = f.call(array, array[i], i))) s += a; else --j;
}
return j ? m : undefined;
return j ? s / j : undefined;
};
2 changes: 1 addition & 1 deletion src/locale/time-format.js
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ function d3_time_parseYear(date, string, i) {

function d3_time_parseZone(date, string, i) {
return /^[+-]\d{4}$/.test(string = string.substring(i, i + 5))
? (date.Z = +string, i + 5)
? (date.Z = -string, i + 5) // sign differs from getTimezoneOffset!
: -1;
}

Expand Down
3 changes: 2 additions & 1 deletion src/scale/quantile.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import "../arrays/ascending";
import "../arrays/bisect";
import "../arrays/quantile";
import "../math/number";
import "scale";

d3.scale.quantile = function() {
Expand All @@ -24,7 +25,7 @@ function d3_scale_quantile(domain, range) {

scale.domain = function(x) {
if (!arguments.length) return domain;
domain = x.filter(function(d) { return !isNaN(d); }).sort(d3_ascending);
domain = x.filter(d3_number).sort(d3_ascending);
return rescale();
};

Expand Down
2 changes: 1 addition & 1 deletion src/start.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
!function(){
var d3 = {version: "3.4.5"}; // semver
var d3 = {version: "3.4.6"}; // semver
4 changes: 0 additions & 4 deletions test/arrays/mean-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@ suite.addBatch({
assert.equal(mean([1, 2, 3, 4, 5, NaN]), 3);
assert.equal(mean([10, null, 3, undefined, 5, NaN]), 6);
},
"can handle large numbers without overflowing": function(mean) {
assert.equal(mean([Number.MAX_VALUE, Number.MAX_VALUE]), Number.MAX_VALUE);
assert.equal(mean([-Number.MAX_VALUE, -Number.MAX_VALUE]), -Number.MAX_VALUE);
},
"returns undefined for empty array": function(mean) {
assert.isUndefined(mean([]));
assert.isUndefined(mean([null]));
Expand Down
2 changes: 1 addition & 1 deletion test/scale/quantile-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ suite.addBatch({
assert.deepEqual(x.domain(), [3, 6, 7, 8, 8, 10, 13, 15, 16, 20]);
},
"non-numeric domain values are ignored": function(quantile) {
var x = quantile().domain([6, 3, NaN, undefined, 7, 8, 8, 13, 20, 15, 16, 10, NaN]);
var x = quantile().domain([6, 3, NaN, undefined, 7, 8, 8, 13, null, 20, 15, 16, 10, NaN]);
assert.deepEqual(x.domain(), [3, 6, 7, 8, 8, 10, 13, 15, 16, 20]);
},
"quantiles returns the inner thresholds": function(quantile) {
Expand Down
5 changes: 3 additions & 2 deletions test/time/format-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -328,8 +328,9 @@ suite.addBatch({
"parses timezone offset": function(format) {
var p = format("%m/%d/%Y %Z").parse;
assert.deepEqual(p("01/02/1990 +0000"), local(1990, 0, 1, 16));
assert.deepEqual(p("01/02/1990 +0100"), local(1990, 0, 1, 17));
assert.deepEqual(p("01/02/1990 -0100"), local(1990, 0, 1, 15));
assert.deepEqual(p("01/02/1990 +0100"), local(1990, 0, 1, 15));
assert.deepEqual(p("01/02/1990 -0100"), local(1990, 0, 1, 17));
assert.deepEqual(p("01/02/1990 -0800"), local(1990, 0, 2, 0));
},
"ignores optional padding modifier, skipping zeroes and spaces": function(format) {
var p = format("%-m/%0d/%_Y").parse;
Expand Down
5 changes: 3 additions & 2 deletions test/time/format-utc-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,9 @@ suite.addBatch({
"parses timezone offset": function(format) {
var p = format("%m/%d/%Y %Z").parse;
assert.deepEqual(p("01/02/1990 +0000"), utc(1990, 0, 2));
assert.deepEqual(p("01/02/1990 +0100"), utc(1990, 0, 2, 1));
assert.deepEqual(p("01/02/1990 -0100"), utc(1990, 0, 1, 23));
assert.deepEqual(p("01/02/1990 +0100"), utc(1990, 0, 1, 23));
assert.deepEqual(p("01/02/1990 -0100"), utc(1990, 0, 2, 1));
assert.deepEqual(p("01/02/1990 -0800"), time.local(1990, 0, 2));
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions test/time/time.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
var offset = 0;

exports.local = function(year, month, day, hours, minutes, seconds, milliseconds) {
var date = new Date();
var date = new Date;
date.setFullYear(year, month, day);
date.setHours(hours || 0, offset + (minutes || 0), seconds || 0, milliseconds || 0);
return date;
};

exports.utc = function(year, month, day, hours, minutes, seconds, milliseconds) {
var date = new Date();
var date = new Date;
date.setUTCFullYear(year, month, day);
date.setUTCHours(hours || 0, minutes || 0, seconds || 0, milliseconds || 0);
return date;
Expand Down

0 comments on commit 49ba8af

Please sign in to comment.