Skip to content
Permalink
Browse files

Merge branch '3.4.6'

  • Loading branch information...
mbostock committed Apr 14, 2014
2 parents 624f21c + 55dc3a2 commit 49ba8afebb2ae813ab66dc2f48f533aa7f333c3c
@@ -1,6 +1,6 @@
{
"name": "d3",
"version": "3.4.5",
"version": "3.4.6",
"main": "d3.js",
"scripts": [
"d3.js"
@@ -10,7 +10,7 @@
"animation",
"canvas"
],
"version": "3.4.5",
"version": "3.4.6",
"main": "d3.js",
"scripts": [
"d3.js"
16 d3.js
@@ -1,6 +1,6 @@
!function() {
var d3 = {
version: "3.4.5"
version: "3.4.6"
};
if (!Date.now) Date.now = function() {
return +new Date();
@@ -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;
@@ -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) {
@@ -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) {

Large diffs are not rendered by default.

@@ -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",
@@ -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;
};
@@ -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;
}

@@ -1,6 +1,7 @@
import "../arrays/ascending";
import "../arrays/bisect";
import "../arrays/quantile";
import "../math/number";
import "scale";

d3.scale.quantile = function() {
@@ -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();
};

@@ -1,2 +1,2 @@
!function(){
var d3 = {version: "3.4.5"}; // semver
var d3 = {version: "3.4.6"}; // semver
@@ -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]));
@@ -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) {
@@ -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;
@@ -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));
}
}
}
@@ -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;

0 comments on commit 49ba8af

Please sign in to comment.
You can’t perform that action at this time.