This commit is contained in:
Mike Bostock 2013-01-01 15:52:50 -08:00
Родитель d2ad9f7942 633fd273bd
Коммит 662226bd84
10 изменённых файлов: 44 добавлений и 20 удалений

Просмотреть файл

@ -1,5 +1,5 @@
{
"name": "d3",
"version": "3.0.1",
"version": "3.0.2",
"main": "./d3.js"
}

13
d3.js поставляемый
Просмотреть файл

@ -12,7 +12,7 @@
};
}
d3 = {
version: "3.0.1"
version: "3.0.2"
};
var π = Math.PI, ε = 1e-6, d3_radians = π / 180, d3_degrees = 180 / π;
function d3_target(d) {
@ -5557,8 +5557,8 @@
(d3.geo.azimuthalEquidistant = function() {
return d3_geo_projection(d3_geo_azimuthalEquidistant);
}).raw = d3_geo_azimuthalEquidistant;
d3.geo.bounds = d3_geo_bounds();
function d3_geo_bounds(projection) {
d3.geo.bounds = d3_geo_bounds(d3_identity);
function d3_geo_bounds(projectStream) {
var x0, y0, x1, y1;
var bound = {
point: boundPoint,
@ -5571,7 +5571,6 @@
bound.point = boundPoint;
}
};
var projectBound = projection ? projection.stream(bound) : bound;
function boundPoint(x, y) {
if (x < x0) x0 = x;
if (x > x1) x1 = x;
@ -5583,7 +5582,7 @@
}
return function(feature) {
y1 = x1 = -(x0 = y0 = Infinity);
d3.geo.stream(feature, projectBound);
d3.geo.stream(feature, projectStream(bound));
return [ [ x0, y0 ], [ x1, y1 ] ];
};
}
@ -5671,7 +5670,7 @@
d3.geo.circle = function() {
var origin = [ 0, 0 ], angle, precision = 6, interpolate;
function circle() {
var center = typeof origin === "function" ? origin.apply(this, arguments) : origin, rotate = d3_geo_rotation(center[0] * d3_radians, center[1] * d3_radians, 0), ring = [];
var center = typeof origin === "function" ? origin.apply(this, arguments) : origin, rotate = d3_geo_rotation(-center[0] * d3_radians, -center[1] * d3_radians, 0).invert, ring = [];
interpolate(null, null, 1, {
point: function(x, y) {
ring.push(x = rotate(x, y));
@ -6229,7 +6228,7 @@
return d3_geo_centroidZ ? [ d3_geo_centroidX / d3_geo_centroidZ, d3_geo_centroidY / d3_geo_centroidZ ] : undefined;
};
path.bounds = function(object) {
return d3_geo_bounds(projection)(object);
return d3_geo_bounds(projectStream)(object);
};
path.projection = function(_) {
if (!arguments.length) return projection;

6
d3.min.js поставляемый

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

Просмотреть файл

@ -1,6 +1,6 @@
{
"name": "d3",
"version": "3.0.1",
"version": "3.0.2",
"description": "A small, free JavaScript library for manipulating documents based on data.",
"keywords": [
"dom",

Просмотреть файл

@ -1,4 +1,4 @@
d3 = {version: "3.0.1"}; // semver
d3 = {version: "3.0.2"}; // semver
var π = Math.PI,
ε = 1e-6,

Просмотреть файл

@ -1,6 +1,6 @@
d3.geo.bounds = d3_geo_bounds();
d3.geo.bounds = d3_geo_bounds(d3_identity);
function d3_geo_bounds(projection) {
function d3_geo_bounds(projectStream) {
var x0, y0, x1, y1;
var bound = {
@ -13,8 +13,6 @@ function d3_geo_bounds(projection) {
polygonEnd: function() { bound.point = boundPoint; }
};
var projectBound = projection ? projection.stream(bound) : bound;
function boundPoint(x, y) {
if (x < x0) x0 = x;
if (x > x1) x1 = x;
@ -28,7 +26,7 @@ function d3_geo_bounds(projection) {
return function(feature) {
y1 = x1 = -(x0 = y0 = Infinity);
d3.geo.stream(feature, projectBound);
d3.geo.stream(feature, projectStream(bound));
return [[x0, y0], [x1, y1]];
};
}

Просмотреть файл

@ -6,7 +6,7 @@ d3.geo.circle = function() {
function circle() {
var center = typeof origin === "function" ? origin.apply(this, arguments) : origin,
rotate = d3_geo_rotation(center[0] * d3_radians, center[1] * d3_radians, 0),
rotate = d3_geo_rotation(-center[0] * d3_radians, -center[1] * d3_radians, 0).invert,
ring = [];
interpolate(null, null, 1, {

Просмотреть файл

@ -29,7 +29,7 @@ d3.geo.path = function() {
};
path.bounds = function(object) {
return d3_geo_bounds(projection)(object);
return d3_geo_bounds(projectStream)(object);
};
path.projection = function(_) {

Просмотреть файл

@ -17,6 +17,11 @@ suite.addBatch({
var o = circle.origin([0, 90])();
assert.equal(o.type, "Polygon");
assert.inDelta(o.coordinates, [d3.range(360, -1, -6).map(function(x) { return [x >= 180 ? x - 360 : x, 0]; })], 1e-6);
},
"origin([45, 45])": function(circle) {
var o = circle.origin([45, 45]).angle(0)();
assert.equal(o.type, "Polygon");
assert.inDelta(o.coordinates[0][0], [45, 45], 1e-6);
}
}
});

Просмотреть файл

@ -186,6 +186,22 @@ suite.addBatch({
},
"Sphere": function(area) {
assert.strictEqual(area({type: "Sphere"}), 1620000);
},
"supports fallback stream": function() {
var path = d3.geo.path(),
area = path.area({type: "Polygon", coordinates: [[[-122, 37], [-71, 42], [-80, 25], [-122, 37]]]});
assert.inDelta(area, 109021.503, 1e-3);
}
},
"bounds": {
"supports fallback stream": function() {
var path = d3.geo.path(),
bounds = path.bounds({type: "LineString", coordinates: [[-122, 37], [-74, 40], [-100, 0]]});
assert.inDelta(bounds[0][0], -5.1214, 1e-3);
assert.inDelta(bounds[0][1], 174.825, 1e-3);
assert.inDelta(bounds[1][0], 794.602, 1e-3);
assert.inDelta(bounds[1][1], 856.501, 1e-3);
}
},
@ -321,6 +337,12 @@ suite.addBatch({
assert.deepEqual(testContext.buffer().filter(function(d) { return d.type === "moveTo"; }), [
{type: "moveTo", x: 1370, y: 243}
]);
},
"supports fallback stream": function() {
var path = d3.geo.path(),
centroid = path.centroid({type: "LineString", coordinates: [[-122, 37], [-74, 40], [-100, 0]]});
assert.inDelta(centroid[0], 434.655, 1e-3);
assert.inDelta(centroid[1], 397.940, 1e-3);
}
},