app/assets/javascripts/d3.v4.js in d3-rails-4.8.0 vs app/assets/javascripts/d3.v4.js in d3-rails-4.9.0
- old
+ new
@@ -1,13 +1,13 @@
-// https://d3js.org Version 4.8.0. Copyright 2017 Mike Bostock.
+// https://d3js.org Version 4.9.0. Copyright 2017 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';
-var version = "4.8.0";
+var version = "4.9.0";
var ascending = function(a, b) {
return a < b ? -1 : a > b ? 1 : a >= b ? 0 : NaN;
};
@@ -565,19 +565,19 @@
var bottom = 3;
var left = 4;
var epsilon = 1e-6;
function translateX(x) {
- return "translate(" + x + ",0)";
+ return "translate(" + (x + 0.5) + ",0)";
}
function translateY(y) {
- return "translate(0," + y + ")";
+ return "translate(0," + (y + 0.5) + ")";
}
function center(scale) {
- var offset = scale.bandwidth() / 2;
+ var offset = Math.max(0, scale.bandwidth() - 1) / 2; // Adjust for 0.5px offset.
if (scale.round()) offset = Math.round(offset);
return function(d) {
return scale(d) + offset;
};
}
@@ -592,11 +592,11 @@
tickFormat = null,
tickSizeInner = 6,
tickSizeOuter = 6,
tickPadding = 3,
k = orient === top || orient === left ? -1 : 1,
- x, y = orient === left || orient === right ? (x = "x", "y") : (x = "y", "x"),
+ x = orient === left || orient === right ? "x" : "y",
transform = orient === top || orient === bottom ? translateX : translateY;
function axis(context) {
var values = tickValues == null ? (scale.ticks ? scale.ticks.apply(scale, tickArguments) : scale.domain()) : tickValues,
format = tickFormat == null ? (scale.tickFormat ? scale.tickFormat.apply(scale, tickArguments) : identity$1) : tickFormat,
@@ -619,18 +619,15 @@
tick = tick.merge(tickEnter);
line = line.merge(tickEnter.append("line")
.attr("stroke", "#000")
- .attr(x + "2", k * tickSizeInner)
- .attr(y + "1", 0.5)
- .attr(y + "2", 0.5));
+ .attr(x + "2", k * tickSizeInner));
text = text.merge(tickEnter.append("text")
.attr("fill", "#000")
.attr(x, k * spacing)
- .attr(y, 0.5)
.attr("dy", orient === top ? "0em" : orient === bottom ? "0.71em" : "0.32em"));
if (context !== selection) {
path = path.transition(context);
tick = tick.transition(context);
@@ -1401,11 +1398,11 @@
? (fullname.local ? attrRemoveNS : attrRemove) : (typeof value === "function"
? (fullname.local ? attrFunctionNS : attrFunction)
: (fullname.local ? attrConstantNS : attrConstant)))(fullname, value));
};
-var window = function(node) {
+var defaultView = function(node) {
return (node.ownerDocument && node.ownerDocument.defaultView) // node is a Node
|| (node.document && node) // node is a Window
|| node.defaultView; // node is a Document
};
@@ -1428,21 +1425,23 @@
else this.style.setProperty(name, v, priority);
};
}
var selection_style = function(name, value, priority) {
- var node;
return arguments.length > 1
? this.each((value == null
? styleRemove : typeof value === "function"
? styleFunction
: styleConstant)(name, value, priority == null ? "" : priority))
- : window(node = this.node())
- .getComputedStyle(node, null)
- .getPropertyValue(name);
+ : styleValue(this.node(), name);
};
+function styleValue(node, name) {
+ return node.style.getPropertyValue(name)
+ || defaultView(node).getComputedStyle(node, null).getPropertyValue(name);
+}
+
function propertyRemove(name) {
return function() {
delete this[name];
};
}
@@ -1647,17 +1646,17 @@
? this.property("__data__", value)
: this.node().__data__;
};
function dispatchEvent(node, type, params) {
- var window$$1 = window(node),
- event = window$$1.CustomEvent;
+ var window = defaultView(node),
+ event = window.CustomEvent;
- if (event) {
+ if (typeof event === "function") {
event = new event(type, params);
} else {
- event = window$$1.document.createEvent("Event");
+ event = window.document.createEvent("Event");
if (params) event.initEvent(type, params.bubbles, params.cancelable), event.detail = params.detail;
else event.initEvent(type, false, false);
}
node.dispatchEvent(event);
@@ -1836,12 +1835,15 @@
container = defaultContainer,
subject = defaultSubject,
gestures = {},
listeners = dispatch("start", "drag", "end"),
active = 0,
+ mousedownx,
+ mousedowny,
mousemoving,
- touchending;
+ touchending,
+ clickDistance2 = 0;
function drag(selection$$1) {
selection$$1
.on("mousedown.drag", mousedowned)
.on("touchstart.drag", touchstarted)
@@ -1856,16 +1858,21 @@
if (!gesture) return;
select(exports.event.view).on("mousemove.drag", mousemoved, true).on("mouseup.drag", mouseupped, true);
dragDisable(exports.event.view);
nopropagation();
mousemoving = false;
+ mousedownx = exports.event.clientX;
+ mousedowny = exports.event.clientY;
gesture("start");
}
function mousemoved() {
noevent();
- mousemoving = true;
+ if (!mousemoving) {
+ var dx = exports.event.clientX - mousedownx, dy = exports.event.clientY - mousedowny;
+ mousemoving = dx * dx + dy * dy > clickDistance2;
+ }
gestures.mouse("drag");
}
function mouseupped() {
select(exports.event.view).on("mousemove.drag mouseup.drag", null);
@@ -1951,10 +1958,14 @@
drag.on = function() {
var value = listeners.on.apply(listeners, arguments);
return value === listeners ? drag : value;
};
+ drag.clickDistance = function(_) {
+ return arguments.length ? (clickDistance2 = (_ = +_) * _, drag) : Math.sqrt(clickDistance2);
+ };
+
return drag;
};
var define = function(constructor, factory, prototype) {
constructor.prototype = factory.prototype = prototype;
@@ -2699,11 +2710,11 @@
: (t === "number" ? reinterpolate
: t === "string" ? ((c = color(b)) ? (b = c, interpolateRgb) : interpolateString)
: b instanceof color ? interpolateRgb
: b instanceof Date ? date
: Array.isArray(b) ? array$1
- : isNaN(b) ? object
+ : typeof b.valueOf !== "function" && typeof b.toString !== "function" || isNaN(b) ? object
: reinterpolate)(a, b);
};
var interpolateRound = function(a, b) {
return a = +a, b -= a, function(t) {
@@ -3662,13 +3673,12 @@
function styleRemove$1(name, interpolate$$2) {
var value00,
value10,
interpolate0;
return function() {
- var style = window(this).getComputedStyle(this, null),
- value0 = style.getPropertyValue(name),
- value1 = (this.style.removeProperty(name), style.getPropertyValue(name));
+ var value0 = styleValue(this, name),
+ value1 = (this.style.removeProperty(name), styleValue(this, name));
return value0 === value1 ? null
: value0 === value00 && value1 === value10 ? interpolate0
: interpolate0 = interpolate$$2(value00 = value0, value10 = value1);
};
}
@@ -3681,11 +3691,11 @@
function styleConstant$1(name, interpolate$$2, value1) {
var value00,
interpolate0;
return function() {
- var value0 = window(this).getComputedStyle(this, null).getPropertyValue(name);
+ var value0 = styleValue(this, name);
return value0 === value1 ? null
: value0 === value00 ? interpolate0
: interpolate0 = interpolate$$2(value00 = value0, value1);
};
}
@@ -3693,14 +3703,13 @@
function styleFunction$1(name, interpolate$$2, value) {
var value00,
value10,
interpolate0;
return function() {
- var style = window(this).getComputedStyle(this, null),
- value0 = style.getPropertyValue(name),
+ var value0 = styleValue(this, name),
value1 = value(this);
- if (value1 == null) value1 = (this.style.removeProperty(name), style.getPropertyValue(name));
+ if (value1 == null) value1 = (this.style.removeProperty(name), styleValue(this, name));
return value0 === value1 ? null
: value0 === value00 && value1 === value10 ? interpolate0
: interpolate0 = interpolate$$2(value00 = value0, value10 = value1);
};
}
@@ -10964,11 +10973,10 @@
var slice$3 = [].slice;
var noabort = {};
function Queue(size) {
- if (!(size >= 1)) throw new Error;
this._size = size;
this._call =
this._error = null;
this._tasks = [];
this._data = [];
@@ -10979,11 +10987,12 @@
}
Queue.prototype = queue.prototype = {
constructor: Queue,
defer: function(callback) {
- if (typeof callback !== "function" || this._call) throw new Error;
+ if (typeof callback !== "function") throw new Error("invalid callback");
+ if (this._call) throw new Error("defer after await");
if (this._error != null) return this;
var t = slice$3.call(arguments, 1);
t.push(callback);
++this._waiting, this._tasks.push(t);
poke$1(this);
@@ -10992,17 +11001,19 @@
abort: function() {
if (this._error == null) abort(this, new Error("abort"));
return this;
},
await: function(callback) {
- if (typeof callback !== "function" || this._call) throw new Error;
+ if (typeof callback !== "function") throw new Error("invalid callback");
+ if (this._call) throw new Error("multiple await");
this._call = function(error, results) { callback.apply(null, [error].concat(results)); };
maybeNotify(this);
return this;
},
awaitAll: function(callback) {
- if (typeof callback !== "function" || this._call) throw new Error;
+ if (typeof callback !== "function") throw new Error("invalid callback");
+ if (this._call) throw new Error("multiple await");
this._call = callback;
maybeNotify(this);
return this;
}
};
@@ -11074,71 +11085,113 @@
q._call(q._error, d);
}
}
function queue(concurrency) {
- return new Queue(arguments.length ? +concurrency : Infinity);
+ if (concurrency == null) concurrency = Infinity;
+ else if (!((concurrency = +concurrency) >= 1)) throw new Error("invalid concurrency");
+ return new Queue(concurrency);
}
-var uniform = function(min, max) {
- min = min == null ? 0 : +min;
- max = max == null ? 1 : +max;
- if (arguments.length === 1) max = min, min = 0;
- else max -= min;
- return function() {
- return Math.random() * max + min;
- };
+var defaultSource$1 = function() {
+ return Math.random();
};
-var normal = function(mu, sigma) {
- var x, r;
- mu = mu == null ? 0 : +mu;
- sigma = sigma == null ? 1 : +sigma;
- return function() {
- var y;
+var uniform = ((function sourceRandomUniform(source) {
+ function randomUniform(min, max) {
+ min = min == null ? 0 : +min;
+ max = max == null ? 1 : +max;
+ if (arguments.length === 1) max = min, min = 0;
+ else max -= min;
+ return function() {
+ return source() * max + min;
+ };
+ }
- // If available, use the second previously-generated uniform random.
- if (x != null) y = x, x = null;
+ randomUniform.source = sourceRandomUniform;
- // Otherwise, generate a new x and y.
- else do {
- x = Math.random() * 2 - 1;
- y = Math.random() * 2 - 1;
- r = x * x + y * y;
- } while (!r || r > 1);
+ return randomUniform;
+}))(defaultSource$1);
- return mu + sigma * y * Math.sqrt(-2 * Math.log(r) / r);
- };
-};
+var normal = ((function sourceRandomNormal(source) {
+ function randomNormal(mu, sigma) {
+ var x, r;
+ mu = mu == null ? 0 : +mu;
+ sigma = sigma == null ? 1 : +sigma;
+ return function() {
+ var y;
-var logNormal = function() {
- var randomNormal = normal.apply(this, arguments);
- return function() {
- return Math.exp(randomNormal());
- };
-};
+ // If available, use the second previously-generated uniform random.
+ if (x != null) y = x, x = null;
-var irwinHall = function(n) {
- return function() {
- for (var sum = 0, i = 0; i < n; ++i) sum += Math.random();
- return sum;
- };
-};
+ // Otherwise, generate a new x and y.
+ else do {
+ x = source() * 2 - 1;
+ y = source() * 2 - 1;
+ r = x * x + y * y;
+ } while (!r || r > 1);
-var bates = function(n) {
- var randomIrwinHall = irwinHall(n);
- return function() {
- return randomIrwinHall() / n;
- };
-};
+ return mu + sigma * y * Math.sqrt(-2 * Math.log(r) / r);
+ };
+ }
-var exponential$1 = function(lambda) {
- return function() {
- return -Math.log(1 - Math.random()) / lambda;
- };
-};
+ randomNormal.source = sourceRandomNormal;
+ return randomNormal;
+}))(defaultSource$1);
+
+var logNormal = ((function sourceRandomLogNormal(source) {
+ function randomLogNormal() {
+ var randomNormal = normal.source(source).apply(this, arguments);
+ return function() {
+ return Math.exp(randomNormal());
+ };
+ }
+
+ randomLogNormal.source = sourceRandomLogNormal;
+
+ return randomLogNormal;
+}))(defaultSource$1);
+
+var irwinHall = ((function sourceRandomIrwinHall(source) {
+ function randomIrwinHall(n) {
+ return function() {
+ for (var sum = 0, i = 0; i < n; ++i) sum += source();
+ return sum;
+ };
+ }
+
+ randomIrwinHall.source = sourceRandomIrwinHall;
+
+ return randomIrwinHall;
+}))(defaultSource$1);
+
+var bates = ((function sourceRandomBates(source) {
+ function randomBates(n) {
+ var randomIrwinHall = irwinHall.source(source)(n);
+ return function() {
+ return randomIrwinHall() / n;
+ };
+ }
+
+ randomBates.source = sourceRandomBates;
+
+ return randomBates;
+}))(defaultSource$1);
+
+var exponential$1 = ((function sourceRandomExponential(source) {
+ function randomExponential(lambda) {
+ return function() {
+ return -Math.log(1 - source()) / lambda;
+ };
+ }
+
+ randomExponential.source = sourceRandomExponential;
+
+ return randomExponential;
+}))(defaultSource$1);
+
var request = function(url, callback) {
var request,
event = dispatch("beforesend", "progress", "load", "error"),
mimeType,
headers = map$1(),
@@ -11641,22 +11694,44 @@
scale.tickFormat = function(count, specifier) {
return tickFormat(domain(), count, specifier);
};
scale.nice = function(count) {
+ if (count == null) count = 10;
+
var d = domain(),
- i = d.length - 1,
- n = count == null ? 10 : count,
- start = d[0],
- stop = d[i],
- step = tickStep(start, stop, n);
+ i0 = 0,
+ i1 = d.length - 1,
+ start = d[i0],
+ stop = d[i1],
+ step;
- if (step) {
- step = tickStep(Math.floor(start / step) * step, Math.ceil(stop / step) * step, n);
- d[0] = Math.floor(start / step) * step;
- d[i] = Math.ceil(stop / step) * step;
+ if (stop < start) {
+ step = start, start = stop, stop = step;
+ step = i0, i0 = i1, i1 = step;
+ }
+
+ step = tickIncrement(start, stop, count);
+
+ if (step > 0) {
+ start = Math.floor(start / step) * step;
+ stop = Math.ceil(stop / step) * step;
+ step = tickIncrement(start, stop, count);
+ } else if (step < 0) {
+ start = Math.ceil(start * step) / step;
+ stop = Math.floor(stop * step) / step;
+ step = tickIncrement(start, stop, count);
+ }
+
+ if (step > 0) {
+ d[i0] = Math.floor(start / step) * step;
+ d[i1] = Math.ceil(stop / step) * step;
domain(d);
+ } else if (step < 0) {
+ d[i0] = Math.ceil(start * step) / step;
+ d[i1] = Math.floor(stop * step) / step;
+ domain(d);
}
return scale;
};
@@ -13716,10 +13791,96 @@
};
return a;
};
+var slice$5 = Array.prototype.slice;
+
+function linkSource(d) {
+ return d.source;
+}
+
+function linkTarget(d) {
+ return d.target;
+}
+
+function link$2(curve) {
+ var source = linkSource,
+ target = linkTarget,
+ x$$1 = x$3,
+ y$$1 = y$3,
+ context = null;
+
+ function link() {
+ var buffer, argv = slice$5.call(arguments), s = source.apply(this, argv), t = target.apply(this, argv);
+ if (!context) context = buffer = path();
+ curve(context, +x$$1.apply(this, (argv[0] = s, argv)), +y$$1.apply(this, argv), +x$$1.apply(this, (argv[0] = t, argv)), +y$$1.apply(this, argv));
+ if (buffer) return context = null, buffer + "" || null;
+ }
+
+ link.source = function(_) {
+ return arguments.length ? (source = _, link) : source;
+ };
+
+ link.target = function(_) {
+ return arguments.length ? (target = _, link) : target;
+ };
+
+ link.x = function(_) {
+ return arguments.length ? (x$$1 = typeof _ === "function" ? _ : constant$10(+_), link) : x$$1;
+ };
+
+ link.y = function(_) {
+ return arguments.length ? (y$$1 = typeof _ === "function" ? _ : constant$10(+_), link) : y$$1;
+ };
+
+ link.context = function(_) {
+ return arguments.length ? ((context = _ == null ? null : _), link) : context;
+ };
+
+ return link;
+}
+
+function curveHorizontal(context, x0, y0, x1, y1) {
+ context.moveTo(x0, y0);
+ context.bezierCurveTo(x0 = (x0 + x1) / 2, y0, x0, y1, x1, y1);
+}
+
+function curveVertical(context, x0, y0, x1, y1) {
+ context.moveTo(x0, y0);
+ context.bezierCurveTo(x0, y0 = (y0 + y1) / 2, x1, y0, x1, y1);
+}
+
+function curveRadial$1(context, x0, y0, x1, y1) {
+ var p0 = cartesian$1(x0, y0),
+ p1 = cartesian$1(x0, y0 = (y0 + y1) / 2),
+ p2 = cartesian$1(x1, y0),
+ p3 = cartesian$1(x1, y1);
+ context.moveTo(p0[0], p0[1]);
+ context.bezierCurveTo(p1[0], p1[1], p2[0], p2[1], p3[0], p3[1]);
+}
+
+function linkHorizontal() {
+ return link$2(curveHorizontal);
+}
+
+function linkVertical() {
+ return link$2(curveVertical);
+}
+
+function linkRadial() {
+ var l = link$2(curveRadial$1);
+ l.angle = l.x, delete l.x;
+ l.radius = l.y, delete l.y;
+ return l;
+}
+
+function cartesian$1(x$$1, y$$1) {
+ var angle = (x$$1 - 90) / 180 * Math.PI, radius = y$$1;
+ return [radius * Math.cos(angle), radius * Math.sin(angle)];
+}
+
var circle$2 = {
draw: function(context, size) {
var r = Math.sqrt(size / pi$4);
context.moveTo(r, 0);
context.arc(0, 0, r, 0, tau$4);
@@ -14697,17 +14858,15 @@
function stepAfter(context) {
return new Step(context, 1);
}
-var slice$5 = Array.prototype.slice;
-
var none$1 = function(series, order) {
if (!((n = series.length) > 1)) return;
- for (var i = 1, s0, s1 = series[order[0]], n, m = s1.length; i < n; ++i) {
+ for (var i = 1, j, s0, s1 = series[order[0]], n, m = s1.length; i < n; ++i) {
s0 = s1, s1 = series[order[i]];
- for (var j = 0; j < m; ++j) {
+ for (j = 0; j < m; ++j) {
s1[j][1] += s1[j][0] = isNaN(s0[j][1]) ? s0[j][0] : s0[j][1];
}
}
};
@@ -14777,10 +14936,25 @@
if (y) for (i = 0; i < n; ++i) series[i][j][1] /= y;
}
none$1(series, order);
};
+var diverging = function(series, order) {
+ if (!((n = series.length) > 1)) return;
+ for (var i, j = 0, d, dy, yp, yn, n, m = series[order[0]].length; j < m; ++j) {
+ for (yp = yn = 0, i = 0; i < n; ++i) {
+ if ((dy = (d = series[order[i]][j])[1] - d[0]) >= 0) {
+ d[0] = yp, d[1] = yp += dy;
+ } else if (dy < 0) {
+ d[1] = yn, d[0] = yn += dy;
+ } else {
+ d[0] = yp;
+ }
+ }
+ }
+};
+
var silhouette = function(series, order) {
if (!((n = series.length) > 0)) return;
for (var j = 0, s0 = series[order[0]], n, m = s0.length; j < m; ++j) {
for (var i = 0, y = 0; i < n; ++i) y += series[i][j][1] || 0;
s0[j][1] += s0[j][0] = -y / 2;
@@ -15950,11 +16124,12 @@
gestures = [],
listeners = dispatch("start", "zoom", "end"),
touchstarting,
touchending,
touchDelay = 500,
- wheelDelay = 150;
+ wheelDelay = 150,
+ clickDistance2 = 0;
function zoom(selection$$1) {
selection$$1
.on("wheel.zoom", wheeled)
.on("mousedown.zoom", mousedowned)
@@ -16140,21 +16315,26 @@
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),
- p = mouse(this);
+ p = mouse(this),
+ x0 = exports.event.clientX,
+ y0 = exports.event.clientY;
dragDisable(exports.event.view);
nopropagation$2();
g.mouse = [p, this.__zoom.invert(p)];
interrupt(this);
g.start();
function mousemoved() {
noevent$2();
- g.moved = true;
+ if (!g.moved) {
+ var dx = exports.event.clientX - x0, dy = exports.event.clientY - y0;
+ g.moved = dx * dx + dy * dy > clickDistance2;
+ }
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);
@@ -16282,10 +16462,14 @@
zoom.on = function() {
var value = listeners.on.apply(listeners, arguments);
return value === listeners ? zoom : value;
};
+ zoom.clickDistance = function(_) {
+ return arguments.length ? (clickDistance2 = (_ = +_) * _, zoom) : Math.sqrt(clickDistance2);
+ };
+
return zoom;
};
exports.version = version;
exports.bisect = bisectRight;
@@ -16541,20 +16725,24 @@
exports.select = select;
exports.selectAll = selectAll;
exports.selection = selection;
exports.selector = selector;
exports.selectorAll = selectorAll;
+exports.style = styleValue;
exports.touch = touch;
exports.touches = touches;
-exports.window = window;
+exports.window = defaultView;
exports.customEvent = customEvent;
exports.arc = arc;
exports.area = area$2;
exports.line = line;
exports.pie = pie;
exports.radialArea = radialArea;
exports.radialLine = radialLine$1;
+exports.linkHorizontal = linkHorizontal;
+exports.linkVertical = linkVertical;
+exports.linkRadial = linkRadial;
exports.symbol = symbol;
exports.symbols = symbols;
exports.symbolCircle = circle$2;
exports.symbolCross = cross$2;
exports.symbolDiamond = diamond;
@@ -16580,9 +16768,10 @@
exports.curveStep = step;
exports.curveStepAfter = stepAfter;
exports.curveStepBefore = stepBefore;
exports.stack = stack;
exports.stackOffsetExpand = expand;
+exports.stackOffsetDiverging = diverging;
exports.stackOffsetNone = none$1;
exports.stackOffsetSilhouette = silhouette;
exports.stackOffsetWiggle = wiggle;
exports.stackOrderAscending = ascending$2;
exports.stackOrderDescending = descending$2;