Commit 9ca071ee authored by Mike Bostock's avatar Mike Bostock
Browse files

Merge branch '3.3.4'

parents 5f8056c1 0d57d390
{
"name": "d3",
"version": "3.3.3",
"version": "3.3.4",
"main": "d3.js",
"scripts": [
"d3.js"
......
......@@ -10,7 +10,7 @@
"animation",
"canvas"
],
"version": "3.3.3",
"version": "3.3.4",
"main": "index-browserify.js",
"scripts": [
"d3.js",
......
d3 = function() {
var d3 = {
version: "3.3.3"
version: "3.3.4"
};
if (!Date.now) Date.now = function() {
return +new Date();
......@@ -1131,7 +1131,6 @@ d3 = function() {
type: "dragstart"
});
function moved() {
if (!parent) return ended();
var p = position(parent, eventId), dx = p[0] - origin_[0], dy = p[1] - origin_[1];
dragged |= dx | dy;
origin_ = p;
......@@ -2821,7 +2820,7 @@ d3 = function() {
return ((a = a.point)[0] < 0 ? a[1] - π / 2 - ε : π / 2 - a[1]) - ((b = b.point)[0] < 0 ? b[1] - π / 2 - ε : π / 2 - b[1]);
}
function d3_geo_pointInPolygon(point, polygon) {
var meridian = point[0], parallel = point[1], meridianNormal = [ Math.sin(meridian), -Math.cos(meridian), 0 ], polarAngle = 0, polar = false, southPole = false, winding = 0;
var meridian = point[0], parallel = point[1], meridianNormal = [ Math.sin(meridian), -Math.cos(meridian), 0 ], polarAngle = 0, winding = 0;
d3_geo_areaRingSum.reset();
for (var i = 0, n = polygon.length; i < n; ++i) {
var ring = polygon[i], m = ring.length;
......@@ -2832,7 +2831,6 @@ d3 = function() {
point = ring[j];
var λ = point[0], φ = point[1] / 2 + π / 4, sinφ = Math.sin(φ), cosφ = Math.cos(φ), = λ - λ0, antimeridian = Math.abs() > π, k = sinφ0 * sinφ;
d3_geo_areaRingSum.add(Math.atan2(k * Math.sin(), cosφ0 * cosφ + k * Math.cos()));
if (Math.abs(φ) < ε) southPole = true;
polarAngle += antimeridian ? + ( >= 0 ? 2 : -2) * π : ;
if (antimeridian ^ λ0 >= meridian ^ λ >= meridian) {
var arc = d3_geo_cartesianCross(d3_geo_cartesian(point0), d3_geo_cartesian(point));
......@@ -2847,9 +2845,8 @@ d3 = function() {
if (!j++) break;
λ0 = λ, sinφ0 = sinφ, cosφ0 = cosφ, point0 = point;
}
if (Math.abs(polarAngle) > ε) polar = true;
}
return (!southPole && !polar && d3_geo_areaRingSum < 0 || polarAngle < -ε) ^ winding & 1;
return (polarAngle < -ε || polarAngle < ε && d3_geo_areaRingSum < 0) ^ winding & 1;
}
var d3_geo_clipAntimeridian = d3_geo_clip(d3_true, d3_geo_clipAntimeridianLine, d3_geo_clipAntimeridianInterpolate, d3_geo_clipAntimeridianPolygonContains);
function d3_geo_clipAntimeridianLine(listener) {
......@@ -7885,7 +7882,7 @@ d3 = function() {
function axis(g) {
g.each(function() {
var g = d3.select(this);
var ticks = tickValues == null ? scale.ticks ? scale.ticks.apply(scale, tickArguments_) : scale.domain() : tickValues, tickFormat = tickFormat_ == null ? scale.tickFormat ? scale.tickFormat.apply(scale, tickArguments_) : d3_identity : tickFormat_, tick = g.selectAll(".tick").data(ticks, d3_identity), tickEnter = tick.enter().insert("g", ".domain").attr("class", "tick").style("opacity", 1e-6), tickExit = d3.transition(tick.exit()).style("opacity", 1e-6).remove(), tickUpdate = d3.transition(tick).style("opacity", 1), tickTransform;
var ticks = tickValues == null ? scale.ticks ? scale.ticks.apply(scale, tickArguments_) : scale.domain() : tickValues, tickFormat = tickFormat_ == null ? scale.tickFormat ? scale.tickFormat.apply(scale, tickArguments_) : d3_identity : tickFormat_, tick = g.selectAll(".tick").data(ticks, scale), tickEnter = tick.enter().insert("g", ".domain").attr("class", "tick").style("opacity", 1e-6), tickExit = d3.transition(tick.exit()).style("opacity", 1e-6).remove(), tickUpdate = d3.transition(tick).style("opacity", 1), tickTransform;
var range = d3_scaleRange(scale), path = g.selectAll(".domain").data([ 0 ]), pathUpdate = (path.enter().append("path").attr("class", "domain"),
d3.transition(path));
var scale1 = scale.copy(), scale0 = this.__chart__ || scale1;
......@@ -8887,7 +8884,7 @@ d3 = function() {
range: interval
}, skip ];
if (method) interval = method[0], skip = method[1];
return interval.range(extent[0], d3_time_scaleDate(+extent[1] + 1), skip);
return interval.range(extent[0], d3_time_scaleDate(+extent[1] + 1), skip < 1 ? 1 : skip);
};
scale.tickFormat = function() {
return format;
......
This source diff could not be displayed because it is too large. You can view the blob instead.
{
"name": "d3",
"version": "3.3.3",
"version": "3.3.4",
"description": "A small, free JavaScript library for manipulating documents based on data.",
"keywords": [
"dom",
......
......@@ -49,8 +49,6 @@ d3.behavior.drag = function() {
event_({type: "dragstart"});
function moved() {
if (!parent) return ended(); // target removed from DOM
var p = position(parent, eventId),
dx = p[0] - origin_[0],
dy = p[1] - origin_[1];
......
......@@ -8,8 +8,6 @@ function d3_geo_pointInPolygon(point, polygon) {
parallel = point[1],
meridianNormal = [Math.sin(meridian), -Math.cos(meridian), 0],
polarAngle = 0,
polar = false,
southPole = false,
winding = 0;
d3_geo_areaRingSum.reset();
......@@ -36,7 +34,6 @@ function d3_geo_pointInPolygon(point, polygon) {
k = sinφ0 * sinφ;
d3_geo_areaRingSum.add(Math.atan2(k * Math.sin(), cosφ0 * cosφ + k * Math.cos()));
if (Math.abs(φ) < ε) southPole = true;
polarAngle += antimeridian ? + ( >= 0 ? 2 : -2) * π : ;
// Are the longitudes either side of the point's meridian, and are the
......@@ -54,18 +51,18 @@ function d3_geo_pointInPolygon(point, polygon) {
if (!j++) break;
λ0 = λ, sinφ0 = sinφ, cosφ0 = cosφ, point0 = point;
}
if (Math.abs(polarAngle) > ε) polar = true;
}
// First, determine whether the South pole is inside or outside:
//
// It is inside if:
// * the polygon doesn't wind around it, and its area is negative (counter-clockwise).
// * otherwise, if the polygon winds around it in a clockwise direction.
// * the polygon winds around it in a clockwise direction.
// * the polygon does not (cumulatively) wind around it, but has a negative
// (counter-clockwise) area.
//
// Second, count the (signed) number of times a segment crosses a meridian
// from the point to the South pole. If it is zero, then the point is the
// same side as the South pole.
return (!southPole && !polar && d3_geo_areaRingSum < 0 || polarAngle < -ε) ^ (winding & 1);
return (polarAngle < -ε || polarAngle < ε && d3_geo_areaRingSum < 0) ^ (winding & 1);
}
d3 = (function(){
var d3 = {version: "3.3.3"}; // semver
var d3 = {version: "3.3.4"}; // semver
......@@ -21,7 +21,7 @@ d3.svg.axis = function() {
// Ticks, or domain values for ordinal scales.
var ticks = tickValues == null ? (scale.ticks ? scale.ticks.apply(scale, tickArguments_) : scale.domain()) : tickValues,
tickFormat = tickFormat_ == null ? (scale.tickFormat ? scale.tickFormat.apply(scale, tickArguments_) : d3_identity) : tickFormat_,
tick = g.selectAll(".tick").data(ticks, d3_identity),
tick = g.selectAll(".tick").data(ticks, scale),
tickEnter = tick.enter().insert("g", ".domain").attr("class", "tick").style("opacity", 1e-6),
tickExit = d3.transition(tick.exit()).style("opacity", 1e-6).remove(),
tickUpdate = d3.transition(tick).style("opacity", 1),
......
......@@ -71,7 +71,7 @@ function d3_time_scale(linear, methods, format) {
if (method) interval = method[0], skip = method[1];
return interval.range(extent[0], d3_time_scaleDate(+extent[1] + 1), skip); // inclusive upper bound
return interval.range(extent[0], d3_time_scaleDate(+extent[1] + 1), skip < 1 ? 1 : skip); // inclusive upper bound
};
scale.tickFormat = function() {
......
......@@ -122,6 +122,36 @@ suite.addBatch({
"inside": function(pointInPolygon) {
assert.ok(pointInPolygon([0, 20]));
}
},
"narrow equatorial hole": {
topic: function(pointInPolygon) {
var circle = _.geo.circle().origin([0, -90]);
return pointInPolygon([
circle.angle(90 - .01)().coordinates[0],
circle.angle(90 + .01)().coordinates[0].reverse()
]);
},
"outside": function(pointInPolygon) {
assert.ok(!pointInPolygon([0, 0]));
},
"inside": function(pointInPolygon) {
assert.ok(pointInPolygon([0, -90]));
}
},
"narrow equatorial strip": {
topic: function(pointInPolygon) {
var circle = _.geo.circle().origin([0, -90]);
return pointInPolygon([
circle.angle(90 + .01)().coordinates[0],
circle.angle(90 - .01)().coordinates[0].reverse()
]);
},
"outside": function(pointInPolygon) {
assert.ok(!pointInPolygon([0, -90]));
},
"inside": function(pointInPolygon) {
assert.ok(pointInPolygon([0, 0]));
}
}
},
"ring": {
......@@ -317,15 +347,15 @@ suite.addBatch({
return pointInPolygon([[[180, -90], [-135, 0], [135, 0], [180, -90]]]);
},
"inside": function(pointInPolygon) {
assert.ok(pointInPolygon([180, 0]));
assert.ok(pointInPolygon([150, 0]));
assert.ok(pointInPolygon([180, -30]));
assert.ok(pointInPolygon([150, -80]));
assert.ok(pointInPolygon([0, 0]));
assert.ok(pointInPolygon([180, 1]));
assert.ok(pointInPolygon([-90, -80]));
},
"outside": function(pointInPolygon) {
assert.ok(!pointInPolygon([0, 0]));
assert.ok(!pointInPolygon([180, 1]));
assert.ok(!pointInPolygon([-90, -80]));
assert.ok(!pointInPolygon([180, 0]));
assert.ok(!pointInPolygon([150, 0]));
assert.ok(!pointInPolygon([180, -30]));
assert.ok(!pointInPolygon([150, -80]));
}
},
"triangle touching the North pole": {
......
......@@ -61,8 +61,8 @@ suite.addBatch({
var x = _.scale.quantile().domain([6, 3, 5, 2, 7, 8, 4, 0, 1, 9]).range([10, 50, 90]),
a = d3.svg.axis().scale(x),
g = d3.select("body").html("").append("g").call(a);
assert.inDelta(g.selectAll(".tick").data(), [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], 1e-4);
assert.inDelta(g.selectAll(".tick").data().map(x), [10, 10, 10, 50, 50, 50, 90, 90, 90, 90], 1e-4);
assert.inDelta(g.selectAll(".tick").data(), [0, 3, 6], 1e-4);
assert.inDelta(g.selectAll(".tick").data().map(x), [10, 50, 90], 1e-4);
assert.equal(g.select("path").attr("d"), "M10,6V0H90V6");
},
"can be a threshold scale": function(d3) {
......
......@@ -313,6 +313,10 @@ suite.addBatch({
local(1500, 0, 1, 0, 0),
local(2000, 0, 1, 0, 0)
]);
},
"returns one tick for degenerate empty domain": function(scale) {
var x = scale().domain([local(2014, 2, 2), local(2014, 2, 2)]);
assert.deepEqual(x.ticks(6), [local(2014, 2, 2)]);
}
},
......@@ -617,6 +621,10 @@ suite.addBatch({
utc(1500, 0, 1, 0, 0),
utc(2000, 0, 1, 0, 0)
]);
},
"returns one tick for degenerate empty domain": function(scale) {
var x = scale().domain([utc(2014, 2, 2), utc(2014, 2, 2)]);
assert.deepEqual(x.ticks(6), [utc(2014, 2, 2)]);
}
},
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment