app/assets/javascripts/d3.v4.js in d3-rails-4.1.0 vs app/assets/javascripts/d3.v4.js in d3-rails-4.2.2
- old
+ new
@@ -1,13 +1,13 @@
-// https://d3js.org Version 4.1.0. Copyright 2016 Mike Bostock.
+// https://d3js.org Version 4.2.2. Copyright 2016 Mike Bostock.
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
typeof define === 'function' && define.amd ? define(['exports'], factory) :
(factory((global.d3 = global.d3 || {})));
-}(this, function (exports) { 'use strict';
+}(this, (function (exports) { 'use strict';
- var version = "4.1.0";
+ var version = "4.2.2";
function ascending(a, b) {
return a < b ? -1 : a > b ? 1 : a >= b ? 0 : NaN;
}
@@ -4806,19 +4806,19 @@
return request.send("POST", data, callback);
},
// If callback is non-null, it will be used for error and load events.
send: function(method, data, callback) {
- if (!callback && typeof data === "function") callback = data, data = null;
- if (callback && callback.length === 1) callback = fixCallback(callback);
xhr.open(method, url, true, user, password);
if (mimeType != null && !headers.has("accept")) headers.set("accept", mimeType + ",*/*");
if (xhr.setRequestHeader) headers.each(function(value, name) { xhr.setRequestHeader(name, value); });
if (mimeType != null && xhr.overrideMimeType) xhr.overrideMimeType(mimeType);
if (responseType != null) xhr.responseType = responseType;
if (timeout > 0) xhr.timeout = timeout;
- if (callback) request.on("error", callback).on("load", function(xhr) { callback(null, xhr); });
+ if (callback == null && typeof data === "function") callback = data, data = null;
+ if (callback != null && callback.length === 1) callback = fixCallback(callback);
+ if (callback != null) request.on("error", callback).on("load", function(xhr) { callback(null, xhr); });
event.call("beforesend", request, xhr);
xhr.send(data == null ? null : data);
return request;
},
@@ -4831,13 +4831,16 @@
var value = event.on.apply(event, arguments);
return value === event ? request : value;
}
};
- return callback
- ? request.get(callback)
- : request;
+ if (callback != null) {
+ if (typeof callback !== "function") throw new Error("invalid callback: " + callback);
+ return request.get(callback);
+ }
+
+ return request;
}
function fixCallback(callback) {
return function(error, xhr) {
callback(error == null ? xhr : null);
@@ -4852,11 +4855,15 @@
}
function type(defaultMimeType, response) {
return function(url, callback) {
var r = request(url).mimeType(defaultMimeType).response(response);
- return callback ? r.get(callback) : r;
+ if (callback != null) {
+ if (typeof callback !== "function") throw new Error("invalid callback: " + callback);
+ return r.get(callback);
+ }
+ return r;
};
}
var html = type("text/html", function(xhr) {
return document.createRange().createContextualFragment(xhr.responseText);
@@ -5618,13 +5625,10 @@
formatPrefix: formatPrefix
};
}
var locale;
- exports.format;
- exports.formatPrefix;
-
defaultLocale({
decimal: ".",
thousands: ",",
grouping: [3],
currency: ["$", ""]
@@ -6176,15 +6180,10 @@
function formatLiteralPercent() {
return "%";
}
var locale$1;
- exports.timeFormat;
- exports.timeParse;
- exports.utcFormat;
- exports.utcParse;
-
defaultLocale$1({
dateTime: "%x, %X",
date: "%-m/%-d/%Y",
time: "%-I:%M:%S %p",
periods: ["AM", "PM"],
@@ -8813,13 +8812,14 @@
var y = scale0(d);
return "translate(0," + (isFinite(y) ? y : scale1(d)) + ")";
}
function center(scale) {
- var width = scale.bandwidth() / 2;
+ var offset = scale.bandwidth() / 2;
+ if (scale.round()) offset = Math.round(offset);
return function(d) {
- return scale(d) + width;
+ return scale(d) + offset;
};
}
function entering() {
return !this.__axis;
@@ -8866,11 +8866,11 @@
text = text.merge(tickEnter.append("text")
.attr("fill", "#000")
.attr(x, k * spacing)
.attr(y, 0.5)
- .attr("dy", orient === top ? "0em" : orient === bottom ? ".71em" : ".32em"));
+ .attr("dy", orient === top ? "0em" : orient === bottom ? "0.71em" : "0.32em"));
if (context !== selection) {
path = path.transition(context);
tick = tick.transition(context);
line = line.transition(context);
@@ -11946,11 +11946,11 @@
voronoi.extent = function(_) {
return arguments.length ? (extent = _ == null ? null : [[+_[0][0], +_[0][1]], [+_[1][0], +_[1][1]]], voronoi) : extent && [[extent[0][0], extent[0][1]], [extent[1][0], extent[1][1]]];
};
voronoi.size = function(_) {
- return arguments.length ? (extent = _ == null ? null : [[0, 0], [+_[0], +_[1]]], voronoi) : extent && [extent[1][0], extent[1][1]];
+ return arguments.length ? (extent = _ == null ? null : [[0, 0], [+_[0], +_[1]]], voronoi) : extent && [extent[1][0] - extent[0][0], extent[1][1] - extent[0][1]];
};
return voronoi;
}
@@ -12058,17 +12058,13 @@
y0 = x0,
y1 = x1,
duration = 250,
gestures = [],
listeners = dispatch("start", "zoom", "end"),
- mousemoving,
- mousePoint,
- mouseLocation,
touchstarting,
touchending,
touchDelay = 500,
- wheelTimer,
wheelDelay = 150;
function zoom(selection) {
selection
.on("wheel.zoom", wheeled)
@@ -12178,10 +12174,11 @@
function Gesture(that, args) {
this.that = that;
this.args = args;
this.index = -1;
this.active = 0;
+ this.extent = extent.apply(that, args);
}
Gesture.prototype = {
start: function() {
if (++this.active === 1) {
@@ -12189,21 +12186,20 @@
this.emit("start");
}
return this;
},
zoom: function(key, transform) {
- if (mousePoint && key !== "mouse") mouseLocation = transform.invert(mousePoint);
+ if (this.mouse && key !== "mouse") this.mouse[1] = transform.invert(this.mouse[0]);
if (this.touch0 && key !== "touch") this.touch0[1] = transform.invert(this.touch0[0]);
if (this.touch1 && key !== "touch") this.touch1[1] = transform.invert(this.touch1[0]);
this.that.__zoom = transform;
this.emit("zoom");
return this;
},
end: function() {
if (--this.active === 0) {
gestures.splice(this.index, 1);
- mousePoint = mouseLocation = null;
this.index = -1;
this.emit("end");
}
return this;
},
@@ -12214,65 +12210,63 @@
function wheeled() {
if (!filter.apply(this, arguments)) return;
var g = gesture(this, arguments),
t = this.__zoom,
- k = Math.max(k0, Math.min(k1, t.k * Math.pow(2, -exports.event.deltaY * (exports.event.deltaMode ? 120 : 1) / 500)));
+ k = Math.max(k0, Math.min(k1, t.k * Math.pow(2, -exports.event.deltaY * (exports.event.deltaMode ? 120 : 1) / 500))),
+ p = mouse(this);
// If the mouse is in the same location as before, reuse it.
// If there were recent wheel events, reset the wheel idle timeout.
- if (wheelTimer) {
- var point = mouse(this);
- if (mousePoint[0] !== point[0] || mousePoint[1] !== point[1]) {
- mouseLocation = t.invert(mousePoint = point);
+ if (g.wheel) {
+ if (g.mouse[0][0] !== p[0] || g.mouse[0][1] !== p[1]) {
+ g.mouse[1] = t.invert(g.mouse[0] = p);
}
- clearTimeout(wheelTimer);
+ clearTimeout(g.wheel);
}
// If this wheel event won’t trigger a transform change, ignore it.
else if (t.k === k) return;
// Otherwise, capture the mouse point and location at the start.
else {
- g.extent = extent.apply(this, arguments);
- mouseLocation = t.invert(mousePoint = mouse(this));
+ g.mouse = [p, t.invert(p)];
interrupt(this);
g.start();
}
noevent$1();
- wheelTimer = setTimeout(wheelidled, wheelDelay);
- g.zoom("mouse", constrain(translate(scale(t, k), mousePoint, mouseLocation), g.extent));
+ g.wheel = setTimeout(wheelidled, wheelDelay);
+ g.zoom("mouse", constrain(translate(scale(t, k), g.mouse[0], g.mouse[1]), g.extent));
function wheelidled() {
- wheelTimer = null;
+ g.wheel = null;
g.end();
}
}
function mousedowned() {
if (touchending || !filter.apply(this, arguments)) return;
var g = gesture(this, arguments),
- v = select(exports.event.view).on("mousemove.zoom", mousemoved, true).on("mouseup.zoom", mouseupped, true);
+ v = select(exports.event.view).on("mousemove.zoom", mousemoved, true).on("mouseup.zoom", mouseupped, true),
+ p = mouse(this);
dragDisable(exports.event.view);
nopropagation$1();
- mousemoving = false;
- g.extent = extent.apply(this, arguments);
- mouseLocation = this.__zoom.invert(mousePoint = mouse(this));
+ g.mouse = [p, this.__zoom.invert(p)];
interrupt(this);
g.start();
function mousemoved() {
noevent$1();
- mousemoving = true;
- g.zoom("mouse", constrain(translate(g.that.__zoom, mousePoint = mouse(g.that), mouseLocation), g.extent));
+ g.moved = true;
+ g.zoom("mouse", constrain(translate(g.that.__zoom, g.mouse[0] = mouse(g.that), g.mouse[1]), g.extent));
}
function mouseupped() {
v.on("mousemove.zoom mouseup.zoom", null);
- dragEnable(exports.event.view, mousemoving);
+ dragEnable(exports.event.view, g.moved);
noevent$1();
g.end();
}
}
@@ -12307,11 +12301,10 @@
if (!g.touch1) return g.end(), dblclicked.apply(this, arguments);
}
if (exports.event.touches.length === n) {
touchstarting = setTimeout(function() { touchstarting = null; }, touchDelay);
interrupt(this);
- g.extent = extent.apply(this, arguments);
g.start();
}
}
function touchmoved() {
@@ -13292,21 +13285,21 @@
stream.polygonStart();
while (++i < n) streamLine(coordinates[i], stream, 1);
stream.polygonEnd();
}
- function stream(object, stream) {
+ function geoStream(object, stream) {
if (object && streamObjectType.hasOwnProperty(object.type)) {
streamObjectType[object.type](object, stream);
} else {
streamGeometry(object, stream);
}
}
- var areaRingSum;
+ var areaRingSum = adder();
- var areaSum;
+ var areaSum = adder();
var lambda00;
var phi00;
var lambda0;
var cosPhi0;
var sinPhi0;
@@ -13364,13 +13357,12 @@
// Advance the previous points.
lambda0 = lambda, cosPhi0 = cosPhi, sinPhi0 = sinPhi;
}
function area$2(object) {
- if (areaSum) areaSum.reset();
- else areaSum = adder(), areaRingSum = adder();
- stream(object, areaStream);
+ areaSum.reset();
+ geoStream(object, areaStream);
return areaSum * 2;
}
function spherical(cartesian) {
return [atan2(cartesian[1], cartesian[0]), asin$1(cartesian[2])];
@@ -13410,11 +13402,11 @@
var phi1;
var lambda2;
var lambda00$1;
var phi00$1;
var p0;
- var deltaSum;
+ var deltaSum = adder();
var ranges;
var range$1;
var boundsStream = {
point: boundsPoint,
lineStart: boundsLineStart,
@@ -13540,15 +13532,13 @@
}
function bounds(feature) {
var i, n, a, b, merged, deltaMax, delta;
- if (deltaSum) deltaSum.reset();
- else deltaSum = adder();
phi1 = lambda1 = -(lambda0$1 = phi0 = Infinity);
ranges = [];
- stream(feature, boundsStream);
+ geoStream(feature, boundsStream);
// First, sort ranges by their minimum longitudes.
if (n = ranges.length) {
ranges.sort(rangeCompare);
@@ -13705,11 +13695,11 @@
function centroid$1(object) {
W0 = W1 =
X0 = Y0 = Z0 =
X1 = Y1 = Z1 =
X2 = Y2 = Z2 = 0;
- stream(object, centroidStream);
+ geoStream(object, centroidStream);
var x = X2,
y = Y2,
z = Z2,
m = x * x + y * y + z * z;
@@ -14255,11 +14245,11 @@
return arguments.length ? (x0 = +_[0][0], y0 = +_[0][1], x1 = +_[1][0], y1 = +_[1][1], cache = cacheStream = null, clip) : [[x0, y0], [x1, y1]];
}
};
}
- var lengthSum;
+ var lengthSum = adder();
var lambda0$2;
var sinPhi0$1;
var cosPhi0$1;
var lengthStream = {
sphere: noop$2,
@@ -14298,13 +14288,12 @@
lengthSum.add(atan2(sqrt$1(x * x + y * y), z));
lambda0$2 = lambda, sinPhi0$1 = sinPhi, cosPhi0$1 = cosPhi;
}
function length$2(object) {
- if (lengthSum) lengthSum.reset();
- else lengthSum = adder();
- stream(object, lengthStream);
+ lengthSum.reset();
+ geoStream(object, lengthStream);
return +lengthSum;
}
var coordinates = [null, null];
var object$1 = {type: "LineString", coordinates: coordinates};
@@ -14732,27 +14721,27 @@
contextStream;
function path(object) {
if (object) {
if (typeof pointRadius === "function") contextStream.pointRadius(+pointRadius.apply(this, arguments));
- stream(object, projectionStream(contextStream));
+ geoStream(object, projectionStream(contextStream));
}
return contextStream.result();
}
path.area = function(object) {
- stream(object, projectionStream(areaStream$1));
+ geoStream(object, projectionStream(areaStream$1));
return areaStream$1.result();
};
path.bounds = function(object) {
- stream(object, projectionStream(boundsStream$1));
+ geoStream(object, projectionStream(boundsStream$1));
return boundsStream$1.result();
};
path.centroid = function(object) {
- stream(object, projectionStream(centroidStream$1));
+ geoStream(object, projectionStream(centroidStream$1));
return centroidStream$1.result();
};
path.projection = function(_) {
return arguments.length ? (projectionStream = (projection = _) == null ? identity$7 : _.stream, path) : projection;
@@ -14781,10 +14770,12 @@
phi = point[1],
normal = [sin$1(lambda), -cos$1(lambda), 0],
angle = 0,
winding = 0;
+ sum$2.reset();
+
for (var i = 0, n = polygon.length; i < n; ++i) {
if (!(m = (ring = polygon[i]).length)) continue;
var ring,
m,
point0 = ring[m - 1],
@@ -14832,13 +14823,11 @@
//
// Second, count the (signed) number of times a segment crosses a lambda
// from the point to the South pole. If it is zero, then the point is the
// same side as the South pole.
- var contains = (angle < -epsilon$4 || angle < epsilon$4 && sum$2 < -epsilon$4) ^ (winding & 1);
- sum$2.reset();
- return contains;
+ return (angle < -epsilon$4 || angle < epsilon$4 && sum$2 < -epsilon$4) ^ (winding & 1);
}
function clip(pointVisible, clipLine, interpolate, start) {
return function(rotate, sink) {
var line = clipLine(sink),
@@ -15261,10 +15250,47 @@
lineEnd: function() { this.stream.lineEnd(); },
polygonStart: function() { this.stream.polygonStart(); },
polygonEnd: function() { this.stream.polygonEnd(); }
};
+ function fit(project, extent, object) {
+ var w = extent[1][0] - extent[0][0],
+ h = extent[1][1] - extent[0][1],
+ clip = project.clipExtent && project.clipExtent();
+
+ project
+ .scale(150)
+ .translate([0, 0]);
+
+ if (clip != null) project.clipExtent(null);
+
+ geoStream(object, project.stream(boundsStream$1));
+
+ var b = boundsStream$1.result(),
+ k = Math.min(w / (b[1][0] - b[0][0]), h / (b[1][1] - b[0][1])),
+ x = +extent[0][0] + (w - k * (b[1][0] + b[0][0])) / 2,
+ y = +extent[0][1] + (h - k * (b[1][1] + b[0][1])) / 2;
+
+ if (clip != null) project.clipExtent(clip);
+
+ return project
+ .scale(k * 150)
+ .translate([x, y]);
+ }
+
+ function fitSize(project) {
+ return function(size, object) {
+ return fit(project, [[0, 0], size], object);
+ };
+ }
+
+ function fitExtent(project) {
+ return function(extent, object) {
+ return fit(project, extent, object);
+ };
+ }
+
var maxDepth = 16;
var cosMinDistance = cos$1(30 * radians);
// cos(minimum angular distance)
function resample(project, delta2) {
@@ -15429,10 +15455,14 @@
projection.precision = function(_) {
return arguments.length ? (projectResample = resample(projectTransform, delta2 = _ * _), reset()) : sqrt$1(delta2);
};
+ projection.fitExtent = fitExtent(projection);
+
+ projection.fitSize = fitSize(projection);
+
function recenter() {
projectRotate = compose(rotate = rotateRadians(deltaLambda, deltaPhi, deltaGamma), project);
var center = project(lambda, phi);
dx = x - center[0] * k;
dy = y + center[1] * k;
@@ -15483,12 +15513,12 @@
return project;
}
function conicEqualArea() {
return conicProjection(conicEqualAreaRaw)
- .scale(151)
- .translate([480, 347]);
+ .scale(155.424)
+ .center([0, 33.6442]);
}
function albers() {
return conicEqualArea()
.parallels([29.5, 45.5])
@@ -15511,12 +15541,13 @@
polygonEnd: function() { var i = -1; while (++i < n) streams[i].polygonEnd(); }
};
}
// A composite projection for the United States, configured by default for
- // 960×500. Also works quite well at 960×600 with scale 1285. The set of
- // standard parallels for each region comes from USGS, which is published here:
+ // 960×500. The projection also works quite well at 960×600 if you change the
+ // scale to 1285 and adjust the translate accordingly. The set of standard
+ // parallels for each region comes from USGS, which is published here:
// http://egsc.usgs.gov/isb/pubs/MapProjections/projections.html#albers
function albersUsa() {
var cache,
cacheStream,
lower48 = albers(), lower48Point,
@@ -15578,10 +15609,14 @@
.stream(pointStream);
return albersUsa;
};
+ albersUsa.fitExtent = fitExtent(albersUsa);
+
+ albersUsa.fitSize = fitSize(albersUsa);
+
return albersUsa.scale(1070);
}
function azimuthalRaw(scale) {
return function(x, y) {
@@ -15616,11 +15651,11 @@
return 2 * asin$1(z / 2);
});
function azimuthalEqualArea() {
return projection(azimuthalEqualAreaRaw)
- .scale(120)
+ .scale(124.75)
.clipAngle(180 - 1e-3);
}
var azimuthalEquidistantRaw = azimuthalRaw(function(c) {
return (c = acos(c)) && c / sin$1(c);
@@ -15630,11 +15665,11 @@
return z;
});
function azimuthalEquidistant() {
return projection(azimuthalEquidistantRaw)
- .scale(480 / tau$4)
+ .scale(79.4188)
.clipAngle(180 - 1e-3);
}
function mercatorRaw(lambda, phi) {
return [lambda, log$1(tan((halfPi$3 + phi) / 2))];
@@ -15643,11 +15678,12 @@
mercatorRaw.invert = function(x, y) {
return [x, 2 * atan(exp(y)) - halfPi$3];
};
function mercator() {
- return mercatorProjection(mercatorRaw);
+ return mercatorProjection(mercatorRaw)
+ .scale(961 / tau$4);
}
function mercatorProjection(project) {
var m = projection(project),
scale = m.scale,
@@ -15664,18 +15700,19 @@
};
m.clipExtent = function(_) {
if (!arguments.length) return clipAuto ? null : clipExtent();
if (clipAuto = _ == null) {
- var k = pi$4 * scale(), t = translate();
+ var k = pi$4 * scale(),
+ t = translate();
_ = [[t[0] - k, t[1] - k], [t[0] + k, t[1] + k]];
}
clipExtent(_);
return m;
};
- return m.clipExtent(null).scale(961 / tau$4);
+ return m.clipExtent(null);
}
function tany(y) {
return tan((halfPi$3 + y) / 2);
}
@@ -15701,21 +15738,24 @@
return project;
}
function conicConformal() {
- return conicProjection(conicConformalRaw);
+ return conicProjection(conicConformalRaw)
+ .scale(109.5)
+ .parallels([30, 30]);
}
function equirectangularRaw(lambda, phi) {
return [lambda, phi];
}
equirectangularRaw.invert = equirectangularRaw;
function equirectangular() {
- return projection(equirectangularRaw).scale(480 / pi$4);
+ return projection(equirectangularRaw)
+ .scale(152.63);
}
function conicEquidistantRaw(y0, y1) {
var cy0 = cos$1(y0),
n = y0 === y1 ? sin$1(y0) : (cy0 - cos$1(y1)) / (y1 - y0),
@@ -15736,12 +15776,12 @@
return project;
}
function conicEquidistant() {
return conicProjection(conicEquidistantRaw)
- .scale(128)
- .translate([480, 280]);
+ .scale(131.154)
+ .center([0, 13.9389]);
}
function gnomonicRaw(x, y) {
var cy = cos$1(y), k = cos$1(x) * cy;
return [cy * sin$1(x) / k, sin$1(y) / k];
@@ -15749,11 +15789,11 @@
gnomonicRaw.invert = azimuthalInvert(atan);
function gnomonic() {
return projection(gnomonicRaw)
- .scale(139)
+ .scale(144.049)
.clipAngle(60);
}
function orthographicRaw(x, y) {
return [cos$1(y) * sin$1(x), sin$1(y)];
@@ -15761,26 +15801,26 @@
orthographicRaw.invert = azimuthalInvert(asin$1);
function orthographic() {
return projection(orthographicRaw)
- .scale(240)
+ .scale(249.5)
.clipAngle(90 + epsilon$4);
}
function stereographicRaw(x, y) {
var cy = cos$1(y), k = 1 + cos$1(x) * cy;
return [cy * sin$1(x) / k, sin$1(y) / k];
}
stereographicRaw.invert = azimuthalInvert(function(z) {
- return 2 + atan(z);
+ return 2 * atan(z);
});
function stereographic() {
return projection(stereographicRaw)
- .scale(240)
+ .scale(250)
.clipAngle(142);
}
function transverseMercatorRaw(lambda, phi) {
return [log$1(tan((halfPi$3 + phi) / 2)), -lambda];
@@ -15801,11 +15841,12 @@
m.rotate = function(_) {
return arguments.length ? rotate([_[0], _[1], _.length > 2 ? _[2] + 90 : 90]) : (_ = rotate(), [_[0], _[1], _[2] - 90]);
};
- return rotate([0, 0, 90]);
+ return rotate([0, 0, 90])
+ .scale(159.155);
}
exports.version = version;
exports.bisect = bisectRight;
exports.bisectRight = bisectRight;
@@ -16175,13 +16216,13 @@
exports.geoProjection = projection;
exports.geoProjectionMutator = projectionMutator;
exports.geoRotation = rotation;
exports.geoStereographic = stereographic;
exports.geoStereographicRaw = stereographicRaw;
- exports.geoStream = stream;
+ exports.geoStream = geoStream;
exports.geoTransform = transform$1;
exports.geoTransverseMercator = transverseMercator;
exports.geoTransverseMercatorRaw = transverseMercatorRaw;
Object.defineProperty(exports, '__esModule', { value: true });
-}));
+})));
\ No newline at end of file