Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch '3.0.1'

  • Loading branch information...
commit d2ad9f7942d236cf1f14fd4cde1764e3252fcceb 2 parents 74582d8 + 8b0c10f
Mike Bostock authored
2  component.json
View
@@ -1,5 +1,5 @@
{
"name": "d3",
- "version": "3.0.0",
+ "version": "3.0.1",
"main": "./d3.js"
}
37 d3.js
View
@@ -12,7 +12,7 @@
};
}
d3 = {
- version: "3.0.0"
+ version: "3.0.1"
};
var π = Math.PI, ε = 1e-6, d3_radians = π / 180, d3_degrees = 180 / π;
function d3_target(d) {
@@ -5092,7 +5092,7 @@
function squarify(node) {
var children = node.children;
if (children && children.length) {
- var rect = pad(node), row = [], remaining = children.slice(), child, best = Infinity, score, u = mode === "slice" ? rect.dx : mode === "dice" || mode === "slice-dice" && node.depth & 1 ? rect.dy : Math.min(rect.dx, rect.dy), n;
+ var rect = pad(node), row = [], remaining = children.slice(), child, best = Infinity, score, u = mode === "slice" ? rect.dx : mode === "dice" ? rect.dy : mode === "slice-dice" ? node.depth & 1 ? rect.dy : rect.dx : Math.min(rect.dx, rect.dy), n;
scale(remaining, rect.dx * rect.dy / node.value);
row.area = 0;
while ((n = remaining.length) > 0) {
@@ -5348,10 +5348,6 @@
FeatureCollection: function(object, listener) {
var features = object.features, i = -1, n = features.length;
while (++i < n) d3_geo_streamGeometry(features[i].geometry, listener);
- },
- GeometryCollection: function(object, listener) {
- var geometries = object.geometries, i = -1, n = geometries.length;
- while (++i < n) d3_geo_streamGeometry(geometries[i], listener);
}
};
var d3_geo_streamGeometryType = {
@@ -5379,6 +5375,10 @@
MultiPolygon: function(object, listener) {
var coordinates = object.coordinates, i = -1, n = coordinates.length;
while (++i < n) d3_geo_streamPolygon(coordinates[i], listener);
+ },
+ GeometryCollection: function(object, listener) {
+ var geometries = object.geometries, i = -1, n = geometries.length;
+ while (++i < n) d3_geo_streamGeometry(geometries[i], listener);
}
};
function d3_geo_streamLine(coordinates, listener, closed) {
@@ -5597,12 +5597,20 @@
};
var d3_geo_centroidDimension, d3_geo_centroidW, d3_geo_centroidX, d3_geo_centroidY, d3_geo_centroidZ;
var d3_geo_centroid = {
- sphere: d3_noop,
+ sphere: function() {
+ if (d3_geo_centroidDimension < 2) {
+ d3_geo_centroidDimension = 2;
+ d3_geo_centroidW = d3_geo_centroidX = d3_geo_centroidY = d3_geo_centroidZ = 0;
+ }
+ },
point: d3_geo_centroidPoint,
lineStart: d3_geo_centroidLineStart,
lineEnd: d3_geo_centroidLineEnd,
polygonStart: function() {
- d3_geo_centroidDimension = 2;
+ if (d3_geo_centroidDimension < 2) {
+ d3_geo_centroidDimension = 2;
+ d3_geo_centroidW = d3_geo_centroidX = d3_geo_centroidY = d3_geo_centroidZ = 0;
+ }
d3_geo_centroid.lineStart = d3_geo_centroidRingStart;
},
polygonEnd: function() {
@@ -5620,10 +5628,6 @@
}
function d3_geo_centroidRingStart() {
var λ00, φ00;
- if (d3_geo_centroidDimension < 2) {
- d3_geo_centroidDimension = 2;
- d3_geo_centroidW = d3_geo_centroidX = d3_geo_centroidY = d3_geo_centroidZ = 0;
- }
d3_geo_centroidDimension = 1;
d3_geo_centroidLineStart();
d3_geo_centroidDimension = 2;
@@ -5639,11 +5643,10 @@
}
function d3_geo_centroidLineStart() {
var x0, y0, z0;
- if (d3_geo_centroidDimension !== 1) {
- if (d3_geo_centroidDimension < 1) {
- d3_geo_centroidDimension = 1;
- d3_geo_centroidW = d3_geo_centroidX = d3_geo_centroidY = d3_geo_centroidZ = 0;
- } else return;
+ if (d3_geo_centroidDimension > 1) return;
+ if (d3_geo_centroidDimension < 1) {
+ d3_geo_centroidDimension = 1;
+ d3_geo_centroidW = d3_geo_centroidX = d3_geo_centroidY = d3_geo_centroidZ = 0;
}
d3_geo_centroid.point = function(λ, φ) {
λ *= d3_radians;
6 d3.min.js
View
3 additions, 3 deletions not shown
2  package.json
View
@@ -1,6 +1,6 @@
{
"name": "d3",
- "version": "3.0.0",
+ "version": "3.0.1",
"description": "A small, free JavaScript library for manipulating documents based on data.",
"keywords": [
"dom",
2  src/core/core.js
View
@@ -1,4 +1,4 @@
-d3 = {version: "3.0.0"}; // semver
+d3 = {version: "3.0.1"}; // semver
var π = Math.PI,
ε = 1e-6,
25 src/geo/centroid.js
View
@@ -18,12 +18,20 @@ var d3_geo_centroidDimension,
d3_geo_centroidZ;
var d3_geo_centroid = {
- sphere: d3_noop,
+ sphere: function() {
+ if (d3_geo_centroidDimension < 2) {
+ d3_geo_centroidDimension = 2;
+ d3_geo_centroidW = d3_geo_centroidX = d3_geo_centroidY = d3_geo_centroidZ = 0;
+ }
+ },
point: d3_geo_centroidPoint,
lineStart: d3_geo_centroidLineStart,
lineEnd: d3_geo_centroidLineEnd,
polygonStart: function() {
- d3_geo_centroidDimension = 2;
+ if (d3_geo_centroidDimension < 2) {
+ d3_geo_centroidDimension = 2;
+ d3_geo_centroidW = d3_geo_centroidX = d3_geo_centroidY = d3_geo_centroidZ = 0;
+ }
d3_geo_centroid.lineStart = d3_geo_centroidRingStart;
},
polygonEnd: function() {
@@ -45,10 +53,6 @@ function d3_geo_centroidPoint(λ, φ) {
function d3_geo_centroidRingStart() {
var λ00, φ00; // first point
- if (d3_geo_centroidDimension < 2) {
- d3_geo_centroidDimension = 2;
- d3_geo_centroidW = d3_geo_centroidX = d3_geo_centroidY = d3_geo_centroidZ = 0;
- }
d3_geo_centroidDimension = 1;
d3_geo_centroidLineStart();
d3_geo_centroidDimension = 2;
@@ -67,11 +71,10 @@ function d3_geo_centroidRingStart() {
function d3_geo_centroidLineStart() {
var x0, y0, z0; // previous point
- if (d3_geo_centroidDimension !== 1) {
- if (d3_geo_centroidDimension < 1) {
- d3_geo_centroidDimension = 1;
- d3_geo_centroidW = d3_geo_centroidX = d3_geo_centroidY = d3_geo_centroidZ = 0;
- } else return;
+ if (d3_geo_centroidDimension > 1) return;
+ if (d3_geo_centroidDimension < 1) {
+ d3_geo_centroidDimension = 1;
+ d3_geo_centroidW = d3_geo_centroidX = d3_geo_centroidY = d3_geo_centroidZ = 0;
}
d3_geo_centroid.point = function(λ, φ) {
8 src/geo/stream.js
View
@@ -19,10 +19,6 @@ var d3_geo_streamObjectType = {
FeatureCollection: function(object, listener) {
var features = object.features, i = -1, n = features.length;
while (++i < n) d3_geo_streamGeometry(features[i].geometry, listener);
- },
- GeometryCollection: function(object, listener) {
- var geometries = object.geometries, i = -1, n = geometries.length;
- while (++i < n) d3_geo_streamGeometry(geometries[i], listener);
}
};
@@ -51,6 +47,10 @@ var d3_geo_streamGeometryType = {
MultiPolygon: function(object, listener) {
var coordinates = object.coordinates, i = -1, n = coordinates.length;
while (++i < n) d3_geo_streamPolygon(coordinates[i], listener);
+ },
+ GeometryCollection: function(object, listener) {
+ var geometries = object.geometries, i = -1, n = geometries.length;
+ while (++i < n) d3_geo_streamGeometry(geometries[i], listener);
}
};
3  src/layout/treemap.js
View
@@ -34,7 +34,8 @@ d3.layout.treemap = function() {
best = Infinity, // the best row score so far
score, // the current row score
u = mode === "slice" ? rect.dx
- : mode === "dice" || mode === "slice-dice" && node.depth & 1 ? rect.dy
+ : mode === "dice" ? rect.dy
+ : mode === "slice-dice" ? node.depth & 1 ? rect.dy : rect.dx
: Math.min(rect.dx, rect.dy), // initial orientation
n;
scale(remaining, rect.dx * rect.dy / node.value);
23 test/geo/bounds-test.js
View
@@ -90,6 +90,29 @@ suite.addBatch({
type: "Polygon",
coordinates: [[[-123, 39], [-122, 39], [-122, 38], [-123, 39]], [[10, 20], [20, 20], [20, 10], [10, 10], [10, 20]]]
}), [[-123, 38], [-122, 39]])
+ },
+ "NestedCollection": function (bounds) {
+ assert.deepEqual(bounds({
+ type: "FeatureCollection",
+ features: [
+ {
+ type: "Feature",
+ geometry: {
+ type: "GeometryCollection",
+ geometries: [
+ {
+ type: "Point",
+ coordinates: [-120,47]
+ },
+ {
+ type: "Point",
+ coordinates: [-119,46]
+ }
+ ]
+ }
+ }
+ ]
+ }), [[-120,46], [-119,47]])
}
}
});
23 test/geo/centroid-test.js
View
@@ -65,18 +65,37 @@ suite.addBatch({
]}), [179.5, 0], 1e-6);
},
"GeometryCollection": {
- "Point and LineString": function(centroid) {
+ "LineString, Point": function(centroid) {
assert.inDelta(centroid({type: "GeometryCollection", geometries: [
{type: "LineString", coordinates: [[179, 0], [180, 0]]},
{type: "Point", coordinates: [0, 0]}
]}), [179.5, 0], 1e-6);
},
- "Point, LineString and Polygon": function(centroid) {
+ "Polygon, LineString, Point": function(centroid) {
assert.inDelta(centroid({type: "GeometryCollection", geometries: [
{type: "Polygon", coordinates: [[[-180, 0], [-180, 1], [-179, 1], [-179, 0], [-180, 0]]]},
{type: "LineString", coordinates: [[179, 0], [180, 0]]},
{type: "Point", coordinates: [0, 0]}
]}), [-179.5, 0.5], 1e-6);
+ },
+ "Point, LineString, Polygon": function(centroid) {
+ assert.inDelta(centroid({type: "GeometryCollection", geometries: [
+ {type: "Point", coordinates: [0, 0]},
+ {type: "LineString", coordinates: [[179, 0], [180, 0]]},
+ {type: "Polygon", coordinates: [[[-180, 0], [-180, 1], [-179, 1], [-179, 0], [-180, 0]]]}
+ ]}), [-179.5, 0.5], 1e-6);
+ },
+ "Sphere, Point": function(centroid) {
+ assert.isUndefined(centroid({type: "GeometryCollection", geometries: [
+ {type: "Sphere"},
+ {type: "Point", coordinates: [0, 0]}
+ ]}));
+ },
+ "Point, Sphere": function(centroid) {
+ assert.isUndefined(centroid({type: "GeometryCollection", geometries: [
+ {type: "Point", coordinates: [0, 0]},
+ {type: "Sphere"}
+ ]}));
}
}
}
14 test/layout/treemap-test.js
View
@@ -154,6 +154,20 @@ suite.addBatch({
{x: 0, y: 0, dx: 0, dy: 1},
{x: 0, y: 0, dx: 1, dy: 1}
]);
+ },
+ "slice-dice": function(treemap) {
+ assert.deepEqual(treemap().size([100, 10]).mode("slice-dice").nodes({children: [
+ {children: [{value: 1}, {value: 1}]},
+ {children: [{value: 1}, {value: 1}]}
+ ]}).map(layout), [
+ {x: 0, y: 0, dx: 100, dy: 10},
+ {x: 50, y: 0, dx: 50, dy: 10},
+ {x: 50, y: 5, dx: 50, dy: 5},
+ {x: 50, y: 0, dx: 50, dy: 5},
+ {x: 0, y: 0, dx: 50, dy: 10},
+ {x: 0, y: 5, dx: 50, dy: 5},
+ {x: 0, y: 0, dx: 50, dy: 5}
+ ]);
}
}
});
Please sign in to comment.
Something went wrong with that request. Please try again.