Skip to content

Commit 840a2d1

Browse files
committed
Merge branch '3.3.12'
2 parents f46d8d2 + bdfe062 commit 840a2d1

File tree

10 files changed

+77
-31
lines changed

10 files changed

+77
-31
lines changed

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "d3",
3-
"version": "3.3.11",
3+
"version": "3.3.12",
44
"main": "d3.js",
55
"scripts": [
66
"d3.js"

component.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"animation",
1111
"canvas"
1212
],
13-
"version": "3.3.11",
13+
"version": "3.3.12",
1414
"main": "index-browserify.js",
1515
"scripts": [
1616
"d3.js",

d3.js

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
d3 = function() {
22
var d3 = {
3-
version: "3.3.11"
3+
version: "3.3.12"
44
};
55
if (!Date.now) Date.now = function() {
66
return +new Date();
@@ -607,7 +607,7 @@ d3 = function() {
607607
d3_selectionPrototype.classed = function(name, value) {
608608
if (arguments.length < 2) {
609609
if (typeof name === "string") {
610-
var node = this.node(), n = (name = name.trim().split(/^|\s+/g)).length, i = -1;
610+
var node = this.node(), n = (name = d3_selection_classes(name)).length, i = -1;
611611
if (value = node.classList) {
612612
while (++i < n) if (!value.contains(name[i])) return false;
613613
} else {
@@ -624,8 +624,11 @@ d3 = function() {
624624
function d3_selection_classedRe(name) {
625625
return new RegExp("(?:^|\\s+)" + d3.requote(name) + "(?:\\s+|$)", "g");
626626
}
627+
function d3_selection_classes(name) {
628+
return name.trim().split(/^|\s+/);
629+
}
627630
function d3_selection_classed(name, value) {
628-
name = name.trim().split(/\s+/).map(d3_selection_classedName);
631+
name = d3_selection_classes(name).map(d3_selection_classedName);
629632
var n = name.length;
630633
function classedConstant() {
631634
var i = -1;
@@ -4166,14 +4169,21 @@ d3 = function() {
41664169
return d3_geo_projection(d3_geo_stereographic);
41674170
}).raw = d3_geo_stereographic;
41684171
function d3_geo_transverseMercator(λ, φ) {
4169-
var B = Math.cos(φ) * Math.sin(λ);
4170-
return [ Math.log((1 + B) / (1 - B)) / 2, Math.atan2(Math.tan(φ), Math.cos(λ)) ];
4172+
return [ Math.log(Math.tan(π / 4 + φ / 2)), -λ ];
41714173
}
41724174
d3_geo_transverseMercator.invert = function(x, y) {
4173-
return [ Math.atan2(d3_sinh(x), Math.cos(y)), d3_asin(Math.sin(y) / d3_cosh(x)) ];
4175+
return [ -y, 2 * Math.atan(Math.exp(x)) - halfπ ];
41744176
};
41754177
(d3.geo.transverseMercator = function() {
4176-
return d3_geo_mercatorProjection(d3_geo_transverseMercator);
4178+
var projection = d3_geo_mercatorProjection(d3_geo_transverseMercator), center = projection.center, rotate = projection.rotate;
4179+
projection.center = function(_) {
4180+
return _ ? center([ -_[1], _[0] ]) : (_ = center(), [ -_[1], _[0] ]);
4181+
};
4182+
projection.rotate = function(_) {
4183+
return _ ? rotate([ _[0], _[1], _.length > 2 ? _[2] + 90 : 90 ]) : (_ = rotate(),
4184+
[ _[0], _[1], _[2] - 90 ]);
4185+
};
4186+
return projection.rotate([ 0, 0 ]);
41774187
}).raw = d3_geo_transverseMercator;
41784188
d3.geom = {};
41794189
function d3_geom_pointX(d) {
@@ -6847,10 +6857,16 @@ d3 = function() {
68476857
return Math.exp(random());
68486858
};
68496859
},
6860+
bates: function(m) {
6861+
var random = d3.random.irwinHall(m);
6862+
return function() {
6863+
return random() / m;
6864+
};
6865+
},
68506866
irwinHall: function(m) {
68516867
return function() {
68526868
for (var s = 0, j = 0; j < m; j++) s += Math.random();
6853-
return s / m;
6869+
return s;
68546870
};
68556871
}
68566872
};

d3.min.js

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "d3",
3-
"version": "3.3.11",
3+
"version": "3.3.12",
44
"description": "A small, free JavaScript library for manipulating documents based on data.",
55
"keywords": [
66
"dom",

src/geo/transverse-mercator.js

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,31 @@
11
import "../math/trigonometry";
22
import "geo";
33
import "mercator";
4-
import "projection";
54

65
function d3_geo_transverseMercator(λ, φ) {
7-
var B = Math.cos(φ) * Math.sin(λ);
8-
return [
9-
Math.log((1 + B) / (1 - B)) / 2,
10-
Math.atan2(Math.tan(φ), Math.cos(λ))
11-
];
6+
return [Math.log(Math.tan(π / 4 + φ / 2)), -λ];
127
}
138

149
d3_geo_transverseMercator.invert = function(x, y) {
15-
return [
16-
Math.atan2(d3_sinh(x), Math.cos(y)),
17-
d3_asin(Math.sin(y) / d3_cosh(x))
18-
];
10+
return [-y, 2 * Math.atan(Math.exp(x)) - halfπ];
1911
};
2012

2113
(d3.geo.transverseMercator = function() {
22-
return d3_geo_mercatorProjection(d3_geo_transverseMercator);
14+
var projection = d3_geo_mercatorProjection(d3_geo_transverseMercator),
15+
center = projection.center,
16+
rotate = projection.rotate;
17+
18+
projection.center = function(_) {
19+
return _
20+
? center([-_[1], _[0]])
21+
: ((_ = center()), [-_[1], _[0]]);
22+
};
23+
24+
projection.rotate = function(_) {
25+
return _
26+
? rotate([_[0], _[1], _.length > 2 ? _[2] + 90 : 90])
27+
: ((_ = rotate()), [_[0], _[1], _[2] - 90]);
28+
};
29+
30+
return projection.rotate([0, 0]);
2331
}).raw = d3_geo_transverseMercator;

src/math/random.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,16 @@ d3.random = {
1919
return Math.exp(random());
2020
};
2121
},
22+
bates: function(m) {
23+
var random = d3.random.irwinHall(m);
24+
return function() {
25+
return random() / m;
26+
};
27+
},
2228
irwinHall: function(m) {
2329
return function() {
2430
for (var s = 0, j = 0; j < m; j++) s += Math.random();
25-
return s / m;
31+
return s;
2632
};
2733
}
2834
};

src/selection/classed.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ d3_selectionPrototype.classed = function(name, value) {
1010
// probably doesn't support it on SVG elements (which can be animated).
1111
if (typeof name === "string") {
1212
var node = this.node(),
13-
n = (name = name.trim().split(/^|\s+/g)).length,
13+
n = (name = d3_selection_classes(name)).length,
1414
i = -1;
1515
if (value = node.classList) {
1616
while (++i < n) if (!value.contains(name[i])) return false;
@@ -35,9 +35,13 @@ function d3_selection_classedRe(name) {
3535
return new RegExp("(?:^|\\s+)" + d3.requote(name) + "(?:\\s+|$)", "g");
3636
}
3737

38+
function d3_selection_classes(name) {
39+
return name.trim().split(/^|\s+/);
40+
}
41+
3842
// Multiple class names are allowed (e.g., "foo bar").
3943
function d3_selection_classed(name, value) {
40-
name = name.trim().split(/\s+/).map(d3_selection_classedName);
44+
name = d3_selection_classes(name).map(d3_selection_classedName);
4145
var n = name.length;
4246

4347
function classedConstant() {

src/start.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
d3 = (function(){
2-
var d3 = {version: "3.3.11"}; // semver
2+
var d3 = {version: "3.3.12"}; // semver

test/selection/classed-test.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,18 @@ suite.addBatch({
8989
body.classed("\tfoo foo ", false);
9090
assert.equal(body.node().className, "");
9191
},
92+
"accepts an empty name, doing nothing or returning true": function(body) {
93+
body.attr("class", null);
94+
body.classed("", true);
95+
assert.equal(body.node().className, "");
96+
assert.isTrue(body.classed(""));
97+
body.classed(" \t ", true);
98+
assert.equal(body.node().className, "");
99+
assert.isTrue(body.classed(""));
100+
body.classed("", false);
101+
assert.equal(body.node().className, "");
102+
assert.isTrue(body.classed(""));
103+
},
92104
"accepts a value function returning true or false": function(body) {
93105
body.attr("class", null);
94106
body.classed("foo", function() { return true; });

0 commit comments

Comments
 (0)