2 (
function (global, factory) {
3 typeof exports ===
'object' && typeof module !==
'undefined' ? factory(exports) :
4 typeof define ===
'function' && define.amd ? define([
'exports'], factory) :
5 (factory((global.d3 = global.d3 || {})));
6 }(
this, (
function (exports) {
'use strict';
10 function ascending(a, b) {
11 return a < b ? -1 : a > b ? 1 : a >= b ? 0 : NaN;
14 function bisector(compare) {
15 if (compare.length === 1) compare = ascendingComparator(compare);
17 left:
function(a, x, lo, hi) {
18 if (lo == null) lo = 0;
19 if (hi == null) hi = a.length;
21 var mid = lo + hi >>> 1;
22 if (compare(a[mid], x) < 0) lo = mid + 1;
27 right:
function(a, x, lo, hi) {
28 if (lo == null) lo = 0;
29 if (hi == null) hi = a.length;
31 var mid = lo + hi >>> 1;
32 if (compare(a[mid], x) > 0) hi = mid;
40 function ascendingComparator(f) {
41 return function(d, x) {
42 return ascending(f(d), x);
46 var ascendingBisect = bisector(ascending);
47 var bisectRight = ascendingBisect.right;
48 var bisectLeft = ascendingBisect.left;
50 function pairs(array, f) {
51 if (f == null) f = pair;
52 var i = 0, n = array.length - 1, p = array[0], pairs =
new Array(n < 0 ? 0 : n);
53 while (i < n) pairs[i] = f(p, p = array[++i]);
61 function cross(values0, values1, reduce) {
62 var n0 = values0.length,
64 values =
new Array(n0 * n1),
70 if (reduce == null) reduce = pair;
72 for (i0 = i = 0; i0 < n0; ++i0) {
73 for (value0 = values0[i0], i1 = 0; i1 < n1; ++i1, ++i) {
74 values[i] = reduce(value0, values1[i1]);
81 function descending(a, b) {
82 return b < a ? -1 : b > a ? 1 : b >= a ? 0 : NaN;
86 return x === null ? NaN : +x;
89 function variance(values, valueof) {
90 var n = values.length,
98 if (valueof == null) {
100 if (!isNaN(value = number(values[i]))) {
101 delta = value - mean;
103 sum += delta * (value - mean);
110 if (!isNaN(value = number(valueof(values[i], i, values)))) {
111 delta = value - mean;
113 sum += delta * (value - mean);
118 if (m > 1)
return sum / (m - 1);
121 function deviation(array, f) {
122 var v = variance(array, f);
123 return v ? Math.sqrt(v) : v;
126 function extent(values, valueof) {
127 var n = values.length,
133 if (valueof == null) {
135 if ((value = values[i]) != null && value >= value) {
138 if ((value = values[i]) != null) {
139 if (min > value) min = value;
140 if (max < value) max = value;
149 if ((value = valueof(values[i], i, values)) != null && value >= value) {
152 if ((value = valueof(values[i], i, values)) != null) {
153 if (min > value) min = value;
154 if (max < value) max = value;
164 var array = Array.prototype;
166 var slice = array.slice;
169 function constant(x) {
175 function identity(x) {
179 function sequence(start, stop, step) {
180 start = +start, stop = +stop, step = (n = arguments.length) < 2 ? (stop = start, start = 0, 1) : n < 3 ? 1 : +step;
183 n = Math.max(0, Math.ceil((stop - start) / step)) | 0,
184 range =
new Array(n);
187 range[i] = start + i * step;
193 var e10 = Math.sqrt(50),
197 function ticks(start, stop, count) {
204 stop = +stop, start = +start, count = +count;
205 if (start === stop && count > 0)
return [start];
206 if (reverse = stop < start) n = start, start = stop, stop = n;
207 if ((step = tickIncrement(start, stop, count)) === 0 || !isFinite(step))
return [];
210 start = Math.ceil(start / step);
211 stop = Math.floor(stop / step);
212 ticks =
new Array(n = Math.ceil(stop - start + 1));
213 while (++i < n) ticks[i] = (start + i) * step;
215 start = Math.floor(start * step);
216 stop = Math.ceil(stop * step);
217 ticks =
new Array(n = Math.ceil(start - stop + 1));
218 while (++i < n) ticks[i] = (start - i) / step;
221 if (reverse) ticks.reverse();
226 function tickIncrement(start, stop, count) {
227 var step = (stop - start) / Math.max(0, count),
228 power = Math.floor(Math.log(step) / Math.LN10),
229 error = step / Math.pow(10, power);
231 ? (error >= e10 ? 10 : error >= e5 ? 5 : error >= e2 ? 2 : 1) * Math.pow(10, power)
232 : -Math.pow(10, -power) / (error >= e10 ? 10 : error >= e5 ? 5 : error >= e2 ? 2 : 1);
235 function tickStep(start, stop, count) {
236 var step0 = Math.abs(stop - start) / Math.max(0, count),
237 step1 = Math.pow(10, Math.floor(Math.log(step0) / Math.LN10)),
238 error = step0 / step1;
239 if (error >= e10) step1 *= 10;
240 else if (error >= e5) step1 *= 5;
241 else if (error >= e2) step1 *= 2;
242 return stop < start ? -step1 : step1;
245 function thresholdSturges(values) {
246 return Math.ceil(Math.log(values.length) / Math.LN2) + 1;
249 function histogram() {
250 var value = identity,
252 threshold = thresholdSturges;
254 function histogram(data) {
258 values =
new Array(n);
260 for (i = 0; i < n; ++i) {
261 values[i] = value(data[i], i, data);
264 var xz = domain(values),
267 tz = threshold(values, x0, x1);
270 if (!Array.isArray(tz)) {
271 tz = tickStep(x0, x1, tz);
272 tz = sequence(Math.ceil(x0 / tz) * tz, x1, tz);
277 while (tz[0] <= x0) tz.shift(), --m;
278 while (tz[m - 1] > x1) tz.pop(), --m;
280 var bins =
new Array(m + 1),
284 for (i = 0; i <= m; ++i) {
286 bin.x0 = i > 0 ? tz[i - 1] : x0;
287 bin.x1 = i < m ? tz[i] : x1;
291 for (i = 0; i < n; ++i) {
293 if (x0 <= x && x <= x1) {
294 bins[bisectRight(tz, x, 0, m)].push(data[i]);
301 histogram.value =
function(_) {
302 return arguments.length ? (value = typeof _ ===
"function" ? _ : constant(_), histogram) : value;
305 histogram.domain =
function(_) {
306 return arguments.length ? (domain = typeof _ ===
"function" ? _ : constant([_[0], _[1]]), histogram) : domain;
309 histogram.thresholds =
function(_) {
310 return arguments.length ? (threshold = typeof _ ===
"function" ? _ : Array.isArray(_) ? constant(slice.call(_)) : constant(_), histogram) : threshold;
316 function threshold(values, p, valueof) {
317 if (valueof == null) valueof = number;
318 if (!(n = values.length))
return;
319 if ((p = +p) <= 0 || n < 2)
return +valueof(values[0], 0, values);
320 if (p >= 1)
return +valueof(values[n - 1], n - 1, values);
324 value0 = +valueof(values[i0], i0, values),
325 value1 = +valueof(values[i0 + 1], i0 + 1, values);
326 return value0 + (value1 - value0) * (i - i0);
329 function freedmanDiaconis(values, min, max) {
330 values = map.call(values, number).sort(ascending);
331 return Math.ceil((max - min) / (2 * (threshold(values, 0.75) - threshold(values, 0.25)) * Math.pow(values.length, -1 / 3)));
334 function scott(values, min, max) {
335 return Math.ceil((max - min) / (3.5 * deviation(values) * Math.pow(values.length, -1 / 3)));
338 function max(values, valueof) {
339 var n = values.length,
344 if (valueof == null) {
346 if ((value = values[i]) != null && value >= value) {
349 if ((value = values[i]) != null && value > max) {
359 if ((value = valueof(values[i], i, values)) != null && value >= value) {
362 if ((value = valueof(values[i], i, values)) != null && value > max) {
373 function mean(values, valueof) {
374 var n = values.length,
380 if (valueof == null) {
382 if (!isNaN(value = number(values[i]))) sum += value;
389 if (!isNaN(value = number(valueof(values[i], i, values)))) sum += value;
394 if (m)
return sum / m;
397 function median(values, valueof) {
398 var n = values.length,
403 if (valueof == null) {
405 if (!isNaN(value = number(values[i]))) {
413 if (!isNaN(value = number(valueof(values[i], i, values)))) {
419 return threshold(numbers.sort(ascending), 0.5);
422 function merge(arrays) {
423 var n = arrays.length,
430 while (++i < n) j += arrays[i].length;
431 merged =
new Array(j);
437 merged[--j] = array[m];
444 function min(values, valueof) {
445 var n = values.length,
450 if (valueof == null) {
452 if ((value = values[i]) != null && value >= value) {
455 if ((value = values[i]) != null && min > value) {
465 if ((value = valueof(values[i], i, values)) != null && value >= value) {
468 if ((value = valueof(values[i], i, values)) != null && min > value) {
479 function permute(array, indexes) {
480 var i = indexes.length, permutes =
new Array(i);
481 while (i--) permutes[i] = array[indexes[i]];
485 function scan(values, compare) {
486 if (!(n = values.length))
return;
493 if (compare == null) compare = ascending;
496 if (compare(xi = values[i], xj) < 0 || compare(xj, xj) !== 0) {
501 if (compare(xj, xj) === 0)
return j;
504 function shuffle(array, i0, i1) {
505 var m = (i1 == null ? array.length : i1) - (i0 = i0 == null ? 0 : +i0),
510 i = Math.random() * m-- | 0;
512 array[m + i0] = array[i + i0];
519 function sum(values, valueof) {
520 var n = values.length,
525 if (valueof == null) {
527 if (value = +values[i]) sum += value;
533 if (value = +valueof(values[i], i, values)) sum += value;
540 function transpose(matrix) {
541 if (!(n = matrix.length))
return [];
542 for (var i = -1, m = min(matrix, length), transpose =
new Array(m); ++i < m;) {
543 for (var j = -1, n, row = transpose[i] =
new Array(n); ++j < n;) {
544 row[j] = matrix[j][i];
555 return transpose(arguments);
558 var slice$1 = Array.prototype.slice;
560 function identity$1(x) {
570 function translateX(x) {
571 return "translate(" + (x + 0.5) +
",0)";
574 function translateY(y) {
575 return "translate(0," + (y + 0.5) +
")";
578 function number$1(scale) {
584 function center(scale) {
585 var offset = Math.max(0, scale.bandwidth() - 1) / 2;
586 if (scale.round()) offset = Math.round(offset);
588 return +scale(d) + offset;
592 function entering() {
596 function axis(orient, scale) {
597 var tickArguments = [],
603 k = orient === top || orient === left ? -1 : 1,
604 x = orient === left || orient === right ?
"x" :
"y",
605 transform = orient === top || orient === bottom ? translateX : translateY;
607 function axis(context) {
608 var values = tickValues == null ? (scale.ticks ? scale.ticks.apply(scale, tickArguments) : scale.domain()) : tickValues,
609 format = tickFormat == null ? (scale.tickFormat ? scale.tickFormat.apply(scale, tickArguments) : identity$1) : tickFormat,
610 spacing = Math.max(tickSizeInner, 0) + tickPadding,
611 range = scale.range(),
612 range0 = +range[0] + 0.5,
613 range1 = +range[range.length - 1] + 0.5,
614 position = (scale.bandwidth ? center : number$1)(scale.copy()),
615 selection = context.selection ? context.selection() : context,
616 path = selection.selectAll(
".domain").data([null]),
617 tick = selection.selectAll(
".tick").data(values, scale).order(),
618 tickExit = tick.exit(),
619 tickEnter = tick.enter().append(
"g").attr(
"class",
"tick"),
620 line = tick.select(
"line"),
621 text = tick.select(
"text");
623 path = path.merge(path.enter().insert(
"path",
".tick")
624 .attr(
"class",
"domain")
625 .attr(
"stroke",
"currentColor"));
627 tick = tick.merge(tickEnter);
629 line = line.merge(tickEnter.append(
"line")
630 .attr(
"stroke",
"currentColor")
631 .attr(x +
"2", k * tickSizeInner));
633 text = text.merge(tickEnter.append(
"text")
634 .attr(
"fill",
"currentColor")
635 .attr(x, k * spacing)
636 .attr(
"dy", orient === top ?
"0em" : orient === bottom ?
"0.71em" :
"0.32em"));
638 if (context !== selection) {
639 path = path.transition(context);
640 tick = tick.transition(context);
641 line = line.transition(context);
642 text = text.transition(context);
644 tickExit = tickExit.transition(context)
645 .attr(
"opacity", epsilon)
646 .attr(
"transform",
function(d) {
return isFinite(d = position(d)) ? transform(d) : this.getAttribute(
"transform"); });
649 .attr(
"opacity", epsilon)
650 .attr(
"transform",
function(d) { var p = this.parentNode.__axis;
return transform(p && isFinite(p = p(d)) ? p : position(d)); });
656 .attr(
"d", orient === left || orient == right
657 ? (tickSizeOuter ?
"M" + k * tickSizeOuter +
"," + range0 +
"H0.5V" + range1 +
"H" + k * tickSizeOuter :
"M0.5," + range0 +
"V" + range1)
658 : (tickSizeOuter ?
"M" + range0 +
"," + k * tickSizeOuter +
"V0.5H" + range1 +
"V" + k * tickSizeOuter :
"M" + range0 +
",0.5H" + range1));
662 .attr(
"transform",
function(d) {
return transform(position(d)); });
665 .attr(x +
"2", k * tickSizeInner);
668 .attr(x, k * spacing)
671 selection.filter(entering)
672 .attr(
"fill",
"none")
673 .attr(
"font-size", 10)
674 .attr(
"font-family",
"sans-serif")
675 .attr(
"text-anchor", orient === right ?
"start" : orient === left ?
"end" :
"middle");
678 .each(
function() { this.__axis = position; });
681 axis.scale =
function(_) {
682 return arguments.length ? (scale = _, axis) : scale;
685 axis.ticks =
function() {
686 return tickArguments = slice$1.call(arguments), axis;
689 axis.tickArguments =
function(_) {
690 return arguments.length ? (tickArguments = _ == null ? [] : slice$1.call(_), axis) : tickArguments.slice();
693 axis.tickValues =
function(_) {
694 return arguments.length ? (tickValues = _ == null ? null : slice$1.call(_), axis) : tickValues && tickValues.slice();
697 axis.tickFormat =
function(_) {
698 return arguments.length ? (tickFormat = _, axis) : tickFormat;
701 axis.tickSize =
function(_) {
702 return arguments.length ? (tickSizeInner = tickSizeOuter = +_, axis) : tickSizeInner;
705 axis.tickSizeInner =
function(_) {
706 return arguments.length ? (tickSizeInner = +_, axis) : tickSizeInner;
709 axis.tickSizeOuter =
function(_) {
710 return arguments.length ? (tickSizeOuter = +_, axis) : tickSizeOuter;
713 axis.tickPadding =
function(_) {
714 return arguments.length ? (tickPadding = +_, axis) : tickPadding;
720 function axisTop(scale) {
721 return axis(top, scale);
724 function axisRight(scale) {
725 return axis(right, scale);
728 function axisBottom(scale) {
729 return axis(bottom, scale);
732 function axisLeft(scale) {
733 return axis(left, scale);
736 var noop = {value:
function() {}};
738 function dispatch() {
739 for (var i = 0, n = arguments.length, _ = {}, t; i < n; ++i) {
740 if (!(t = arguments[i] +
"") || (t in _))
throw new Error(
"illegal type: " + t);
743 return new Dispatch(_);
746 function Dispatch(_) {
750 function parseTypenames(typenames, types) {
751 return typenames.trim().split(/^|\s+/).map(
function(t) {
752 var name =
"", i = t.indexOf(
".");
753 if (i >= 0) name = t.slice(i + 1), t = t.slice(0, i);
754 if (t && !types.hasOwnProperty(t))
throw new Error(
"unknown type: " + t);
755 return {type: t, name: name};
759 Dispatch.prototype = dispatch.prototype = {
760 constructor: Dispatch,
761 on:
function(
typename, callback) {
763 T = parseTypenames(
typename +
"", _),
769 if (arguments.length < 2) {
770 while (++i < n)
if ((t = (
typename = T[i]).type) && (t =
get(_[t],
typename.name)))
return t;
776 if (callback != null && typeof callback !==
"function")
throw new Error(
"invalid callback: " + callback);
778 if (t = (
typename = T[i]).type) _[t] = set(_[t],
typename.name, callback);
779 else if (callback == null)
for (t in _) _[t] = set(_[t],
typename.name, null);
785 var copy = {}, _ = this._;
786 for (var t in _) copy[t] = _[t].slice();
787 return new Dispatch(copy);
789 call:
function(type, that) {
790 if ((n = arguments.length - 2) > 0)
for (var args =
new Array(n), i = 0, n, t; i < n; ++i) args[i] = arguments[i + 2];
791 if (!this._.hasOwnProperty(type))
throw new Error(
"unknown type: " + type);
792 for (t = this._[type], i = 0, n = t.length; i < n; ++i) t[i].value.apply(that, args);
794 apply:
function(type, that, args) {
795 if (!this._.hasOwnProperty(type))
throw new Error(
"unknown type: " + type);
796 for (var t = this._[type], i = 0, n = t.length; i < n; ++i) t[i].value.apply(that, args);
800 function get(type, name) {
801 for (var i = 0, n = type.length, c; i < n; ++i) {
802 if ((c = type[i]).name === name) {
808 function set(type, name, callback) {
809 for (var i = 0, n = type.length; i < n; ++i) {
810 if (type[i].name === name) {
811 type[i] = noop, type = type.slice(0, i).concat(type.slice(i + 1));
815 if (callback != null) type.push({name: name, value: callback});
819 var xhtml =
"http://www.w3.org/1999/xhtml";
822 svg:
"http://www.w3.org/2000/svg",
824 xlink:
"http://www.w3.org/1999/xlink",
825 xml:
"http://www.w3.org/XML/1998/namespace",
826 xmlns:
"http://www.w3.org/2000/xmlns/"
829 function namespace(name) {
830 var prefix = name +=
"", i = prefix.indexOf(
":");
831 if (i >= 0 && (prefix = name.slice(0, i)) !==
"xmlns") name = name.slice(i + 1);
832 return namespaces.hasOwnProperty(prefix) ? {space: namespaces[prefix], local: name} : name;
835 function creatorInherit(name) {
837 var document = this.ownerDocument,
838 uri = this.namespaceURI;
839 return uri === xhtml && document.documentElement.namespaceURI === xhtml
840 ? document.createElement(name)
841 : document.createElementNS(uri, name);
845 function creatorFixed(fullname) {
847 return this.ownerDocument.createElementNS(fullname.space, fullname.local);
851 function creator(name) {
852 var fullname =
namespace(name);
853 return (fullname.local
855 : creatorInherit)(fullname);
860 function selector(selector) {
861 return selector == null ? none :
function() {
862 return this.querySelector(selector);
866 function selection_select(select) {
867 if (typeof select !==
"function") select = selector(select);
869 for (var groups = this._groups, m = groups.length, subgroups =
new Array(m), j = 0; j < m; ++j) {
870 for (var group = groups[j], n = group.length, subgroup = subgroups[j] =
new Array(n), node, subnode, i = 0; i < n; ++i) {
871 if ((node = group[i]) && (subnode = select.call(node, node.__data__, i, group))) {
872 if (
"__data__" in node) subnode.__data__ = node.__data__;
873 subgroup[i] = subnode;
878 return new Selection(subgroups, this._parents);
885 function selectorAll(selector) {
886 return selector == null ? empty :
function() {
887 return this.querySelectorAll(selector);
891 function selection_selectAll(select) {
892 if (typeof select !==
"function") select = selectorAll(select);
894 for (var groups = this._groups, m = groups.length, subgroups = [], parents = [], j = 0; j < m; ++j) {
895 for (var group = groups[j], n = group.length, node, i = 0; i < n; ++i) {
896 if (node = group[i]) {
897 subgroups.push(select.call(node, node.__data__, i, group));
903 return new Selection(subgroups, parents);
906 var matcher =
function(selector) {
908 return this.matches(selector);
912 if (typeof document !==
"undefined") {
913 var element = document.documentElement;
914 if (!element.matches) {
915 var vendorMatches = element.webkitMatchesSelector
916 || element.msMatchesSelector
917 || element.mozMatchesSelector
918 || element.oMatchesSelector;
919 matcher =
function(selector) {
921 return vendorMatches.call(
this, selector);
927 var matcher$1 = matcher;
929 function selection_filter(match) {
930 if (typeof match !==
"function") match = matcher$1(match);
932 for (var groups = this._groups, m = groups.length, subgroups =
new Array(m), j = 0; j < m; ++j) {
933 for (var group = groups[j], n = group.length, subgroup = subgroups[j] = [], node, i = 0; i < n; ++i) {
934 if ((node = group[i]) && match.call(node, node.__data__, i, group)) {
940 return new Selection(subgroups, this._parents);
943 function sparse(update) {
944 return new Array(update.length);
947 function selection_enter() {
948 return new Selection(this._enter || this._groups.map(sparse), this._parents);
951 function EnterNode(parent, datum) {
952 this.ownerDocument = parent.ownerDocument;
953 this.namespaceURI = parent.namespaceURI;
955 this._parent = parent;
956 this.__data__ = datum;
959 EnterNode.prototype = {
960 constructor: EnterNode,
961 appendChild:
function(child) {
return this._parent.insertBefore(child, this._next); },
962 insertBefore:
function(child, next) {
return this._parent.insertBefore(child, next); },
963 querySelector:
function(selector) {
return this._parent.querySelector(selector); },
964 querySelectorAll:
function(selector) {
return this._parent.querySelectorAll(selector); }
967 function constant$1(x) {
975 function bindIndex(parent, group, enter, update, exit, data) {
978 groupLength = group.length,
979 dataLength = data.length;
984 for (; i < dataLength; ++i) {
985 if (node = group[i]) {
986 node.__data__ = data[i];
989 enter[i] =
new EnterNode(parent, data[i]);
994 for (; i < groupLength; ++i) {
995 if (node = group[i]) {
1001 function bindKey(parent, group, enter, update, exit, data, key) {
1004 nodeByKeyValue = {},
1005 groupLength = group.length,
1006 dataLength = data.length,
1007 keyValues =
new Array(groupLength),
1012 for (i = 0; i < groupLength; ++i) {
1013 if (node = group[i]) {
1014 keyValues[i] = keyValue = keyPrefix + key.call(node, node.__data__, i, group);
1015 if (keyValue in nodeByKeyValue) {
1018 nodeByKeyValue[keyValue] = node;
1026 for (i = 0; i < dataLength; ++i) {
1027 keyValue = keyPrefix + key.call(parent, data[i], i, data);
1028 if (node = nodeByKeyValue[keyValue]) {
1030 node.__data__ = data[i];
1031 nodeByKeyValue[keyValue] = null;
1033 enter[i] =
new EnterNode(parent, data[i]);
1038 for (i = 0; i < groupLength; ++i) {
1039 if ((node = group[i]) && (nodeByKeyValue[keyValues[i]] === node)) {
1045 function selection_data(value, key) {
1047 data =
new Array(this.size()), j = -1;
1048 this.each(
function(d) { data[++j] = d; });
1052 var bind = key ? bindKey : bindIndex,
1053 parents = this._parents,
1054 groups = this._groups;
1056 if (typeof value !==
"function") value = constant$1(value);
1058 for (var m = groups.length, update =
new Array(m), enter =
new Array(m), exit =
new Array(m), j = 0; j < m; ++j) {
1059 var parent = parents[j],
1061 groupLength = group.length,
1062 data = value.call(parent, parent && parent.__data__, j, parents),
1063 dataLength = data.length,
1064 enterGroup = enter[j] =
new Array(dataLength),
1065 updateGroup = update[j] =
new Array(dataLength),
1066 exitGroup = exit[j] =
new Array(groupLength);
1068 bind(parent, group, enterGroup, updateGroup, exitGroup, data, key);
1073 for (var i0 = 0, i1 = 0, previous, next; i0 < dataLength; ++i0) {
1074 if (previous = enterGroup[i0]) {
1075 if (i0 >= i1) i1 = i0 + 1;
1076 while (!(next = updateGroup[i1]) && ++i1 < dataLength);
1077 previous._next = next || null;
1082 update =
new Selection(update, parents);
1083 update._enter = enter;
1084 update._exit = exit;
1088 function selection_exit() {
1089 return new Selection(this._exit || this._groups.map(sparse), this._parents);
1092 function selection_merge(selection$$1) {
1094 for (var groups0 = this._groups, groups1 = selection$$1._groups, m0 = groups0.length, m1 = groups1.length, m = Math.min(m0, m1), merges =
new Array(m0), j = 0; j < m; ++j) {
1095 for (var group0 = groups0[j], group1 = groups1[j], n = group0.length, merge = merges[j] =
new Array(n), node, i = 0; i < n; ++i) {
1096 if (node = group0[i] || group1[i]) {
1102 for (; j < m0; ++j) {
1103 merges[j] = groups0[j];
1106 return new Selection(merges, this._parents);
1109 function selection_order() {
1111 for (var groups = this._groups, j = -1, m = groups.length; ++j < m;) {
1112 for (var group = groups[j], i = group.length - 1, next = group[i], node; --i >= 0;) {
1113 if (node = group[i]) {
1114 if (next && next !== node.nextSibling) next.parentNode.insertBefore(node, next);
1123 function selection_sort(compare) {
1124 if (!compare) compare = ascending$1;
1126 function compareNode(a, b) {
1127 return a && b ? compare(a.__data__, b.__data__) : !a - !b;
1130 for (var groups = this._groups, m = groups.length, sortgroups =
new Array(m), j = 0; j < m; ++j) {
1131 for (var group = groups[j], n = group.length, sortgroup = sortgroups[j] =
new Array(n), node, i = 0; i < n; ++i) {
1132 if (node = group[i]) {
1133 sortgroup[i] = node;
1136 sortgroup.sort(compareNode);
1139 return new Selection(sortgroups, this._parents).order();
1142 function ascending$1(a, b) {
1143 return a < b ? -1 : a > b ? 1 : a >= b ? 0 : NaN;
1146 function selection_call() {
1147 var callback = arguments[0];
1148 arguments[0] =
this;
1149 callback.apply(null, arguments);
1153 function selection_nodes() {
1154 var nodes =
new Array(this.size()), i = -1;
1155 this.each(
function() { nodes[++i] =
this; });
1159 function selection_node() {
1161 for (var groups = this._groups, j = 0, m = groups.length; j < m; ++j) {
1162 for (var group = groups[j], i = 0, n = group.length; i < n; ++i) {
1163 var node = group[i];
1164 if (node)
return node;
1171 function selection_size() {
1173 this.each(
function() { ++size; });
1177 function selection_empty() {
1178 return !this.node();
1181 function selection_each(callback) {
1183 for (var groups = this._groups, j = 0, m = groups.length; j < m; ++j) {
1184 for (var group = groups[j], i = 0, n = group.length, node; i < n; ++i) {
1185 if (node = group[i]) callback.call(node, node.__data__, i, group);
1192 function attrRemove(name) {
1194 this.removeAttribute(name);
1198 function attrRemoveNS(fullname) {
1200 this.removeAttributeNS(fullname.space, fullname.local);
1204 function attrConstant(name, value) {
1206 this.setAttribute(name, value);
1210 function attrConstantNS(fullname, value) {
1212 this.setAttributeNS(fullname.space, fullname.local, value);
1216 function attrFunction(name, value) {
1218 var v = value.apply(
this, arguments);
1219 if (v == null) this.removeAttribute(name);
1220 else this.setAttribute(name, v);
1224 function attrFunctionNS(fullname, value) {
1226 var v = value.apply(
this, arguments);
1227 if (v == null) this.removeAttributeNS(fullname.space, fullname.local);
1228 else this.setAttributeNS(fullname.space, fullname.local, v);
1232 function selection_attr(name, value) {
1233 var fullname =
namespace(name);
1235 if (arguments.length < 2) {
1236 var node = this.node();
1237 return fullname.local
1238 ? node.getAttributeNS(fullname.space, fullname.local)
1239 : node.getAttribute(fullname);
1242 return this.each((value == null
1243 ? (fullname.local ? attrRemoveNS : attrRemove) : (typeof value ===
"function"
1244 ? (fullname.local ? attrFunctionNS : attrFunction)
1245 : (fullname.local ? attrConstantNS : attrConstant)))(fullname, value));
1248 function defaultView(node) {
1249 return (node.ownerDocument && node.ownerDocument.defaultView)
1250 || (node.document && node)
1251 || node.defaultView;
1254 function styleRemove(name) {
1256 this.style.removeProperty(name);
1260 function styleConstant(name, value, priority) {
1262 this.style.setProperty(name, value, priority);
1266 function styleFunction(name, value, priority) {
1268 var v = value.apply(
this, arguments);
1269 if (v == null) this.style.removeProperty(name);
1270 else this.style.setProperty(name, v, priority);
1274 function selection_style(name, value, priority) {
1275 return arguments.length > 1
1276 ? this.each((value == null
1277 ? styleRemove : typeof value ===
"function"
1279 : styleConstant)(name, value, priority == null ?
"" : priority))
1280 : styleValue(this.node(), name);
1283 function styleValue(node, name) {
1284 return node.style.getPropertyValue(name)
1285 || defaultView(node).getComputedStyle(node, null).getPropertyValue(name);
1288 function propertyRemove(name) {
1294 function propertyConstant(name, value) {
1300 function propertyFunction(name, value) {
1302 var v = value.apply(
this, arguments);
1303 if (v == null)
delete this[name];
1304 else this[name] = v;
1308 function selection_property(name, value) {
1309 return arguments.length > 1
1310 ? this.each((value == null
1311 ? propertyRemove : typeof value ===
"function"
1313 : propertyConstant)(name, value))
1314 : this.node()[name];
1317 function classArray(
string) {
1318 return string.trim().split(/^|\s+/);
1321 function classList(node) {
1322 return node.classList ||
new ClassList(node);
1325 function ClassList(node) {
1327 this._names = classArray(node.getAttribute(
"class") ||
"");
1330 ClassList.prototype = {
1331 add:
function(name) {
1332 var i = this._names.indexOf(name);
1334 this._names.push(name);
1335 this._node.setAttribute(
"class", this._names.join(
" "));
1338 remove:
function(name) {
1339 var i = this._names.indexOf(name);
1341 this._names.splice(i, 1);
1342 this._node.setAttribute(
"class", this._names.join(
" "));
1345 contains:
function(name) {
1346 return this._names.indexOf(name) >= 0;
1350 function classedAdd(node, names) {
1351 var list = classList(node), i = -1, n = names.length;
1352 while (++i < n) list.add(names[i]);
1355 function classedRemove(node, names) {
1356 var list = classList(node), i = -1, n = names.length;
1357 while (++i < n) list.remove(names[i]);
1360 function classedTrue(names) {
1362 classedAdd(
this, names);
1366 function classedFalse(names) {
1368 classedRemove(
this, names);
1372 function classedFunction(names, value) {
1374 (value.apply(
this, arguments) ? classedAdd : classedRemove)(
this, names);
1378 function selection_classed(name, value) {
1379 var names = classArray(name +
"");
1381 if (arguments.length < 2) {
1382 var list = classList(this.node()), i = -1, n = names.length;
1383 while (++i < n)
if (!list.contains(names[i]))
return false;
1387 return this.each((typeof value ===
"function"
1388 ? classedFunction : value
1390 : classedFalse)(names, value));
1393 function textRemove() {
1394 this.textContent =
"";
1397 function textConstant(value) {
1399 this.textContent = value;
1403 function textFunction(value) {
1405 var v = value.apply(
this, arguments);
1406 this.textContent = v == null ?
"" : v;
1410 function selection_text(value) {
1411 return arguments.length
1412 ? this.each(value == null
1413 ? textRemove : (typeof value ===
"function"
1415 : textConstant)(value))
1416 : this.node().textContent;
1419 function htmlRemove() {
1420 this.innerHTML =
"";
1423 function htmlConstant(value) {
1425 this.innerHTML = value;
1429 function htmlFunction(value) {
1431 var v = value.apply(
this, arguments);
1432 this.innerHTML = v == null ?
"" : v;
1436 function selection_html(value) {
1437 return arguments.length
1438 ? this.each(value == null
1439 ? htmlRemove : (typeof value ===
"function"
1441 : htmlConstant)(value))
1442 : this.node().innerHTML;
1446 if (this.nextSibling) this.parentNode.appendChild(
this);
1449 function selection_raise() {
1450 return this.each(
raise);
1454 if (this.previousSibling) this.parentNode.insertBefore(
this, this.parentNode.firstChild);
1457 function selection_lower() {
1458 return this.each(lower);
1461 function selection_append(name) {
1462 var create = typeof name ===
"function" ? name : creator(name);
1463 return this.select(
function() {
1464 return this.appendChild(create.apply(
this, arguments));
1468 function constantNull() {
1472 function selection_insert(name, before) {
1473 var create = typeof name ===
"function" ? name : creator(name),
1474 select = before == null ? constantNull : typeof before ===
"function" ? before : selector(before);
1475 return this.select(
function() {
1476 return this.insertBefore(create.apply(
this, arguments), select.apply(
this, arguments) || null);
1481 var parent = this.parentNode;
1482 if (parent) parent.removeChild(
this);
1485 function selection_remove() {
1486 return this.each(
remove);
1489 function selection_cloneShallow() {
1490 return this.parentNode.insertBefore(this.cloneNode(
false), this.nextSibling);
1493 function selection_cloneDeep() {
1494 return this.parentNode.insertBefore(this.cloneNode(
true), this.nextSibling);
1497 function selection_clone(deep) {
1498 return this.select(deep ? selection_cloneDeep : selection_cloneShallow);
1501 function selection_datum(value) {
1502 return arguments.length
1503 ? this.property(
"__data__", value)
1504 : this.node().__data__;
1507 var filterEvents = {};
1509 exports.event = null;
1511 if (typeof document !==
"undefined") {
1512 var element$1 = document.documentElement;
1513 if (!(
"onmouseenter" in element$1)) {
1514 filterEvents = {mouseenter:
"mouseover", mouseleave:
"mouseout"};
1518 function filterContextListener(listener, index, group) {
1519 listener = contextListener(listener, index, group);
1520 return function(event) {
1521 var related =
event.relatedTarget;
1522 if (!related || (related !==
this && !(related.compareDocumentPosition(
this) & 8))) {
1523 listener.call(
this, event);
1528 function contextListener(listener, index, group) {
1529 return function(event1) {
1530 var event0 = exports.event;
1531 exports.event = event1;
1533 listener.call(
this, this.__data__, index, group);
1535 exports.event = event0;
1540 function parseTypenames$1(typenames) {
1541 return typenames.trim().split(/^|\s+/).map(
function(t) {
1542 var name =
"", i = t.indexOf(
".");
1543 if (i >= 0) name = t.slice(i + 1), t = t.slice(0, i);
1544 return {type: t, name: name};
1548 function onRemove(
typename) {
1552 for (var j = 0, i = -1, m = on.length, o; j < m; ++j) {
1553 if (o = on[j], (!
typename.type || o.type ===
typename.type) && o.name ===
typename.name) {
1554 this.removeEventListener(o.type, o.listener, o.capture);
1559 if (++i) on.length = i;
1560 else delete this.__on;
1564 function onAdd(
typename, value, capture) {
1565 var wrap = filterEvents.hasOwnProperty(
typename.type) ? filterContextListener : contextListener;
1566 return function(d, i, group) {
1567 var on = this.__on, o, listener = wrap(value, i, group);
1568 if (on)
for (var j = 0, m = on.length; j < m; ++j) {
1569 if ((o = on[j]).type ===
typename.type && o.name ===
typename.name) {
1570 this.removeEventListener(o.type, o.listener, o.capture);
1571 this.addEventListener(o.type, o.listener = listener, o.capture = capture);
1576 this.addEventListener(
typename.type, listener, capture);
1577 o = {type:
typename.type, name:
typename.name, value: value, listener: listener, capture: capture};
1578 if (!on) this.__on = [o];
1583 function selection_on(
typename, value, capture) {
1584 var typenames = parseTypenames$1(
typename +
""), i, n = typenames.length, t;
1586 if (arguments.length < 2) {
1587 var on = this.node().__on;
1588 if (on)
for (var j = 0, m = on.length, o; j < m; ++j) {
1589 for (i = 0, o = on[j]; i < n; ++i) {
1590 if ((t = typenames[i]).type === o.type && t.name === o.name) {
1598 on = value ? onAdd : onRemove;
1599 if (capture == null) capture =
false;
1600 for (i = 0; i < n; ++i) this.each(on(typenames[i], value, capture));
1604 function customEvent(event1, listener, that, args) {
1605 var event0 = exports.event;
1606 event1.sourceEvent = exports.event;
1607 exports.event = event1;
1609 return listener.apply(that, args);
1611 exports.event = event0;
1615 function dispatchEvent(node, type, params) {
1616 var window = defaultView(node),
1617 event = window.CustomEvent;
1619 if (typeof event ===
"function") {
1620 event =
new event(type, params);
1622 event = window.document.createEvent(
"Event");
1623 if (params)
event.initEvent(type, params.bubbles, params.cancelable),
event.detail = params.detail;
1624 else event.initEvent(type,
false,
false);
1627 node.dispatchEvent(event);
1630 function dispatchConstant(type, params) {
1632 return dispatchEvent(
this, type, params);
1636 function dispatchFunction(type, params) {
1638 return dispatchEvent(
this, type, params.apply(
this, arguments));
1642 function selection_dispatch(type, params) {
1643 return this.each((typeof params ===
"function"
1645 : dispatchConstant)(type, params));
1650 function Selection(groups, parents) {
1651 this._groups = groups;
1652 this._parents = parents;
1655 function selection() {
1656 return new Selection([[document.documentElement]], root);
1659 Selection.prototype = selection.prototype = {
1660 constructor: Selection,
1661 select: selection_select,
1662 selectAll: selection_selectAll,
1663 filter: selection_filter,
1664 data: selection_data,
1665 enter: selection_enter,
1666 exit: selection_exit,
1667 merge: selection_merge,
1668 order: selection_order,
1669 sort: selection_sort,
1670 call: selection_call,
1671 nodes: selection_nodes,
1672 node: selection_node,
1673 size: selection_size,
1674 empty: selection_empty,
1675 each: selection_each,
1676 attr: selection_attr,
1677 style: selection_style,
1678 property: selection_property,
1679 classed: selection_classed,
1680 text: selection_text,
1681 html: selection_html,
1682 raise: selection_raise,
1683 lower: selection_lower,
1684 append: selection_append,
1685 insert: selection_insert,
1686 remove: selection_remove,
1687 clone: selection_clone,
1688 datum: selection_datum,
1690 dispatch: selection_dispatch
1693 function select(selector) {
1694 return typeof selector ===
"string"
1695 ?
new Selection([[document.querySelector(selector)]], [document.documentElement])
1696 :
new Selection([[selector]], root);
1699 function create(name) {
1700 return select(creator(name).call(document.documentElement));
1710 this._ =
"@" + (++nextId).toString(36);
1713 Local.prototype = local.prototype = {
1715 get:
function(node) {
1717 while (!(
id in node))
if (!(node = node.parentNode))
return;
1720 set:
function(node, value) {
1721 return node[this._] = value;
1723 remove:
function(node) {
1724 return this._ in node &&
delete node[this._];
1726 toString:
function() {
1731 function sourceEvent() {
1732 var current = exports.event, source;
1733 while (source = current.sourceEvent) current = source;
1737 function point(node, event) {
1738 var svg = node.ownerSVGElement || node;
1740 if (svg.createSVGPoint) {
1741 var point = svg.createSVGPoint();
1742 point.x =
event.clientX, point.y =
event.clientY;
1743 point = point.matrixTransform(node.getScreenCTM().inverse());
1744 return [point.x, point.y];
1747 var rect = node.getBoundingClientRect();
1748 return [
event.clientX - rect.left - node.clientLeft,
event.clientY - rect.top - node.clientTop];
1751 function mouse(node) {
1752 var
event = sourceEvent();
1753 if (event.changedTouches)
event =
event.changedTouches[0];
1754 return point(node, event);
1757 function selectAll(selector) {
1758 return typeof selector ===
"string"
1759 ?
new Selection([document.querySelectorAll(selector)], [document.documentElement])
1760 :
new Selection([selector == null ? [] : selector], root);
1763 function touch(node, touches, identifier) {
1764 if (arguments.length < 3) identifier = touches, touches = sourceEvent().changedTouches;
1766 for (var i = 0, n = touches ? touches.length : 0, touch; i < n; ++i) {
1767 if ((touch = touches[i]).identifier === identifier) {
1768 return point(node, touch);
1775 function touches(node, touches) {
1776 if (touches == null) touches = sourceEvent().touches;
1778 for (var i = 0, n = touches ? touches.length : 0, points =
new Array(n); i < n; ++i) {
1779 points[i] = point(node, touches[i]);
1785 function nopropagation() {
1786 exports.event.stopImmediatePropagation();
1789 function noevent() {
1790 exports.event.preventDefault();
1791 exports.event.stopImmediatePropagation();
1794 function dragDisable(view) {
1795 var root = view.document.documentElement,
1796 selection$$1 = select(view).on(
"dragstart.drag", noevent,
true);
1797 if (
"onselectstart" in root) {
1798 selection$$1.on(
"selectstart.drag", noevent,
true);
1800 root.__noselect = root.style.MozUserSelect;
1801 root.style.MozUserSelect =
"none";
1805 function yesdrag(view, noclick) {
1806 var root = view.document.documentElement,
1807 selection$$1 = select(view).on(
"dragstart.drag", null);
1809 selection$$1.on(
"click.drag", noevent,
true);
1810 setTimeout(
function() { selection$$1.on(
"click.drag", null); }, 0);
1812 if (
"onselectstart" in root) {
1813 selection$$1.on(
"selectstart.drag", null);
1815 root.style.MozUserSelect = root.__noselect;
1816 delete root.__noselect;
1820 function constant$2(x) {
1826 function DragEvent(target, type, subject,
id, active, x, y, dx, dy, dispatch) {
1827 this.target = target;
1829 this.subject = subject;
1830 this.identifier = id;
1831 this.active = active;
1839 DragEvent.prototype.on =
function() {
1840 var value = this._.on.apply(this._, arguments);
1841 return value === this._ ?
this : value;
1845 function defaultFilter() {
1846 return !exports.event.button;
1849 function defaultContainer() {
1850 return this.parentNode;
1853 function defaultSubject(d) {
1854 return d == null ? {x: exports.event.x, y: exports.event.y} : d;
1857 function defaultTouchable() {
1858 return "ontouchstart" in
this;
1862 var filter = defaultFilter,
1863 container = defaultContainer,
1864 subject = defaultSubject,
1865 touchable = defaultTouchable,
1867 listeners = dispatch(
"start",
"drag",
"end"),
1875 function drag(selection$$1) {
1877 .on(
"mousedown.drag", mousedowned)
1879 .on(
"touchstart.drag", touchstarted)
1880 .on(
"touchmove.drag", touchmoved)
1881 .on(
"touchend.drag touchcancel.drag", touchended)
1882 .style(
"touch-action",
"none")
1883 .style(
"-webkit-tap-highlight-color",
"rgba(0,0,0,0)");
1886 function mousedowned() {
1887 if (touchending || !filter.apply(
this, arguments))
return;
1888 var gesture = beforestart(
"mouse", container.apply(
this, arguments), mouse,
this, arguments);
1889 if (!gesture)
return;
1890 select(exports.event.view).on(
"mousemove.drag", mousemoved,
true).on(
"mouseup.drag", mouseupped,
true);
1891 dragDisable(exports.event.view);
1893 mousemoving =
false;
1894 mousedownx = exports.event.clientX;
1895 mousedowny = exports.event.clientY;
1899 function mousemoved() {
1902 var dx = exports.event.clientX - mousedownx, dy = exports.event.clientY - mousedowny;
1903 mousemoving = dx * dx + dy * dy > clickDistance2;
1905 gestures.mouse(
"drag");
1908 function mouseupped() {
1909 select(exports.event.view).on(
"mousemove.drag mouseup.drag", null);
1910 yesdrag(exports.event.view, mousemoving);
1912 gestures.mouse(
"end");
1915 function touchstarted() {
1916 if (!filter.apply(
this, arguments))
return;
1917 var touches$$1 = exports.event.changedTouches,
1918 c = container.apply(
this, arguments),
1919 n = touches$$1.length, i, gesture;
1921 for (i = 0; i < n; ++i) {
1922 if (gesture = beforestart(touches$$1[i].identifier, c, touch,
this, arguments)) {
1929 function touchmoved() {
1930 var touches$$1 = exports.event.changedTouches,
1931 n = touches$$1.length, i, gesture;
1933 for (i = 0; i < n; ++i) {
1934 if (gesture = gestures[touches$$1[i].identifier]) {
1941 function touchended() {
1942 var touches$$1 = exports.event.changedTouches,
1943 n = touches$$1.length, i, gesture;
1945 if (touchending) clearTimeout(touchending);
1946 touchending = setTimeout(
function() { touchending = null; }, 500);
1947 for (i = 0; i < n; ++i) {
1948 if (gesture = gestures[touches$$1[i].identifier]) {
1955 function beforestart(
id, container, point$$1, that, args) {
1956 var p = point$$1(container, id), s, dx, dy,
1957 sublisteners = listeners.copy();
1959 if (!customEvent(
new DragEvent(drag,
"beforestart", s,
id, active, p[0], p[1], 0, 0, sublisteners),
function() {
1960 if ((exports.event.subject = s = subject.apply(that, args)) == null)
return false;
1961 dx = s.x - p[0] || 0;
1962 dy = s.y - p[1] || 0;
1966 return function gesture(type) {
1969 case "start": gestures[id] = gesture, n = active++;
break;
1970 case "end":
delete gestures[id], --active;
1971 case "drag": p = point$$1(container, id), n = active;
break;
1973 customEvent(
new DragEvent(drag, type, s,
id, n, p[0] + dx, p[1] + dy, p[0] - p0[0], p[1] - p0[1], sublisteners), sublisteners.apply, sublisteners, [type, that, args]);
1977 drag.filter =
function(_) {
1978 return arguments.length ? (filter = typeof _ ===
"function" ? _ : constant$2(!!_), drag) : filter;
1981 drag.container =
function(_) {
1982 return arguments.length ? (container = typeof _ ===
"function" ? _ : constant$2(_), drag) : container;
1985 drag.subject =
function(_) {
1986 return arguments.length ? (subject = typeof _ ===
"function" ? _ : constant$2(_), drag) : subject;
1989 drag.touchable =
function(_) {
1990 return arguments.length ? (touchable = typeof _ ===
"function" ? _ : constant$2(!!_), drag) : touchable;
1993 drag.on =
function() {
1994 var value = listeners.on.apply(listeners, arguments);
1995 return value === listeners ? drag : value;
1998 drag.clickDistance =
function(_) {
1999 return arguments.length ? (clickDistance2 = (_ = +_) * _, drag) : Math.sqrt(clickDistance2);
2005 function define(constructor, factory, prototype) {
2006 constructor.prototype = factory.prototype = prototype;
2007 prototype.constructor = constructor;
2010 function extend(parent, definition) {
2011 var prototype = Object.create(parent.prototype);
2012 for (var key in definition) prototype[key] = definition[key];
2019 var brighter = 1 / darker;
2021 var reI =
"\\s*([+-]?\\d+)\\s*",
2022 reN =
"\\s*([+-]?\\d*\\.?\\d+(?:[eE][+-]?\\d+)?)\\s*",
2023 reP =
"\\s*([+-]?\\d*\\.?\\d+(?:[eE][+-]?\\d+)?)%\\s*",
2024 reHex3 = /^#([0-9a-f]{3})$/,
2025 reHex6 = /^#([0-9a-f]{6})$/,
2026 reRgbInteger =
new RegExp(
"^rgb\\(" + [reI, reI, reI] +
"\\)$"),
2027 reRgbPercent =
new RegExp(
"^rgb\\(" + [reP, reP, reP] +
"\\)$"),
2028 reRgbaInteger =
new RegExp(
"^rgba\\(" + [reI, reI, reI, reN] +
"\\)$"),
2029 reRgbaPercent =
new RegExp(
"^rgba\\(" + [reP, reP, reP, reN] +
"\\)$"),
2030 reHslPercent =
new RegExp(
"^hsl\\(" + [reN, reP, reP] +
"\\)$"),
2031 reHslaPercent =
new RegExp(
"^hsla\\(" + [reN, reP, reP, reN] +
"\\)$");
2034 aliceblue: 0xf0f8ff,
2035 antiquewhite: 0xfaebd7,
2037 aquamarine: 0x7fffd4,
2042 blanchedalmond: 0xffebcd,
2044 blueviolet: 0x8a2be2,
2046 burlywood: 0xdeb887,
2047 cadetblue: 0x5f9ea0,
2048 chartreuse: 0x7fff00,
2049 chocolate: 0xd2691e,
2051 cornflowerblue: 0x6495ed,
2057 darkgoldenrod: 0xb8860b,
2059 darkgreen: 0x006400,
2061 darkkhaki: 0xbdb76b,
2062 darkmagenta: 0x8b008b,
2063 darkolivegreen: 0x556b2f,
2064 darkorange: 0xff8c00,
2065 darkorchid: 0x9932cc,
2067 darksalmon: 0xe9967a,
2068 darkseagreen: 0x8fbc8f,
2069 darkslateblue: 0x483d8b,
2070 darkslategray: 0x2f4f4f,
2071 darkslategrey: 0x2f4f4f,
2072 darkturquoise: 0x00ced1,
2073 darkviolet: 0x9400d3,
2075 deepskyblue: 0x00bfff,
2078 dodgerblue: 0x1e90ff,
2079 firebrick: 0xb22222,
2080 floralwhite: 0xfffaf0,
2081 forestgreen: 0x228b22,
2083 gainsboro: 0xdcdcdc,
2084 ghostwhite: 0xf8f8ff,
2086 goldenrod: 0xdaa520,
2089 greenyellow: 0xadff2f,
2093 indianred: 0xcd5c5c,
2098 lavenderblush: 0xfff0f5,
2099 lawngreen: 0x7cfc00,
2100 lemonchiffon: 0xfffacd,
2101 lightblue: 0xadd8e6,
2102 lightcoral: 0xf08080,
2103 lightcyan: 0xe0ffff,
2104 lightgoldenrodyellow: 0xfafad2,
2105 lightgray: 0xd3d3d3,
2106 lightgreen: 0x90ee90,
2107 lightgrey: 0xd3d3d3,
2108 lightpink: 0xffb6c1,
2109 lightsalmon: 0xffa07a,
2110 lightseagreen: 0x20b2aa,
2111 lightskyblue: 0x87cefa,
2112 lightslategray: 0x778899,
2113 lightslategrey: 0x778899,
2114 lightsteelblue: 0xb0c4de,
2115 lightyellow: 0xffffe0,
2117 limegreen: 0x32cd32,
2121 mediumaquamarine: 0x66cdaa,
2122 mediumblue: 0x0000cd,
2123 mediumorchid: 0xba55d3,
2124 mediumpurple: 0x9370db,
2125 mediumseagreen: 0x3cb371,
2126 mediumslateblue: 0x7b68ee,
2127 mediumspringgreen: 0x00fa9a,
2128 mediumturquoise: 0x48d1cc,
2129 mediumvioletred: 0xc71585,
2130 midnightblue: 0x191970,
2131 mintcream: 0xf5fffa,
2132 mistyrose: 0xffe4e1,
2134 navajowhite: 0xffdead,
2138 olivedrab: 0x6b8e23,
2140 orangered: 0xff4500,
2142 palegoldenrod: 0xeee8aa,
2143 palegreen: 0x98fb98,
2144 paleturquoise: 0xafeeee,
2145 palevioletred: 0xdb7093,
2146 papayawhip: 0xffefd5,
2147 peachpuff: 0xffdab9,
2151 powderblue: 0xb0e0e6,
2153 rebeccapurple: 0x663399,
2155 rosybrown: 0xbc8f8f,
2156 royalblue: 0x4169e1,
2157 saddlebrown: 0x8b4513,
2159 sandybrown: 0xf4a460,
2165 slateblue: 0x6a5acd,
2166 slategray: 0x708090,
2167 slategrey: 0x708090,
2169 springgreen: 0x00ff7f,
2170 steelblue: 0x4682b4,
2175 turquoise: 0x40e0d0,
2179 whitesmoke: 0xf5f5f5,
2181 yellowgreen: 0x9acd32
2184 define(Color, color, {
2185 displayable:
function() {
2186 return this.rgb().displayable();
2189 return this.rgb().hex();
2191 toString:
function() {
2192 return this.rgb() +
"";
2196 function color(format) {
2198 format = (format +
"").trim().toLowerCase();
2199 return (m = reHex3.exec(format)) ? (m = parseInt(m[1], 16),
new Rgb((m >> 8 & 0xf) | (m >> 4 & 0x0f0), (m >> 4 & 0xf) | (m & 0xf0), ((m & 0xf) << 4) | (m & 0xf), 1))
2200 : (m = reHex6.exec(format)) ? rgbn(parseInt(m[1], 16))
2201 : (m = reRgbInteger.exec(format)) ?
new Rgb(m[1], m[2], m[3], 1)
2202 : (m = reRgbPercent.exec(format)) ?
new Rgb(m[1] * 255 / 100, m[2] * 255 / 100, m[3] * 255 / 100, 1)
2203 : (m = reRgbaInteger.exec(format)) ? rgba(m[1], m[2], m[3], m[4])
2204 : (m = reRgbaPercent.exec(format)) ? rgba(m[1] * 255 / 100, m[2] * 255 / 100, m[3] * 255 / 100, m[4])
2205 : (m = reHslPercent.exec(format)) ? hsla(m[1], m[2] / 100, m[3] / 100, 1)
2206 : (m = reHslaPercent.exec(format)) ? hsla(m[1], m[2] / 100, m[3] / 100, m[4])
2207 : named.hasOwnProperty(format) ? rgbn(named[format])
2208 : format ===
"transparent" ? new Rgb(NaN, NaN, NaN, 0)
2213 return new Rgb(n >> 16 & 0xff, n >> 8 & 0xff, n & 0xff, 1);
2216 function rgba(r, g, b, a) {
2217 if (a <= 0) r = g = b = NaN;
2218 return new Rgb(r, g, b, a);
2221 function rgbConvert(o) {
2222 if (!(o instanceof Color)) o = color(o);
2223 if (!o)
return new Rgb;
2225 return new Rgb(o.r, o.g, o.b, o.opacity);
2228 function rgb(r, g, b, opacity) {
2229 return arguments.length === 1 ? rgbConvert(r) : new Rgb(r, g, b, opacity == null ? 1 : opacity);
2232 function Rgb(r, g, b, opacity) {
2236 this.opacity = +opacity;
2239 define(Rgb, rgb, extend(Color, {
2240 brighter:
function(k) {
2241 k = k == null ? brighter : Math.pow(brighter, k);
2242 return new Rgb(this.r * k, this.g * k, this.b * k, this.opacity);
2244 darker:
function(k) {
2245 k = k == null ? darker : Math.pow(darker, k);
2246 return new Rgb(this.r * k, this.g * k, this.b * k, this.opacity);
2251 displayable:
function() {
2252 return (0 <= this.r && this.r <= 255)
2253 && (0 <= this.g && this.g <= 255)
2254 && (0 <= this.b && this.b <= 255)
2255 && (0 <= this.opacity && this.opacity <= 1);
2258 return "#" + hex(this.r) + hex(this.g) + hex(this.b);
2260 toString:
function() {
2261 var a = this.opacity; a = isNaN(a) ? 1 : Math.max(0, Math.min(1, a));
2262 return (a === 1 ?
"rgb(" :
"rgba(")
2263 + Math.max(0, Math.min(255, Math.round(
this.r) || 0)) +
", "
2264 + Math.max(0, Math.min(255, Math.round(
this.g) || 0)) +
", "
2265 + Math.max(0, Math.min(255, Math.round(
this.b) || 0))
2266 + (a === 1 ?
")" :
", " + a +
")");
2270 function hex(value) {
2271 value = Math.max(0, Math.min(255, Math.round(value) || 0));
2272 return (value < 16 ?
"0" :
"") + value.toString(16);
2275 function hsla(h, s, l, a) {
2276 if (a <= 0) h = s = l = NaN;
2277 else if (l <= 0 || l >= 1) h = s = NaN;
2278 else if (s <= 0) h = NaN;
2279 return new Hsl(h, s, l, a);
2282 function hslConvert(o) {
2283 if (o instanceof Hsl)
return new Hsl(o.h, o.s, o.l, o.opacity);
2284 if (!(o instanceof Color)) o = color(o);
2285 if (!o)
return new Hsl;
2286 if (o instanceof Hsl)
return o;
2291 min = Math.min(r, g, b),
2292 max = Math.max(r, g, b),
2295 l = (max + min) / 2;
2297 if (r === max) h = (g - b) / s + (g < b) * 6;
2298 else if (g === max) h = (b - r) / s + 2;
2299 else h = (r - g) / s + 4;
2300 s /= l < 0.5 ? max + min : 2 - max - min;
2303 s = l > 0 && l < 1 ? 0 : h;
2305 return new Hsl(h, s, l, o.opacity);
2308 function hsl(h, s, l, opacity) {
2309 return arguments.length === 1 ? hslConvert(h) : new Hsl(h, s, l, opacity == null ? 1 : opacity);
2312 function Hsl(h, s, l, opacity) {
2316 this.opacity = +opacity;
2319 define(Hsl, hsl, extend(Color, {
2320 brighter:
function(k) {
2321 k = k == null ? brighter : Math.pow(brighter, k);
2322 return new Hsl(this.h, this.s, this.l * k, this.opacity);
2324 darker:
function(k) {
2325 k = k == null ? darker : Math.pow(darker, k);
2326 return new Hsl(this.h, this.s, this.l * k, this.opacity);
2329 var h = this.h % 360 + (this.h < 0) * 360,
2330 s = isNaN(h) || isNaN(this.s) ? 0 : this.s,
2332 m2 = l + (l < 0.5 ? l : 1 - l) * s,
2335 hsl2rgb(h >= 240 ? h - 240 : h + 120, m1, m2),
2337 hsl2rgb(h < 120 ? h + 240 : h - 120, m1, m2),
2341 displayable:
function() {
2342 return (0 <= this.s && this.s <= 1 || isNaN(this.s))
2343 && (0 <= this.l && this.l <= 1)
2344 && (0 <= this.opacity && this.opacity <= 1);
2349 function hsl2rgb(h, m1, m2) {
2350 return (h < 60 ? m1 + (m2 - m1) * h / 60
2352 : h < 240 ? m1 + (m2 - m1) * (240 - h) / 60
2356 var deg2rad = Math.PI / 180;
2357 var rad2deg = 180 / Math.PI;
2369 function labConvert(o) {
2370 if (o instanceof Lab)
return new Lab(o.l, o.a, o.b, o.opacity);
2371 if (o instanceof Hcl) {
2372 if (isNaN(o.h))
return new Lab(o.l, 0, 0, o.opacity);
2373 var h = o.h * deg2rad;
2374 return new Lab(o.l, Math.cos(h) * o.c, Math.sin(h) * o.c, o.opacity);
2376 if (!(o instanceof Rgb)) o = rgbConvert(o);
2377 var r = rgb2lrgb(o.r),
2380 y = xyz2lab((0.2225045 * r + 0.7168786 * g + 0.0606169 * b) / Yn), x, z;
2381 if (r === g && g === b) x = z = y;
else {
2382 x = xyz2lab((0.4360747 * r + 0.3850649 * g + 0.1430804 * b) / Xn);
2383 z = xyz2lab((0.0139322 * r + 0.0971045 * g + 0.7141733 * b) / Zn);
2385 return new Lab(116 * y - 16, 500 * (x - y), 200 * (y - z), o.opacity);
2388 function gray(l, opacity) {
2389 return new Lab(l, 0, 0, opacity == null ? 1 : opacity);
2392 function lab(l, a, b, opacity) {
2393 return arguments.length === 1 ? labConvert(l) : new Lab(l, a, b, opacity == null ? 1 : opacity);
2396 function Lab(l, a, b, opacity) {
2400 this.opacity = +opacity;
2403 define(Lab, lab, extend(Color, {
2404 brighter:
function(k) {
2405 return new Lab(this.l + K * (k == null ? 1 : k), this.a, this.b, this.opacity);
2407 darker:
function(k) {
2408 return new Lab(this.l - K * (k == null ? 1 : k), this.a, this.b, this.opacity);
2411 var y = (this.l + 16) / 116,
2412 x = isNaN(this.a) ? y : y + this.a / 500,
2413 z = isNaN(this.b) ? y : y - this.b / 200;
2414 x = Xn * lab2xyz(x);
2415 y = Yn * lab2xyz(y);
2416 z = Zn * lab2xyz(z);
2418 lrgb2rgb( 3.1338561 * x - 1.6168667 * y - 0.4906146 * z),
2419 lrgb2rgb(-0.9787684 * x + 1.9161415 * y + 0.0334540 * z),
2420 lrgb2rgb( 0.0719453 * x - 0.2289914 * y + 1.4052427 * z),
2426 function xyz2lab(t) {
2427 return t > t3 ? Math.pow(t, 1 / 3) : t / t2 + t0;
2430 function lab2xyz(t) {
2431 return t > t1 ? t * t * t : t2 * (t - t0);
2434 function lrgb2rgb(x) {
2435 return 255 * (x <= 0.0031308 ? 12.92 * x : 1.055 * Math.pow(x, 1 / 2.4) - 0.055);
2438 function rgb2lrgb(x) {
2439 return (x /= 255) <= 0.04045 ? x / 12.92 : Math.pow((x + 0.055) / 1.055, 2.4);
2442 function hclConvert(o) {
2443 if (o instanceof Hcl)
return new Hcl(o.h, o.c, o.l, o.opacity);
2444 if (!(o instanceof Lab)) o = labConvert(o);
2445 if (o.a === 0 && o.b === 0)
return new Hcl(NaN, 0, o.l, o.opacity);
2446 var h = Math.atan2(o.b, o.a) * rad2deg;
2447 return new Hcl(h < 0 ? h + 360 : h, Math.sqrt(o.a * o.a + o.b * o.b), o.l, o.opacity);
2450 function lch(l, c, h, opacity) {
2451 return arguments.length === 1 ? hclConvert(l) : new Hcl(h, c, l, opacity == null ? 1 : opacity);
2454 function hcl(h, c, l, opacity) {
2455 return arguments.length === 1 ? hclConvert(h) : new Hcl(h, c, l, opacity == null ? 1 : opacity);
2458 function Hcl(h, c, l, opacity) {
2462 this.opacity = +opacity;
2465 define(Hcl, hcl, extend(Color, {
2466 brighter:
function(k) {
2467 return new Hcl(this.h, this.c, this.l + K * (k == null ? 1 : k), this.opacity);
2469 darker:
function(k) {
2470 return new Hcl(this.h, this.c, this.l - K * (k == null ? 1 : k), this.opacity);
2473 return labConvert(
this).rgb();
2484 BC_DA = B * C - D * A;
2486 function cubehelixConvert(o) {
2487 if (o instanceof Cubehelix)
return new Cubehelix(o.h, o.s, o.l, o.opacity);
2488 if (!(o instanceof Rgb)) o = rgbConvert(o);
2492 l = (BC_DA * b + ED * r - EB * g) / (BC_DA + ED - EB),
2494 k = (E * (g - l) - C * bl) / D,
2495 s = Math.sqrt(k * k + bl * bl) / (E * l * (1 - l)),
2496 h = s ? Math.atan2(k, bl) * rad2deg - 120 : NaN;
2497 return new Cubehelix(h < 0 ? h + 360 : h, s, l, o.opacity);
2500 function cubehelix(h, s, l, opacity) {
2501 return arguments.length === 1 ? cubehelixConvert(h) : new Cubehelix(h, s, l, opacity == null ? 1 : opacity);
2504 function Cubehelix(h, s, l, opacity) {
2508 this.opacity = +opacity;
2511 define(Cubehelix, cubehelix, extend(Color, {
2512 brighter:
function(k) {
2513 k = k == null ? brighter : Math.pow(brighter, k);
2514 return new Cubehelix(this.h, this.s, this.l * k, this.opacity);
2516 darker:
function(k) {
2517 k = k == null ? darker : Math.pow(darker, k);
2518 return new Cubehelix(this.h, this.s, this.l * k, this.opacity);
2521 var h = isNaN(this.h) ? 0 : (this.h + 120) * deg2rad,
2523 a = isNaN(this.s) ? 0 : this.s * l * (1 - l),
2527 255 * (l + a * (A * cosh + B * sinh)),
2528 255 * (l + a * (C * cosh + D * sinh)),
2529 255 * (l + a * (E * cosh)),
2535 function basis(t1, v0, v1, v2, v3) {
2536 var t2 = t1 * t1, t3 = t2 * t1;
2537 return ((1 - 3 * t1 + 3 * t2 - t3) * v0
2538 + (4 - 6 * t2 + 3 * t3) * v1
2539 + (1 + 3 * t1 + 3 * t2 - 3 * t3) * v2
2543 function basis$1(values) {
2544 var n = values.length - 1;
2545 return function(t) {
2546 var i = t <= 0 ? (t = 0) : t >= 1 ? (t = 1, n - 1) : Math.floor(t * n),
2549 v0 = i > 0 ? values[i - 1] : 2 * v1 - v2,
2550 v3 = i < n - 1 ? values[i + 2] : 2 * v2 - v1;
2551 return basis((t - i / n) * n, v0, v1, v2, v3);
2555 function basisClosed(values) {
2556 var n = values.length;
2557 return function(t) {
2558 var i = Math.floor(((t %= 1) < 0 ? ++t : t) * n),
2559 v0 = values[(i + n - 1) % n],
2561 v2 = values[(i + 1) % n],
2562 v3 = values[(i + 2) % n];
2563 return basis((t - i / n) * n, v0, v1, v2, v3);
2567 function constant$3(x) {
2573 function linear(a, d) {
2574 return function(t) {
2579 function exponential(a, b, y) {
2580 return a = Math.pow(a, y), b = Math.pow(b, y) - a, y = 1 / y,
function(t) {
2581 return Math.pow(a + t * b, y);
2585 function hue(a, b) {
2587 return d ? linear(a, d > 180 || d < -180 ? d - 360 * Math.round(d / 360) : d) : constant$3(isNaN(a) ? b : a);
2591 return (y = +y) === 1 ? nogamma :
function(a, b) {
2592 return b - a ? exponential(a, b, y) : constant$3(isNaN(a) ? b : a);
2596 function nogamma(a, b) {
2598 return d ? linear(a, d) : constant$3(isNaN(a) ? b : a);
2601 var interpolateRgb = (
function rgbGamma(y) {
2602 var color$$1 = gamma(y);
2604 function rgb$$1(start, end) {
2605 var r = color$$1((start = rgb(start)).r, (end = rgb(end)).r),
2606 g = color$$1(start.g, end.g),
2607 b = color$$1(start.b, end.b),
2608 opacity = nogamma(start.opacity, end.opacity);
2609 return function(t) {
2613 start.opacity = opacity(t);
2618 rgb$$1.gamma = rgbGamma;
2623 function rgbSpline(spline) {
2624 return function(colors) {
2625 var n = colors.length,
2630 for (i = 0; i < n; ++i) {
2631 color$$1 = rgb(colors[i]);
2632 r[i] = color$$1.r || 0;
2633 g[i] = color$$1.g || 0;
2634 b[i] = color$$1.b || 0;
2639 color$$1.opacity = 1;
2640 return function(t) {
2644 return color$$1 +
"";
2649 var rgbBasis = rgbSpline(basis$1);
2650 var rgbBasisClosed = rgbSpline(basisClosed);
2652 function array$1(a, b) {
2653 var nb = b ? b.length : 0,
2654 na = a ? Math.min(nb, a.length) : 0,
2659 for (i = 0; i < na; ++i) x[i] = interpolateValue(a[i], b[i]);
2660 for (; i < nb; ++i) c[i] = b[i];
2662 return function(t) {
2663 for (i = 0; i < na; ++i) c[i] = x[i](t);
2668 function date(a, b) {
2670 return a = +a, b -= a,
function(t) {
2671 return d.setTime(a + b * t), d;
2675 function interpolateNumber(a, b) {
2676 return a = +a, b -= a,
function(t) {
2681 function object(a, b) {
2686 if (a === null || typeof a !==
"object") a = {};
2687 if (b === null || typeof b !==
"object") b = {};
2691 i[k] = interpolateValue(a[k], b[k]);
2697 return function(t) {
2698 for (k in i) c[k] = i[k](t);
2703 var reA = /[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,
2704 reB =
new RegExp(reA.source,
"g");
2713 return function(t) {
2718 function interpolateString(a, b) {
2719 var bi = reA.lastIndex = reB.lastIndex = 0,
2728 a = a +
"", b = b +
"";
2731 while ((am = reA.exec(a))
2732 && (bm = reB.exec(b))) {
2733 if ((bs = bm.index) > bi) {
2734 bs = b.slice(bi, bs);
2735 if (s[i]) s[i] += bs;
2738 if ((am = am[0]) === (bm = bm[0])) {
2739 if (s[i]) s[i] += bm;
2743 q.push({i: i, x: interpolateNumber(am, bm)});
2749 if (bi < b.length) {
2751 if (s[i]) s[i] += bs;
2757 return s.length < 2 ? (q[0]
2760 : (b = q.length, function(t) {
2761 for (var i = 0, o; i < b; ++i) s[(o = q[i]).i] = o.x(t);
2766 function interpolateValue(a, b) {
2767 var t = typeof b, c;
2768 return b == null || t ===
"boolean" ? constant$3(b)
2769 : (t ===
"number" ? interpolateNumber
2770 : t ===
"string" ? ((c = color(b)) ? (b = c, interpolateRgb) : interpolateString)
2771 : b instanceof color ? interpolateRgb
2772 : b instanceof Date ? date
2773 : Array.isArray(b) ? array$1
2774 : typeof b.valueOf !==
"function" && typeof b.toString !==
"function" || isNaN(b) ? object
2775 : interpolateNumber)(a, b);
2778 function discrete(range) {
2779 var n = range.length;
2780 return function(t) {
2781 return range[Math.max(0, Math.min(n - 1, Math.floor(t * n)))];
2785 function hue$1(a, b) {
2786 var i = hue(+a, +b);
2787 return function(t) {
2789 return x - 360 * Math.floor(x / 360);
2793 function interpolateRound(a, b) {
2794 return a = +a, b -= a,
function(t) {
2795 return Math.round(a + b * t);
2799 var degrees = 180 / Math.PI;
2810 function decompose(a, b, c, d, e, f) {
2811 var scaleX, scaleY, skewX;
2812 if (scaleX = Math.sqrt(a * a + b * b)) a /= scaleX, b /= scaleX;
2813 if (skewX = a * c + b * d) c -= a * skewX, d -= b * skewX;
2814 if (scaleY = Math.sqrt(c * c + d * d)) c /= scaleY, d /= scaleY, skewX /= scaleY;
2815 if (a * d < b * c) a = -a, b = -b, skewX = -skewX, scaleX = -scaleX;
2819 rotate: Math.atan2(b, a) * degrees,
2820 skewX: Math.atan(skewX) * degrees,
2831 function parseCss(value) {
2832 if (value ===
"none")
return identity$2;
2833 if (!cssNode) cssNode = document.createElement(
"DIV"), cssRoot = document.documentElement, cssView = document.defaultView;
2834 cssNode.style.transform = value;
2835 value = cssView.getComputedStyle(cssRoot.appendChild(cssNode), null).getPropertyValue(
"transform");
2836 cssRoot.removeChild(cssNode);
2837 value = value.slice(7, -1).split(
",");
2838 return decompose(+value[0], +value[1], +value[2], +value[3], +value[4], +value[5]);
2841 function parseSvg(value) {
2842 if (value == null)
return identity$2;
2843 if (!svgNode) svgNode = document.createElementNS(
"http://www.w3.org/2000/svg",
"g");
2844 svgNode.setAttribute(
"transform", value);
2845 if (!(value = svgNode.transform.baseVal.consolidate()))
return identity$2;
2846 value = value.matrix;
2847 return decompose(value.a, value.b, value.c, value.d, value.e, value.f);
2850 function interpolateTransform(parse, pxComma, pxParen, degParen) {
2853 return s.length ? s.pop() +
" " :
"";
2856 function translate(xa, ya, xb, yb, s, q) {
2857 if (xa !== xb || ya !== yb) {
2858 var i = s.push(
"translate(", null, pxComma, null, pxParen);
2859 q.push({i: i - 4, x: interpolateNumber(xa, xb)}, {i: i - 2, x: interpolateNumber(ya, yb)});
2860 }
else if (xb || yb) {
2861 s.push(
"translate(" + xb + pxComma + yb + pxParen);
2865 function rotate(a, b, s, q) {
2867 if (a - b > 180) b += 360;
else if (b - a > 180) a += 360;
2868 q.push({i: s.push(pop(s) +
"rotate(", null, degParen) - 2, x: interpolateNumber(a, b)});
2870 s.push(pop(s) +
"rotate(" + b + degParen);
2874 function skewX(a, b, s, q) {
2876 q.push({i: s.push(pop(s) +
"skewX(", null, degParen) - 2, x: interpolateNumber(a, b)});
2878 s.push(pop(s) +
"skewX(" + b + degParen);
2882 function scale(xa, ya, xb, yb, s, q) {
2883 if (xa !== xb || ya !== yb) {
2884 var i = s.push(pop(s) +
"scale(", null,
",", null,
")");
2885 q.push({i: i - 4, x: interpolateNumber(xa, xb)}, {i: i - 2, x: interpolateNumber(ya, yb)});
2886 }
else if (xb !== 1 || yb !== 1) {
2887 s.push(pop(s) +
"scale(" + xb +
"," + yb +
")");
2891 return function(a, b) {
2894 a = parse(a), b = parse(b);
2895 translate(a.translateX, a.translateY, b.translateX, b.translateY, s, q);
2896 rotate(a.rotate, b.rotate, s, q);
2897 skewX(a.skewX, b.skewX, s, q);
2898 scale(a.scaleX, a.scaleY, b.scaleX, b.scaleY, s, q);
2900 return function(t) {
2901 var i = -1, n = q.length, o;
2902 while (++i < n) s[(o = q[i]).i] = o.x(t);
2908 var interpolateTransformCss = interpolateTransform(parseCss,
"px, ",
"px)",
"deg)");
2909 var interpolateTransformSvg = interpolateTransform(parseSvg,
", ",
")",
")");
2911 var rho = Math.SQRT2,
2917 return ((x = Math.exp(x)) + 1 / x) / 2;
2921 return ((x = Math.exp(x)) - 1 / x) / 2;
2925 return ((x = Math.exp(2 * x)) - 1) / (x + 1);
2930 function interpolateZoom(p0, p1) {
2931 var ux0 = p0[0], uy0 = p0[1], w0 = p0[2],
2932 ux1 = p1[0], uy1 = p1[1], w1 = p1[2],
2935 d2 = dx * dx + dy * dy,
2940 if (d2 < epsilon2) {
2941 S = Math.log(w1 / w0) / rho;
2946 w0 * Math.exp(rho * t * S)
2953 var d1 = Math.sqrt(d2),
2954 b0 = (w1 * w1 - w0 * w0 + rho4 * d2) / (2 * w0 * rho2 * d1),
2955 b1 = (w1 * w1 - w0 * w0 - rho4 * d2) / (2 * w1 * rho2 * d1),
2956 r0 = Math.log(Math.sqrt(b0 * b0 + 1) - b0),
2957 r1 = Math.log(Math.sqrt(b1 * b1 + 1) - b1);
2958 S = (r1 - r0) / rho;
2962 u = w0 / (rho2 * d1) * (coshr0 * tanh(rho * s + r0) - sinh(r0));
2966 w0 * coshr0 / cosh(rho * s + r0)
2971 i.duration = S * 1000;
2976 function hsl$1(hue$$1) {
2977 return function(start, end) {
2978 var h = hue$$1((start = hsl(start)).h, (end = hsl(end)).h),
2979 s = nogamma(start.s, end.s),
2980 l = nogamma(start.l, end.l),
2981 opacity = nogamma(start.opacity, end.opacity);
2982 return function(t) {
2986 start.opacity = opacity(t);
2992 var hsl$2 = hsl$1(hue);
2993 var hslLong = hsl$1(nogamma);
2995 function lab$1(start, end) {
2996 var l = nogamma((start = lab(start)).l, (end = lab(end)).l),
2997 a = nogamma(start.a, end.a),
2998 b = nogamma(start.b, end.b),
2999 opacity = nogamma(start.opacity, end.opacity);
3000 return function(t) {
3004 start.opacity = opacity(t);
3009 function hcl$1(hue$$1) {
3010 return function(start, end) {
3011 var h = hue$$1((start = hcl(start)).h, (end = hcl(end)).h),
3012 c = nogamma(start.c, end.c),
3013 l = nogamma(start.l, end.l),
3014 opacity = nogamma(start.opacity, end.opacity);
3015 return function(t) {
3019 start.opacity = opacity(t);
3025 var hcl$2 = hcl$1(hue);
3026 var hclLong = hcl$1(nogamma);
3028 function cubehelix$1(hue$$1) {
3029 return (
function cubehelixGamma(y) {
3032 function cubehelix$$1(start, end) {
3033 var h = hue$$1((start = cubehelix(start)).h, (end = cubehelix(end)).h),
3034 s = nogamma(start.s, end.s),
3035 l = nogamma(start.l, end.l),
3036 opacity = nogamma(start.opacity, end.opacity);
3037 return function(t) {
3040 start.l = l(Math.pow(t, y));
3041 start.opacity = opacity(t);
3046 cubehelix$$1.gamma = cubehelixGamma;
3048 return cubehelix$$1;
3052 var cubehelix$2 = cubehelix$1(hue);
3053 var cubehelixLong = cubehelix$1(nogamma);
3055 function piecewise(interpolate, values) {
3056 var i = 0, n = values.length - 1, v = values[0], I =
new Array(n < 0 ? 0 : n);
3057 while (i < n) I[i] = interpolate(v, v = values[++i]);
3058 return function(t) {
3059 var i = Math.max(0, Math.min(n - 1, Math.floor(t *= n)));
3064 function quantize(interpolator, n) {
3065 var samples =
new Array(n);
3066 for (var i = 0; i < n; ++i) samples[i] = interpolator(i / (n - 1));
3079 clock = typeof performance ===
"object" && performance.now ? performance : Date,
3080 setFrame = typeof window ===
"object" && window.requestAnimationFrame ? window.requestAnimationFrame.bind(window) :
function(f) { setTimeout(f, 17); };
3083 return clockNow || (setFrame(clearNow), clockNow = clock.now() + clockSkew);
3086 function clearNow() {
3096 Timer.prototype = timer.prototype = {
3098 restart:
function(callback, delay, time) {
3099 if (typeof callback !==
"function")
throw new TypeError(
"callback is not a function");
3100 time = (time == null ? now() : +time) + (delay == null ? 0 : +delay);
3101 if (!this._next && taskTail !==
this) {
3102 if (taskTail) taskTail._next =
this;
3103 else taskHead =
this;
3106 this._call = callback;
3113 this._time = Infinity;
3119 function timer(callback, delay, time) {
3121 t.restart(callback, delay, time);
3125 function timerFlush() {
3128 var t = taskHead, e;
3130 if ((e = clockNow - t._time) >= 0) t._call.call(null, e);
3137 clockNow = (clockLast = clock.now()) + clockSkew;
3138 frame = timeout = 0;
3149 var now = clock.now(), delay = now - clockLast;
3150 if (delay > pokeDelay) clockSkew -= delay, clockLast = now;
3154 var t0, t1 = taskHead, t2, time = Infinity;
3157 if (time > t1._time) time = t1._time;
3158 t0 = t1, t1 = t1._next;
3160 t2 = t1._next, t1._next = null;
3161 t1 = t0 ? t0._next = t2 : taskHead = t2;
3168 function sleep(time) {
3170 if (timeout) timeout = clearTimeout(timeout);
3171 var delay = time - clockNow;
3173 if (time < Infinity) timeout = setTimeout(wake, time - clock.now() - clockSkew);
3174 if (interval) interval = clearInterval(interval);
3176 if (!interval) clockLast = clock.now(), interval = setInterval(poke, pokeDelay);
3177 frame = 1, setFrame(wake);
3181 function timeout$1(callback, delay, time) {
3183 delay = delay == null ? 0 : +delay;
3184 t.restart(
function(elapsed) {
3186 callback(elapsed + delay);
3191 function interval$1(callback, delay, time) {
3192 var t =
new Timer, total = delay;
3193 if (delay == null)
return t.restart(callback, delay, time), t;
3194 delay = +delay, time = time == null ? now() : +time;
3195 t.restart(
function tick(elapsed) {
3197 t.restart(tick, total += delay, time);
3203 var emptyOn = dispatch(
"start",
"end",
"interrupt");
3204 var emptyTween = [];
3214 function schedule(node, name,
id, index, group, timing) {
3215 var schedules = node.__transition;
3216 if (!schedules) node.__transition = {};
3217 else if (
id in schedules)
return;
3218 create$1(node, id, {
3225 delay: timing.delay,
3226 duration: timing.duration,
3233 function init(node,
id) {
3234 var schedule =
get$1(node, id);
3235 if (schedule.state > CREATED)
throw new Error(
"too late; already scheduled");
3239 function set$1(node, id) {
3240 var schedule =
get$1(node, id);
3241 if (schedule.state > STARTING)
throw new Error(
"too late; already started");
3245 function get$1(node, id) {
3246 var schedule = node.__transition;
3247 if (!schedule || !(schedule = schedule[
id]))
throw new Error(
"transition not found");
3251 function create$1(node, id,
self) {
3252 var schedules = node.__transition,
3257 schedules[id] =
self;
3258 self.timer = timer(schedule, 0,
self.time);
3260 function schedule(elapsed) {
3261 self.state = SCHEDULED;
3262 self.timer.restart(start,
self.delay,
self.time);
3265 if (
self.delay <= elapsed) start(elapsed -
self.delay);
3268 function start(elapsed) {
3272 if (
self.state !== SCHEDULED)
return stop();
3274 for (i in schedules) {
3276 if (o.name !==
self.name)
continue;
3281 if (o.state === STARTED)
return timeout$1(start);
3285 if (o.state === RUNNING) {
3288 o.on.call(
"interrupt", node, node.__data__, o.index, o.group);
3289 delete schedules[i];
3298 delete schedules[i];
3306 timeout$1(
function() {
3307 if (
self.state === STARTED) {
3308 self.state = RUNNING;
3309 self.timer.restart(tick,
self.delay,
self.time);
3316 self.state = STARTING;
3317 self.on.call(
"start", node, node.__data__,
self.index,
self.group);
3318 if (
self.state !== STARTING)
return;
3319 self.state = STARTED;
3322 tween =
new Array(n =
self.tween.length);
3323 for (i = 0, j = -1; i < n; ++i) {
3324 if (o =
self.tween[i].value.call(node, node.__data__,
self.index,
self.group)) {
3328 tween.length = j + 1;
3331 function tick(elapsed) {
3332 var t = elapsed <
self.duration ?
self.ease.call(null, elapsed /
self.duration) : (
self.timer.restart(stop),
self.state = ENDING, 1),
3337 tween[i].call(null, t);
3341 if (
self.state === ENDING) {
3342 self.on.call(
"end", node, node.__data__,
self.index,
self.group);
3350 delete schedules[id];
3351 for (var i in schedules)
return;
3352 delete node.__transition;
3356 function interrupt(node, name) {
3357 var schedules = node.__transition,
3363 if (!schedules)
return;
3365 name = name == null ? null : name +
"";
3367 for (i in schedules) {
3368 if ((schedule$$1 = schedules[i]).name !== name) { empty =
false;
continue; }
3369 active = schedule$$1.state > STARTING && schedule$$1.state < ENDING;
3370 schedule$$1.state = ENDED;
3371 schedule$$1.timer.stop();
3372 if (active) schedule$$1.on.call(
"interrupt", node, node.__data__, schedule$$1.index, schedule$$1.group);
3373 delete schedules[i];
3376 if (empty)
delete node.__transition;
3379 function selection_interrupt(name) {
3380 return this.each(
function() {
3381 interrupt(
this, name);
3385 function tweenRemove(
id, name) {
3388 var schedule$$1 = set$1(
this, id),
3389 tween = schedule$$1.tween;
3394 if (tween !== tween0) {
3395 tween1 = tween0 = tween;
3396 for (var i = 0, n = tween1.length; i < n; ++i) {
3397 if (tween1[i].name === name) {
3398 tween1 = tween1.slice();
3399 tween1.splice(i, 1);
3405 schedule$$1.tween = tween1;
3409 function tweenFunction(
id, name, value) {
3411 if (typeof value !==
"function")
throw new Error;
3413 var schedule$$1 = set$1(
this, id),
3414 tween = schedule$$1.tween;
3419 if (tween !== tween0) {
3420 tween1 = (tween0 = tween).slice();
3421 for (var t = {name: name, value: value}, i = 0, n = tween1.length; i < n; ++i) {
3422 if (tween1[i].name === name) {
3427 if (i === n) tween1.push(t);
3430 schedule$$1.tween = tween1;
3434 function transition_tween(name, value) {
3439 if (arguments.length < 2) {
3440 var tween =
get$1(this.node(), id).tween;
3441 for (var i = 0, n = tween.length, t; i < n; ++i) {
3442 if ((t = tween[i]).name === name) {
3449 return this.each((value == null ? tweenRemove : tweenFunction)(
id, name, value));
3452 function tweenValue(transition, name, value) {
3453 var
id = transition._id;
3455 transition.each(
function() {
3456 var schedule$$1 = set$1(
this, id);
3457 (schedule$$1.value || (schedule$$1.value = {}))[name] = value.apply(
this, arguments);
3460 return function(node) {
3461 return get$1(node, id).value[name];
3465 function interpolate(a, b) {
3467 return (typeof b ===
"number" ? interpolateNumber
3468 : b instanceof color ? interpolateRgb
3469 : (c = color(b)) ? (b = c, interpolateRgb)
3470 : interpolateString)(a, b);
3473 function attrRemove$1(name) {
3475 this.removeAttribute(name);
3479 function attrRemoveNS$1(fullname) {
3481 this.removeAttributeNS(fullname.space, fullname.local);
3485 function attrConstant$1(name, interpolate$$1, value1) {
3489 var value0 = this.getAttribute(name);
3490 return value0 === value1 ? null
3491 : value0 === value00 ? interpolate0
3492 : interpolate0 = interpolate$$1(value00 = value0, value1);
3496 function attrConstantNS$1(fullname, interpolate$$1, value1) {
3500 var value0 = this.getAttributeNS(fullname.space, fullname.local);
3501 return value0 === value1 ? null
3502 : value0 === value00 ? interpolate0
3503 : interpolate0 = interpolate$$1(value00 = value0, value1);
3507 function attrFunction$1(name, interpolate$$1, value) {
3512 var value0, value1 = value(
this);
3513 if (value1 == null)
return void this.removeAttribute(name);
3514 value0 = this.getAttribute(name);
3515 return value0 === value1 ? null
3516 : value0 === value00 && value1 === value10 ? interpolate0
3517 : interpolate0 = interpolate$$1(value00 = value0, value10 = value1);
3521 function attrFunctionNS$1(fullname, interpolate$$1, value) {
3526 var value0, value1 = value(
this);
3527 if (value1 == null)
return void this.removeAttributeNS(fullname.space, fullname.local);
3528 value0 = this.getAttributeNS(fullname.space, fullname.local);
3529 return value0 === value1 ? null
3530 : value0 === value00 && value1 === value10 ? interpolate0
3531 : interpolate0 = interpolate$$1(value00 = value0, value10 = value1);
3535 function transition_attr(name, value) {
3536 var fullname =
namespace(name), i = fullname ===
"transform" ? interpolateTransformSvg : interpolate;
3537 return this.attrTween(name, typeof value ===
"function"
3538 ? (fullname.local ? attrFunctionNS$1 : attrFunction$1)(fullname, i, tweenValue(
this,
"attr." + name, value))
3539 : value == null ? (fullname.local ? attrRemoveNS$1 : attrRemove$1)(fullname)
3540 : (fullname.local ? attrConstantNS$1 : attrConstant$1)(fullname, i, value +
""));
3543 function attrTweenNS(fullname, value) {
3545 var node =
this, i = value.apply(node, arguments);
3546 return i &&
function(t) {
3547 node.setAttributeNS(fullname.space, fullname.local, i(t));
3550 tween._value = value;
3554 function attrTween(name, value) {
3556 var node =
this, i = value.apply(node, arguments);
3557 return i &&
function(t) {
3558 node.setAttribute(name, i(t));
3561 tween._value = value;
3565 function transition_attrTween(name, value) {
3566 var key =
"attr." + name;
3567 if (arguments.length < 2)
return (key = this.tween(key)) && key._value;
3568 if (value == null)
return this.tween(key, null);
3569 if (typeof value !==
"function")
throw new Error;
3570 var fullname =
namespace(name);
3571 return this.tween(key, (fullname.local ? attrTweenNS : attrTween)(fullname, value));
3574 function delayFunction(
id, value) {
3576 init(
this,
id).delay = +value.apply(
this, arguments);
3580 function delayConstant(
id, value) {
3581 return value = +value,
function() {
3582 init(
this,
id).delay = value;
3586 function transition_delay(value) {
3589 return arguments.length
3590 ? this.each((typeof value ===
"function"
3592 : delayConstant)(
id, value))
3593 : get$1(this.node(), id).delay;
3596 function durationFunction(
id, value) {
3598 set$1(
this, id).duration = +value.apply(
this, arguments);
3602 function durationConstant(
id, value) {
3603 return value = +value,
function() {
3604 set$1(
this, id).duration = value;
3608 function transition_duration(value) {
3611 return arguments.length
3612 ? this.each((typeof value ===
"function"
3614 : durationConstant)(
id, value))
3615 : get$1(this.node(), id).duration;
3618 function easeConstant(
id, value) {
3619 if (typeof value !==
"function")
throw new Error;
3621 set$1(
this, id).ease = value;
3625 function transition_ease(value) {
3628 return arguments.length
3629 ? this.each(easeConstant(
id, value))
3630 : get$1(this.node(), id).ease;
3633 function transition_filter(match) {
3634 if (typeof match !==
"function") match = matcher$1(match);
3636 for (var groups = this._groups, m = groups.length, subgroups =
new Array(m), j = 0; j < m; ++j) {
3637 for (var group = groups[j], n = group.length, subgroup = subgroups[j] = [], node, i = 0; i < n; ++i) {
3638 if ((node = group[i]) && match.call(node, node.__data__, i, group)) {
3639 subgroup.push(node);
3644 return new Transition(subgroups, this._parents, this._name, this._id);
3647 function transition_merge(transition$$1) {
3648 if (transition$$1._id !== this._id)
throw new Error;
3650 for (var groups0 = this._groups, groups1 = transition$$1._groups, m0 = groups0.length, m1 = groups1.length, m = Math.min(m0, m1), merges =
new Array(m0), j = 0; j < m; ++j) {
3651 for (var group0 = groups0[j], group1 = groups1[j], n = group0.length, merge = merges[j] =
new Array(n), node, i = 0; i < n; ++i) {
3652 if (node = group0[i] || group1[i]) {
3658 for (; j < m0; ++j) {
3659 merges[j] = groups0[j];
3662 return new Transition(merges, this._parents, this._name, this._id);
3665 function start(name) {
3666 return (name +
"").trim().split(/^|\s+/).every(
function(t) {
3667 var i = t.indexOf(
".");
3668 if (i >= 0) t = t.slice(0, i);
3669 return !t || t ===
"start";
3673 function onFunction(
id, name, listener) {
3674 var on0, on1, sit = start(name) ? init : set$1;
3676 var schedule$$1 = sit(
this,
id),
3677 on = schedule$$1.on;
3682 if (on !== on0) (on1 = (on0 = on).copy()).on(name, listener);
3684 schedule$$1.on = on1;
3688 function transition_on(name, listener) {
3691 return arguments.length < 2
3692 ?
get$1(this.node(), id).on.on(name)
3693 : this.each(onFunction(
id, name, listener));
3696 function removeFunction(
id) {
3698 var parent = this.parentNode;
3699 for (var i in this.__transition)
if (+i !==
id)
return;
3700 if (parent) parent.removeChild(
this);
3704 function transition_remove() {
3705 return this.on(
"end.remove", removeFunction(this._id));
3708 function transition_select(select$$1) {
3709 var name = this._name,
3712 if (typeof select$$1 !==
"function") select$$1 = selector(select$$1);
3714 for (var groups = this._groups, m = groups.length, subgroups =
new Array(m), j = 0; j < m; ++j) {
3715 for (var group = groups[j], n = group.length, subgroup = subgroups[j] =
new Array(n), node, subnode, i = 0; i < n; ++i) {
3716 if ((node = group[i]) && (subnode = select$$1.call(node, node.__data__, i, group))) {
3717 if (
"__data__" in node) subnode.__data__ = node.__data__;
3718 subgroup[i] = subnode;
3719 schedule(subgroup[i], name,
id, i, subgroup,
get$1(node,
id));
3724 return new Transition(subgroups, this._parents, name,
id);
3727 function transition_selectAll(select$$1) {
3728 var name = this._name,
3731 if (typeof select$$1 !==
"function") select$$1 = selectorAll(select$$1);
3733 for (var groups = this._groups, m = groups.length, subgroups = [], parents = [], j = 0; j < m; ++j) {
3734 for (var group = groups[j], n = group.length, node, i = 0; i < n; ++i) {
3735 if (node = group[i]) {
3736 for (var children = select$$1.call(node, node.__data__, i, group), child, inherit =
get$1(node,
id), k = 0, l = children.length; k < l; ++k) {
3737 if (child = children[k]) {
3738 schedule(child, name,
id, k, children, inherit);
3741 subgroups.push(children);
3747 return new Transition(subgroups, parents, name,
id);
3750 var Selection$1 = selection.prototype.constructor;
3752 function transition_selection() {
3753 return new Selection$1(this._groups, this._parents);
3756 function styleRemove$1(name, interpolate$$1) {
3761 var value0 = styleValue(
this, name),
3762 value1 = (this.style.removeProperty(name), styleValue(
this, name));
3763 return value0 === value1 ? null
3764 : value0 === value00 && value1 === value10 ? interpolate0
3765 : interpolate0 = interpolate$$1(value00 = value0, value10 = value1);
3769 function styleRemoveEnd(name) {
3771 this.style.removeProperty(name);
3775 function styleConstant$1(name, interpolate$$1, value1) {
3779 var value0 = styleValue(
this, name);
3780 return value0 === value1 ? null
3781 : value0 === value00 ? interpolate0
3782 : interpolate0 = interpolate$$1(value00 = value0, value1);
3786 function styleFunction$1(name, interpolate$$1, value) {
3791 var value0 = styleValue(
this, name),
3792 value1 = value(
this);
3793 if (value1 == null) value1 = (this.style.removeProperty(name), styleValue(
this, name));
3794 return value0 === value1 ? null
3795 : value0 === value00 && value1 === value10 ? interpolate0
3796 : interpolate0 = interpolate$$1(value00 = value0, value10 = value1);
3800 function transition_style(name, value, priority) {
3801 var i = (name +=
"") ===
"transform" ? interpolateTransformCss : interpolate;
3802 return value == null ?
this
3803 .styleTween(name, styleRemove$1(name, i))
3804 .on(
"end.style." + name, styleRemoveEnd(name))
3805 : this.styleTween(name, typeof value ===
"function"
3806 ? styleFunction$1(name, i, tweenValue(
this,
"style." + name, value))
3807 : styleConstant$1(name, i, value +
""), priority);
3810 function styleTween(name, value, priority) {
3812 var node =
this, i = value.apply(node, arguments);
3813 return i &&
function(t) {
3814 node.style.setProperty(name, i(t), priority);
3817 tween._value = value;
3821 function transition_styleTween(name, value, priority) {
3822 var key =
"style." + (name +=
"");
3823 if (arguments.length < 2)
return (key = this.tween(key)) && key._value;
3824 if (value == null)
return this.tween(key, null);
3825 if (typeof value !==
"function")
throw new Error;
3826 return this.tween(key, styleTween(name, value, priority == null ?
"" : priority));
3829 function textConstant$1(value) {
3831 this.textContent = value;
3835 function textFunction$1(value) {
3837 var value1 = value(
this);
3838 this.textContent = value1 == null ?
"" : value1;
3842 function transition_text(value) {
3843 return this.tween(
"text", typeof value ===
"function"
3844 ? textFunction$1(tweenValue(
this,
"text", value))
3845 : textConstant$1(value == null ?
"" : value +
""));
3848 function transition_transition() {
3849 var name = this._name,
3853 for (var groups = this._groups, m = groups.length, j = 0; j < m; ++j) {
3854 for (var group = groups[j], n = group.length, node, i = 0; i < n; ++i) {
3855 if (node = group[i]) {
3856 var inherit =
get$1(node, id0);
3857 schedule(node, name, id1, i, group, {
3858 time: inherit.time + inherit.delay + inherit.duration,
3860 duration: inherit.duration,
3867 return new Transition(groups, this._parents, name, id1);
3872 function Transition(groups, parents, name,
id) {
3873 this._groups = groups;
3874 this._parents = parents;
3879 function transition(name) {
3880 return selection().transition(name);
3887 var selection_prototype = selection.prototype;
3889 Transition.prototype = transition.prototype = {
3890 constructor: Transition,
3891 select: transition_select,
3892 selectAll: transition_selectAll,
3893 filter: transition_filter,
3894 merge: transition_merge,
3895 selection: transition_selection,
3896 transition: transition_transition,
3897 call: selection_prototype.call,
3898 nodes: selection_prototype.nodes,
3899 node: selection_prototype.node,
3900 size: selection_prototype.size,
3901 empty: selection_prototype.empty,
3902 each: selection_prototype.each,
3904 attr: transition_attr,
3905 attrTween: transition_attrTween,
3906 style: transition_style,
3907 styleTween: transition_styleTween,
3908 text: transition_text,
3909 remove: transition_remove,
3910 tween: transition_tween,
3911 delay: transition_delay,
3912 duration: transition_duration,
3913 ease: transition_ease
3916 function linear$1(t) {
3920 function quadIn(t) {
3924 function quadOut(t) {
3928 function quadInOut(t) {
3929 return ((t *= 2) <= 1 ? t * t : --t * (2 - t) + 1) / 2;
3932 function cubicIn(t) {
3936 function cubicOut(t) {
3937 return --t * t * t + 1;
3940 function cubicInOut(t) {
3941 return ((t *= 2) <= 1 ? t * t * t : (t -= 2) * t * t + 2) / 2;
3946 var polyIn = (
function custom(e) {
3949 function polyIn(t) {
3950 return Math.pow(t, e);
3953 polyIn.exponent = custom;
3958 var polyOut = (
function custom(e) {
3961 function polyOut(t) {
3962 return 1 - Math.pow(1 - t, e);
3965 polyOut.exponent = custom;
3970 var polyInOut = (
function custom(e) {
3973 function polyInOut(t) {
3974 return ((t *= 2) <= 1 ? Math.pow(t, e) : 2 - Math.pow(2 - t, e)) / 2;
3977 polyInOut.exponent = custom;
3986 return 1 - Math.cos(t * halfPi);
3989 function sinOut(t) {
3990 return Math.sin(t * halfPi);
3993 function sinInOut(t) {
3994 return (1 - Math.cos(pi * t)) / 2;
3998 return Math.pow(2, 10 * t - 10);
4001 function expOut(t) {
4002 return 1 - Math.pow(2, -10 * t);
4005 function expInOut(t) {
4006 return ((t *= 2) <= 1 ? Math.pow(2, 10 * t - 10) : 2 - Math.pow(2, 10 - 10 * t)) / 2;
4009 function circleIn(t) {
4010 return 1 - Math.sqrt(1 - t * t);
4013 function circleOut(t) {
4014 return Math.sqrt(1 - --t * t);
4017 function circleInOut(t) {
4018 return ((t *= 2) <= 1 ? 1 - Math.sqrt(1 - t * t) : Math.sqrt(1 - (t -= 2) * t) + 1) / 2;
4032 function bounceIn(t) {
4033 return 1 - bounceOut(1 - t);
4036 function bounceOut(t) {
4037 return (t = +t) < b1 ? b0 * t * t : t < b3 ? b0 * (t -= b2) * t + b4 : t < b6 ? b0 * (t -= b5) * t + b7 : b0 * (t -= b8) * t + b9;
4040 function bounceInOut(t) {
4041 return ((t *= 2) <= 1 ? 1 - bounceOut(1 - t) : bounceOut(t - 1) + 1) / 2;
4044 var overshoot = 1.70158;
4046 var backIn = (
function custom(s) {
4049 function backIn(t) {
4050 return t * t * ((s + 1) * t - s);
4053 backIn.overshoot = custom;
4058 var backOut = (
function custom(s) {
4061 function backOut(t) {
4062 return --t * t * ((s + 1) * t + s) + 1;
4065 backOut.overshoot = custom;
4070 var backInOut = (
function custom(s) {
4073 function backInOut(t) {
4074 return ((t *= 2) < 1 ? t * t * ((s + 1) * t - s) : (t -= 2) * t * ((s + 1) * t + s) + 2) / 2;
4077 backInOut.overshoot = custom;
4082 var tau = 2 * Math.PI,
4086 var elasticIn = (
function custom(a, p) {
4087 var s = Math.asin(1 / (a = Math.max(1, a))) * (p /= tau);
4089 function elasticIn(t) {
4090 return a * Math.pow(2, 10 * --t) * Math.sin((s - t) / p);
4093 elasticIn.amplitude =
function(a) {
return custom(a, p * tau); };
4094 elasticIn.period =
function(p) {
return custom(a, p); };
4097 })(amplitude, period);
4099 var elasticOut = (
function custom(a, p) {
4100 var s = Math.asin(1 / (a = Math.max(1, a))) * (p /= tau);
4102 function elasticOut(t) {
4103 return 1 - a * Math.pow(2, -10 * (t = +t)) * Math.sin((t + s) / p);
4106 elasticOut.amplitude =
function(a) {
return custom(a, p * tau); };
4107 elasticOut.period =
function(p) {
return custom(a, p); };
4110 })(amplitude, period);
4112 var elasticInOut = (
function custom(a, p) {
4113 var s = Math.asin(1 / (a = Math.max(1, a))) * (p /= tau);
4115 function elasticInOut(t) {
4116 return ((t = t * 2 - 1) < 0
4117 ? a * Math.pow(2, 10 * t) * Math.sin((s - t) / p)
4118 : 2 - a * Math.pow(2, -10 * t) * Math.sin((s + t) / p)) / 2;
4121 elasticInOut.amplitude =
function(a) {
return custom(a, p * tau); };
4122 elasticInOut.period =
function(p) {
return custom(a, p); };
4124 return elasticInOut;
4125 })(amplitude, period);
4127 var defaultTiming = {
4134 function inherit(node,
id) {
4136 while (!(timing = node.__transition) || !(timing = timing[
id])) {
4137 if (!(node = node.parentNode)) {
4138 return defaultTiming.time = now(), defaultTiming;
4144 function selection_transition(name) {
4148 if (name instanceof Transition) {
4149 id = name._id, name = name._name;
4151 id = newId(), (timing = defaultTiming).time = now(), name = name == null ? null : name +
"";
4154 for (var groups = this._groups, m = groups.length, j = 0; j < m; ++j) {
4155 for (var group = groups[j], n = group.length, node, i = 0; i < n; ++i) {
4156 if (node = group[i]) {
4157 schedule(node, name,
id, i, group, timing || inherit(node,
id));
4162 return new Transition(groups, this._parents, name,
id);
4165 selection.prototype.interrupt = selection_interrupt;
4166 selection.prototype.transition = selection_transition;
4168 var root$1 = [null];
4170 function active(node, name) {
4171 var schedules = node.__transition,
4176 name = name == null ? null : name +
"";
4177 for (i in schedules) {
4178 if ((schedule$$1 = schedules[i]).state > SCHEDULED && schedule$$1.name === name) {
4179 return new Transition([[node]], root$1, name, +i);
4187 function constant$4(x) {
4193 function BrushEvent(target, type, selection) {
4194 this.target = target;
4196 this.selection = selection;
4199 function nopropagation$1() {
4200 exports.event.stopImmediatePropagation();
4203 function noevent$1() {
4204 exports.event.preventDefault();
4205 exports.event.stopImmediatePropagation();
4208 var MODE_DRAG = {name:
"drag"},
4209 MODE_SPACE = {name:
"space"},
4210 MODE_HANDLE = {name:
"handle"},
4211 MODE_CENTER = {name:
"center"};
4215 handles: [
"e",
"w"].map(type),
4216 input:
function(x, e) {
return x && [[x[0], e[0][1]], [x[1], e[1][1]]]; },
4217 output:
function(xy) {
return xy && [xy[0][0], xy[1][0]]; }
4222 handles: [
"n",
"s"].map(type),
4223 input:
function(y, e) {
return y && [[e[0][0], y[0]], [e[1][0], y[1]]]; },
4224 output:
function(xy) {
return xy && [xy[0][1], xy[1][1]]; }
4229 handles: [
"n",
"e",
"s",
"w",
"nw",
"ne",
"se",
"sw"].map(type),
4230 input:
function(xy) {
return xy; },
4231 output:
function(xy) {
return xy; }
4235 overlay:
"crosshair",
4296 function defaultFilter$1() {
4297 return !exports.event.button;
4300 function defaultExtent() {
4301 var svg = this.ownerSVGElement ||
this;
4302 return [[0, 0], [svg.width.baseVal.value, svg.height.baseVal.value]];
4306 function local$1(node) {
4307 while (!node.__brush)
if (!(node = node.parentNode))
return;
4308 return node.__brush;
4311 function empty$1(extent) {
4312 return extent[0][0] === extent[1][0]
4313 || extent[0][1] === extent[1][1];
4316 function brushSelection(node) {
4317 var state = node.__brush;
4318 return state ? state.dim.output(state.selection) : null;
4333 function brush$1(dim) {
4334 var extent = defaultExtent,
4335 filter = defaultFilter$1,
4336 listeners = dispatch(brush,
"start",
"brush",
"end"),
4340 function brush(group) {
4342 .property(
"__brush", initialize)
4343 .selectAll(
".overlay")
4344 .data([type(
"overlay")]);
4346 overlay.enter().append(
"rect")
4347 .attr(
"class",
"overlay")
4348 .attr(
"pointer-events",
"all")
4349 .attr(
"cursor", cursors.overlay)
4352 var extent = local$1(
this).extent;
4354 .attr(
"x", extent[0][0])
4355 .attr(
"y", extent[0][1])
4356 .attr(
"width", extent[1][0] - extent[0][0])
4357 .attr(
"height", extent[1][1] - extent[0][1]);
4360 group.selectAll(
".selection")
4361 .data([type(
"selection")])
4362 .enter().append(
"rect")
4363 .attr(
"class",
"selection")
4364 .attr(
"cursor", cursors.selection)
4365 .attr(
"fill",
"#777")
4366 .attr(
"fill-opacity", 0.3)
4367 .attr(
"stroke",
"#fff")
4368 .attr(
"shape-rendering",
"crispEdges");
4370 var handle = group.selectAll(
".handle")
4371 .data(dim.handles,
function(d) {
return d.type; });
4373 handle.exit().remove();
4375 handle.enter().append(
"rect")
4376 .attr(
"class",
function(d) {
return "handle handle--" + d.type; })
4377 .attr(
"cursor",
function(d) {
return cursors[d.type]; });
4381 .attr(
"fill",
"none")
4382 .attr(
"pointer-events",
"all")
4383 .style(
"-webkit-tap-highlight-color",
"rgba(0,0,0,0)")
4384 .on(
"mousedown.brush touchstart.brush", started);
4387 brush.move =
function(group, selection$$1) {
4388 if (group.selection) {
4390 .on(
"start.brush",
function() { emitter(
this, arguments).beforestart().start(); })
4391 .on(
"interrupt.brush end.brush",
function() { emitter(
this, arguments).end(); })
4392 .tween(
"brush",
function() {
4394 state = that.__brush,
4395 emit = emitter(that, arguments),
4396 selection0 = state.selection,
4397 selection1 = dim.input(typeof selection$$1 ===
"function" ? selection$$1.apply(
this, arguments) : selection$$1, state.extent),
4398 i = interpolateValue(selection0, selection1);
4401 state.selection = t === 1 && empty$1(selection1) ? null : i(t);
4406 return selection0 && selection1 ? tween : tween(1);
4413 state = that.__brush,
4414 selection1 = dim.input(typeof selection$$1 ===
"function" ? selection$$1.apply(that, args) : selection$$1, state.extent),
4415 emit = emitter(that, args).beforestart();
4418 state.selection = selection1 == null || empty$1(selection1) ? null : selection1;
4420 emit.start().brush().end();
4426 var group = select(
this),
4427 selection$$1 = local$1(
this).selection;
4430 group.selectAll(
".selection")
4431 .style(
"display", null)
4432 .attr(
"x", selection$$1[0][0])
4433 .attr(
"y", selection$$1[0][1])
4434 .attr(
"width", selection$$1[1][0] - selection$$1[0][0])
4435 .attr(
"height", selection$$1[1][1] - selection$$1[0][1]);
4437 group.selectAll(
".handle")
4438 .style(
"display", null)
4439 .attr(
"x",
function(d) {
return d.type[d.type.length - 1] ===
"e" ? selection$$1[1][0] - handleSize / 2 : selection$$1[0][0] - handleSize / 2; })
4440 .attr(
"y",
function(d) {
return d.type[0] ===
"s" ? selection$$1[1][1] - handleSize / 2 : selection$$1[0][1] - handleSize / 2; })
4441 .attr(
"width",
function(d) {
return d.type ===
"n" || d.type ===
"s" ? selection$$1[1][0] - selection$$1[0][0] + handleSize : handleSize; })
4442 .attr(
"height",
function(d) {
return d.type ===
"e" || d.type ===
"w" ? selection$$1[1][1] - selection$$1[0][1] + handleSize : handleSize; });
4446 group.selectAll(
".selection,.handle")
4447 .style(
"display",
"none")
4450 .attr(
"width", null)
4451 .attr(
"height", null);
4455 function emitter(that, args) {
4456 return that.__brush.emitter ||
new Emitter(that, args);
4459 function Emitter(that, args) {
4462 this.state = that.__brush;
4466 Emitter.prototype = {
4467 beforestart:
function() {
4468 if (++this.active === 1) this.state.emitter =
this, this.starting =
true;
4472 if (this.starting) this.starting =
false, this.emit(
"start");
4480 if (--this.active === 0)
delete this.state.emitter, this.emit(
"end");
4483 emit:
function(type) {
4484 customEvent(
new BrushEvent(brush, type, dim.output(
this.state.selection)), listeners.apply, listeners, [type,
this.that,
this.args]);
4488 function started() {
4489 if (exports.event.touches) {
if (exports.event.changedTouches.length < exports.event.touches.length)
return noevent$1(); }
4490 else if (touchending)
return;
4491 if (!filter.apply(
this, arguments))
return;
4494 type = exports.event.target.__data__.type,
4495 mode = (exports.event.metaKey ? type =
"overlay" : type) ===
"selection" ? MODE_DRAG : (exports.event.altKey ? MODE_CENTER : MODE_HANDLE),
4496 signX = dim === Y ? null : signsX[type],
4497 signY = dim === X ? null : signsY[type],
4498 state = local$1(that),
4499 extent = state.extent,
4500 selection$$1 = state.selection,
4501 W = extent[0][0], w0, w1,
4502 N = extent[0][1], n0, n1,
4503 E = extent[1][0], e0, e1,
4504 S = extent[1][1], s0, s1,
4508 shifting = signX && signY && exports.event.shiftKey,
4511 point0 = mouse(that),
4513 emit = emitter(that, arguments).beforestart();
4515 if (type ===
"overlay") {
4516 state.selection = selection$$1 = [
4517 [w0 = dim === Y ? W : point0[0], n0 = dim === X ? N : point0[1]],
4518 [e0 = dim === Y ? E : w0, s0 = dim === X ? S : n0]
4521 w0 = selection$$1[0][0];
4522 n0 = selection$$1[0][1];
4523 e0 = selection$$1[1][0];
4524 s0 = selection$$1[1][1];
4532 var group = select(that)
4533 .attr(
"pointer-events",
"none");
4535 var overlay = group.selectAll(
".overlay")
4536 .attr(
"cursor", cursors[type]);
4538 if (exports.event.touches) {
4540 .on(
"touchmove.brush", moved,
true)
4541 .on(
"touchend.brush touchcancel.brush", ended,
true);
4543 var view = select(exports.event.view)
4544 .on(
"keydown.brush", keydowned,
true)
4545 .on(
"keyup.brush", keyupped,
true)
4546 .on(
"mousemove.brush", moved,
true)
4547 .on(
"mouseup.brush", ended,
true);
4549 dragDisable(exports.event.view);
4558 var point1 = mouse(that);
4559 if (shifting && !lockX && !lockY) {
4560 if (Math.abs(point1[0] - point$$1[0]) > Math.abs(point1[1] - point$$1[1])) lockY =
true;
4572 dx = point$$1[0] - point0[0];
4573 dy = point$$1[1] - point0[1];
4578 if (signX) dx = Math.max(W - w0, Math.min(E - e0, dx)), w1 = w0 + dx, e1 = e0 + dx;
4579 if (signY) dy = Math.max(N - n0, Math.min(S - s0, dy)), n1 = n0 + dy, s1 = s0 + dy;
4583 if (signX < 0) dx = Math.max(W - w0, Math.min(E - w0, dx)), w1 = w0 + dx, e1 = e0;
4584 else if (signX > 0) dx = Math.max(W - e0, Math.min(E - e0, dx)), w1 = w0, e1 = e0 + dx;
4585 if (signY < 0) dy = Math.max(N - n0, Math.min(S - n0, dy)), n1 = n0 + dy, s1 = s0;
4586 else if (signY > 0) dy = Math.max(N - s0, Math.min(S - s0, dy)), n1 = n0, s1 = s0 + dy;
4590 if (signX) w1 = Math.max(W, Math.min(E, w0 - dx * signX)), e1 = Math.max(W, Math.min(E, e0 + dx * signX));
4591 if (signY) n1 = Math.max(N, Math.min(S, n0 - dy * signY)), s1 = Math.max(N, Math.min(S, s0 + dy * signY));
4598 t = w0, w0 = e0, e0 = t;
4599 t = w1, w1 = e1, e1 = t;
4600 if (type in flipX) overlay.attr(
"cursor", cursors[type = flipX[type]]);
4605 t = n0, n0 = s0, s0 = t;
4606 t = n1, n1 = s1, s1 = t;
4607 if (type in flipY) overlay.attr(
"cursor", cursors[type = flipY[type]]);
4610 if (state.selection) selection$$1 = state.selection;
4611 if (lockX) w1 = selection$$1[0][0], e1 = selection$$1[1][0];
4612 if (lockY) n1 = selection$$1[0][1], s1 = selection$$1[1][1];
4614 if (selection$$1[0][0] !== w1
4615 || selection$$1[0][1] !== n1
4616 || selection$$1[1][0] !== e1
4617 || selection$$1[1][1] !== s1) {
4618 state.selection = [[w1, n1], [e1, s1]];
4626 if (exports.event.touches) {
4627 if (exports.event.touches.length)
return;
4628 if (touchending) clearTimeout(touchending);
4629 touchending = setTimeout(
function() { touchending = null; }, 500);
4630 group.on(
"touchmove.brush touchend.brush touchcancel.brush", null);
4632 yesdrag(exports.event.view, moving);
4633 view.on(
"keydown.brush keyup.brush mousemove.brush mouseup.brush", null);
4635 group.attr(
"pointer-events",
"all");
4636 overlay.attr(
"cursor", cursors.overlay);
4637 if (state.selection) selection$$1 = state.selection;
4638 if (empty$1(selection$$1)) state.selection = null, redraw.call(that);
4642 function keydowned() {
4643 switch (exports.event.keyCode) {
4645 shifting = signX && signY;
4649 if (mode === MODE_HANDLE) {
4650 if (signX) e0 = e1 - dx * signX, w0 = w1 + dx * signX;
4651 if (signY) s0 = s1 - dy * signY, n0 = n1 + dy * signY;
4658 if (mode === MODE_HANDLE || mode === MODE_CENTER) {
4659 if (signX < 0) e0 = e1 - dx;
else if (signX > 0) w0 = w1 - dx;
4660 if (signY < 0) s0 = s1 - dy;
else if (signY > 0) n0 = n1 - dy;
4662 overlay.attr(
"cursor", cursors.selection);
4672 function keyupped() {
4673 switch (exports.event.keyCode) {
4676 lockX = lockY = shifting =
false;
4682 if (mode === MODE_CENTER) {
4683 if (signX < 0) e0 = e1;
else if (signX > 0) w0 = w1;
4684 if (signY < 0) s0 = s1;
else if (signY > 0) n0 = n1;
4691 if (mode === MODE_SPACE) {
4692 if (exports.event.altKey) {
4693 if (signX) e0 = e1 - dx * signX, w0 = w1 + dx * signX;
4694 if (signY) s0 = s1 - dy * signY, n0 = n1 + dy * signY;
4697 if (signX < 0) e0 = e1;
else if (signX > 0) w0 = w1;
4698 if (signY < 0) s0 = s1;
else if (signY > 0) n0 = n1;
4701 overlay.attr(
"cursor", cursors[type]);
4712 function initialize() {
4713 var state = this.__brush || {selection: null};
4714 state.extent = extent.apply(
this, arguments);
4719 brush.extent =
function(_) {
4720 return arguments.length ? (extent = typeof _ ===
"function" ? _ : constant$4([[+_[0][0], +_[0][1]], [+_[1][0], +_[1][1]]]), brush) : extent;
4723 brush.filter =
function(_) {
4724 return arguments.length ? (filter = typeof _ ===
"function" ? _ : constant$4(!!_), brush) : filter;
4727 brush.handleSize =
function(_) {
4728 return arguments.length ? (handleSize = +_, brush) : handleSize;
4731 brush.on =
function() {
4732 var value = listeners.on.apply(listeners, arguments);
4733 return value === listeners ? brush : value;
4742 var halfPi$1 = pi$1 / 2;
4743 var tau$1 = pi$1 * 2;
4744 var max$1 = Math.max;
4746 function compareValue(compare) {
4747 return function(a, b) {
4749 a.source.value + a.target.value,
4750 b.source.value + b.target.value
4758 sortSubgroups = null,
4761 function chord(matrix) {
4762 var n = matrix.length,
4764 groupIndex = sequence(n),
4767 groups = chords.groups =
new Array(n),
4768 subgroups =
new Array(n * n),
4777 k = 0, i = -1;
while (++i < n) {
4778 x = 0, j = -1;
while (++j < n) {
4782 subgroupIndex.push(sequence(n));
4787 if (sortGroups) groupIndex.sort(
function(a, b) {
4788 return sortGroups(groupSums[a], groupSums[b]);
4792 if (sortSubgroups) subgroupIndex.forEach(
function(d, i) {
4793 d.sort(
function(a, b) {
4794 return sortSubgroups(matrix[i][a], matrix[i][b]);
4801 k = max$1(0, tau$1 - padAngle * n) / k;
4802 dx = k ? padAngle : tau$1 / n;
4806 x = 0, i = -1;
while (++i < n) {
4807 x0 = x, j = -1;
while (++j < n) {
4808 var di = groupIndex[i],
4809 dj = subgroupIndex[di][j],
4813 subgroups[dj * n + di] = {
4825 value: groupSums[di]
4831 i = -1;
while (++i < n) {
4832 j = i - 1;
while (++j < n) {
4833 var source = subgroups[j * n + i],
4834 target = subgroups[i * n + j];
4835 if (source.value || target.value) {
4836 chords.push(source.value < target.value
4837 ? {source: target, target: source}
4838 : {source: source, target: target});
4843 return sortChords ? chords.sort(sortChords) : chords;
4846 chord.padAngle =
function(_) {
4847 return arguments.length ? (padAngle = max$1(0, _), chord) : padAngle;
4850 chord.sortGroups =
function(_) {
4851 return arguments.length ? (sortGroups = _, chord) : sortGroups;
4854 chord.sortSubgroups =
function(_) {
4855 return arguments.length ? (sortSubgroups = _, chord) : sortSubgroups;
4858 chord.sortChords =
function(_) {
4859 return arguments.length ? (_ == null ? sortChords = null : (sortChords = compareValue(_))._ = _, chord) : sortChords && sortChords._;
4865 var slice$2 = Array.prototype.slice;
4867 function constant$5(x) {
4876 tauEpsilon = tau$2 - epsilon$1;
4879 this._x0 = this._y0 =
4880 this._x1 = this._y1 = null;
4888 Path.prototype = path.prototype = {
4890 moveTo:
function(x, y) {
4891 this._ +=
"M" + (this._x0 = this._x1 = +x) +
"," + (this._y0 = this._y1 = +y);
4893 closePath:
function() {
4894 if (this._x1 !== null) {
4895 this._x1 = this._x0, this._y1 = this._y0;
4899 lineTo:
function(x, y) {
4900 this._ +=
"L" + (this._x1 = +x) +
"," + (this._y1 = +y);
4902 quadraticCurveTo:
function(x1, y1, x, y) {
4903 this._ +=
"Q" + (+x1) +
"," + (+y1) +
"," + (this._x1 = +x) +
"," + (this._y1 = +y);
4905 bezierCurveTo:
function(x1, y1, x2, y2, x, y) {
4906 this._ +=
"C" + (+x1) +
"," + (+y1) +
"," + (+x2) +
"," + (+y2) +
"," + (this._x1 = +x) +
"," + (this._y1 = +y);
4908 arcTo:
function(x1, y1, x2, y2, r) {
4909 x1 = +x1, y1 = +y1, x2 = +x2, y2 = +y2, r = +r;
4916 l01_2 = x01 * x01 + y01 * y01;
4919 if (r < 0)
throw new Error(
"negative radius: " + r);
4922 if (this._x1 === null) {
4923 this._ +=
"M" + (this._x1 = x1) +
"," + (this._y1 = y1);
4927 else if (!(l01_2 > epsilon$1));
4932 else if (!(Math.abs(y01 * x21 - y21 * x01) > epsilon$1) || !r) {
4933 this._ +=
"L" + (this._x1 = x1) +
"," + (this._y1 = y1);
4940 l21_2 = x21 * x21 + y21 * y21,
4941 l20_2 = x20 * x20 + y20 * y20,
4942 l21 = Math.sqrt(l21_2),
4943 l01 = Math.sqrt(l01_2),
4944 l = r * Math.tan((pi$2 - Math.acos((l21_2 + l01_2 - l20_2) / (2 * l21 * l01))) / 2),
4949 if (Math.abs(t01 - 1) > epsilon$1) {
4950 this._ +=
"L" + (x1 + t01 * x01) +
"," + (y1 + t01 * y01);
4953 this._ +=
"A" + r +
"," + r +
",0,0," + (+(y01 * x20 > x01 * y20)) +
"," + (this._x1 = x1 + t21 * x21) +
"," + (this._y1 = y1 + t21 * y21);
4956 arc:
function(x, y, r, a0, a1, ccw) {
4957 x = +x, y = +y, r = +r;
4958 var dx = r * Math.cos(a0),
4959 dy = r * Math.sin(a0),
4963 da = ccw ? a0 - a1 : a1 - a0;
4966 if (r < 0)
throw new Error(
"negative radius: " + r);
4969 if (this._x1 === null) {
4970 this._ +=
"M" + x0 +
"," + y0;
4974 else if (Math.abs(
this._x1 - x0) > epsilon$1 || Math.abs(this._y1 - y0) > epsilon$1) {
4975 this._ +=
"L" + x0 +
"," + y0;
4982 if (da < 0) da = da % tau$2 + tau$2;
4985 if (da > tauEpsilon) {
4986 this._ +=
"A" + r +
"," + r +
",0,1," + cw +
"," + (x - dx) +
"," + (y - dy) +
"A" + r +
"," + r +
",0,1," + cw +
"," + (this._x1 = x0) +
"," + (this._y1 = y0);
4990 else if (da > epsilon$1) {
4991 this._ +=
"A" + r +
"," + r +
",0," + (+(da >= pi$2)) +
"," + cw +
"," + (this._x1 = x + r * Math.cos(a1)) +
"," + (this._y1 = y + r * Math.sin(a1));
4994 rect:
function(x, y, w, h) {
4995 this._ +=
"M" + (this._x0 = this._x1 = +x) +
"," + (this._y0 = this._y1 = +y) +
"h" + (+w) +
"v" + (+h) +
"h" + (-w) +
"Z";
4997 toString:
function() {
5002 function defaultSource(d) {
5006 function defaultTarget(d) {
5010 function defaultRadius(d) {
5014 function defaultStartAngle(d) {
5015 return d.startAngle;
5018 function defaultEndAngle(d) {
5023 var source = defaultSource,
5024 target = defaultTarget,
5025 radius = defaultRadius,
5026 startAngle = defaultStartAngle,
5027 endAngle = defaultEndAngle,
5032 argv = slice$2.call(arguments),
5033 s = source.apply(
this, argv),
5034 t = target.apply(
this, argv),
5035 sr = +radius.apply(
this, (argv[0] = s, argv)),
5036 sa0 = startAngle.apply(
this, argv) - halfPi$1,
5037 sa1 = endAngle.apply(
this, argv) - halfPi$1,
5038 sx0 = sr * cos(sa0),
5039 sy0 = sr * sin(sa0),
5040 tr = +radius.apply(
this, (argv[0] = t, argv)),
5041 ta0 = startAngle.apply(
this, argv) - halfPi$1,
5042 ta1 = endAngle.apply(
this, argv) - halfPi$1;
5044 if (!context) context = buffer = path();
5046 context.moveTo(sx0, sy0);
5047 context.arc(0, 0, sr, sa0, sa1);
5048 if (sa0 !== ta0 || sa1 !== ta1) {
5049 context.quadraticCurveTo(0, 0, tr * cos(ta0), tr * sin(ta0));
5050 context.arc(0, 0, tr, ta0, ta1);
5052 context.quadraticCurveTo(0, 0, sx0, sy0);
5053 context.closePath();
5055 if (buffer)
return context = null, buffer +
"" || null;
5058 ribbon.radius =
function(_) {
5059 return arguments.length ? (radius = typeof _ ===
"function" ? _ : constant$5(+_), ribbon) : radius;
5062 ribbon.startAngle =
function(_) {
5063 return arguments.length ? (startAngle = typeof _ ===
"function" ? _ : constant$5(+_), ribbon) : startAngle;
5066 ribbon.endAngle =
function(_) {
5067 return arguments.length ? (endAngle = typeof _ ===
"function" ? _ : constant$5(+_), ribbon) : endAngle;
5070 ribbon.source =
function(_) {
5071 return arguments.length ? (source = _, ribbon) : source;
5074 ribbon.target =
function(_) {
5075 return arguments.length ? (target = _, ribbon) : target;
5078 ribbon.context =
function(_) {
5079 return arguments.length ? ((context = _ == null ? null : _), ribbon) : context;
5089 Map.prototype = map$1.prototype = {
5091 has:
function(key) {
5092 return (prefix + key) in
this;
5094 get:
function(key) {
5095 return this[prefix + key];
5097 set:
function(key, value) {
5098 this[prefix + key] = value;
5101 remove:
function(key) {
5102 var
property = prefix + key;
5103 return property in
this &&
delete this[property];
5106 for (var property in
this)
if (property[0] === prefix)
delete this[property];
5110 for (var property in
this)
if (property[0] === prefix) keys.push(property.slice(1));
5113 values:
function() {
5115 for (var property in
this)
if (property[0] === prefix) values.push(
this[property]);
5118 entries:
function() {
5120 for (var property in
this)
if (property[0] === prefix) entries.push({key:
property.slice(1), value:
this[property]});
5125 for (var property in
this)
if (property[0] === prefix) ++size;
5129 for (var property in
this)
if (property[0] === prefix)
return false;
5133 for (var property in
this)
if (property[0] === prefix) f(
this[property], property.slice(1),
this);
5137 function map$1(object, f) {
5141 if (
object instanceof Map)
object.each(
function(value, key) { map.set(key, value); });
5144 else if (Array.isArray(
object)) {
5149 if (f == null)
while (++i < n) map.set(i,
object[i]);
5150 else while (++i < n) map.set(f(o =
object[i], i,
object), o);
5154 else if (
object)
for (var key in
object) map.set(key,
object[key]);
5166 function apply(array, depth, createResult, setResult) {
5167 if (depth >= keys.length) {
5168 if (sortValues != null) array.sort(sortValues);
5169 return rollup != null ? rollup(array) : array;
5174 key = keys[depth++],
5177 valuesByKey = map$1(),
5179 result = createResult();
5182 if (values = valuesByKey.get(keyValue = key(value = array[i]) +
"")) {
5185 valuesByKey.set(keyValue, [value]);
5189 valuesByKey.each(
function(values, key) {
5190 setResult(result, key, apply(values, depth, createResult, setResult));
5196 function entries(map, depth) {
5197 if (++depth > keys.length)
return map;
5198 var array, sortKey = sortKeys[depth - 1];
5199 if (rollup != null && depth >= keys.length) array = map.entries();
5200 else array = [], map.each(
function(v, k) { array.push({key: k, values: entries(v, depth)}); });
5201 return sortKey != null ? array.sort(
function(a, b) {
return sortKey(a.key, b.key); }) : array;
5205 object:
function(array) {
return apply(array, 0, createObject, setObject); },
5206 map:
function(array) {
return apply(array, 0, createMap, setMap); },
5207 entries:
function(array) {
return entries(apply(array, 0, createMap, setMap), 0); },
5208 key:
function(d) { keys.push(d);
return nest; },
5209 sortKeys:
function(order) { sortKeys[keys.length - 1] = order;
return nest; },
5210 sortValues:
function(order) { sortValues = order;
return nest; },
5211 rollup:
function(f) { rollup = f;
return nest; }
5215 function createObject() {
5219 function setObject(
object, key, value) {
5220 object[key] = value;
5223 function createMap() {
5227 function setMap(map, key, value) {
5228 map.set(key, value);
5233 var proto = map$1.prototype;
5235 Set.prototype = set$2.prototype = {
5238 add:
function(value) {
5240 this[prefix + value] = value;
5243 remove: proto.remove,
5251 function set$2(object, f) {
5255 if (
object instanceof Set)
object.each(
function(value) { set.add(value); });
5259 var i = -1, n =
object.length;
5260 if (f == null)
while (++i < n) set.add(
object[i]);
5261 else while (++i < n) set.add(f(
object[i], i,
object));
5267 function keys(map) {
5269 for (var key in map) keys.push(key);
5273 function values(map) {
5275 for (var key in map) values.push(map[key]);
5279 function entries(map) {
5281 for (var key in map) entries.push({key: key, value: map[key]});
5285 var array$2 = Array.prototype;
5287 var slice$3 = array$2.slice;
5289 function ascending$2(a, b) {
5293 function area(ring) {
5294 var i = 0, n = ring.length, area = ring[n - 1][1] * ring[0][0] - ring[n - 1][0] * ring[0][1];
5295 while (++i < n) area += ring[i - 1][1] * ring[i][0] - ring[i - 1][0] * ring[i][1];
5299 function constant$6(x) {
5305 function contains(ring, hole) {
5306 var i = -1, n = hole.length, c;
5307 while (++i < n)
if (c = ringContains(ring, hole[i]))
return c;
5311 function ringContains(ring, point) {
5312 var x = point[0], y = point[1], contains = -1;
5313 for (var i = 0, n = ring.length, j = n - 1; i < n; j = i++) {
5314 var pi = ring[i], xi = pi[0], yi = pi[1], pj = ring[j], xj = pj[0], yj = pj[1];
5315 if (segmentContains(pi, pj, point))
return 0;
5316 if (((yi > y) !== (yj > y)) && ((x < (xj - xi) * (y - yi) / (yj - yi) + xi))) contains = -contains;
5321 function segmentContains(a, b, c) {
5322 var i;
return collinear(a, b, c) && within(a[i = +(a[0] === b[0])], c[i], b[i]);
5325 function collinear(a, b, c) {
5326 return (b[0] - a[0]) * (c[1] - a[1]) === (c[0] - a[0]) * (b[1] - a[1]);
5329 function within(p, q, r) {
5330 return p <= q && q <= r || r <= q && q <= p;
5333 function noop$1() {}
5337 [[[1.0, 1.5], [0.5, 1.0]]],
5338 [[[1.5, 1.0], [1.0, 1.5]]],
5339 [[[1.5, 1.0], [0.5, 1.0]]],
5340 [[[1.0, 0.5], [1.5, 1.0]]],
5341 [[[1.0, 1.5], [0.5, 1.0]], [[1.0, 0.5], [1.5, 1.0]]],
5342 [[[1.0, 0.5], [1.0, 1.5]]],
5343 [[[1.0, 0.5], [0.5, 1.0]]],
5344 [[[0.5, 1.0], [1.0, 0.5]]],
5345 [[[1.0, 1.5], [1.0, 0.5]]],
5346 [[[0.5, 1.0], [1.0, 0.5]], [[1.5, 1.0], [1.0, 1.5]]],
5347 [[[1.5, 1.0], [1.0, 0.5]]],
5348 [[[0.5, 1.0], [1.5, 1.0]]],
5349 [[[1.0, 1.5], [1.5, 1.0]]],
5350 [[[0.5, 1.0], [1.0, 1.5]]],
5354 function contours() {
5357 threshold$$1 = thresholdSturges,
5358 smooth = smoothLinear;
5360 function contours(values) {
5361 var tz = threshold$$1(values);
5364 if (!Array.isArray(tz)) {
5365 var domain = extent(values), start = domain[0], stop = domain[1];
5366 tz = tickStep(start, stop, tz);
5367 tz = sequence(Math.floor(start / tz) * tz, Math.floor(stop / tz) * tz, tz);
5369 tz = tz.slice().sort(ascending$2);
5372 return tz.map(
function(value) {
5373 return contour(values, value);
5379 function contour(values, value) {
5383 isorings(values, value,
function(ring) {
5384 smooth(ring, values, value);
5385 if (area(ring) > 0) polygons.push([ring]);
5386 else holes.push(ring);
5389 holes.forEach(
function(hole) {
5390 for (var i = 0, n = polygons.length, polygon; i < n; ++i) {
5391 if (contains((polygon = polygons[i])[0], hole) !== -1) {
5399 type:
"MultiPolygon",
5401 coordinates: polygons
5407 function isorings(values, value, callback) {
5408 var fragmentByStart =
new Array,
5409 fragmentByEnd =
new Array,
5410 x, y, t0, t1, t2, t3;
5414 t1 = values[0] >= value;
5415 cases[t1 << 1].forEach(stitch);
5416 while (++x < dx - 1) {
5417 t0 = t1, t1 = values[x + 1] >= value;
5418 cases[t0 | t1 << 1].forEach(stitch);
5420 cases[t1 << 0].forEach(stitch);
5423 while (++y < dy - 1) {
5425 t1 = values[y * dx + dx] >= value;
5426 t2 = values[y * dx] >= value;
5427 cases[t1 << 1 | t2 << 2].forEach(stitch);
5428 while (++x < dx - 1) {
5429 t0 = t1, t1 = values[y * dx + dx + x + 1] >= value;
5430 t3 = t2, t2 = values[y * dx + x + 1] >= value;
5431 cases[t0 | t1 << 1 | t2 << 2 | t3 << 3].forEach(stitch);
5433 cases[t1 | t2 << 3].forEach(stitch);
5438 t2 = values[y * dx] >= value;
5439 cases[t2 << 2].forEach(stitch);
5440 while (++x < dx - 1) {
5441 t3 = t2, t2 = values[y * dx + x + 1] >= value;
5442 cases[t2 << 2 | t3 << 3].forEach(stitch);
5444 cases[t2 << 3].forEach(stitch);
5446 function stitch(line) {
5447 var start = [line[0][0] + x, line[0][1] + y],
5448 end = [line[1][0] + x, line[1][1] + y],
5449 startIndex = index(start),
5450 endIndex = index(end),
5452 if (f = fragmentByEnd[startIndex]) {
5453 if (g = fragmentByStart[endIndex]) {
5454 delete fragmentByEnd[f.end];
5455 delete fragmentByStart[g.start];
5460 fragmentByStart[f.start] = fragmentByEnd[g.end] = {start: f.start, end: g.end, ring: f.ring.concat(g.ring)};
5463 delete fragmentByEnd[f.end];
5465 fragmentByEnd[f.end = endIndex] = f;
5467 }
else if (f = fragmentByStart[endIndex]) {
5468 if (g = fragmentByEnd[startIndex]) {
5469 delete fragmentByStart[f.start];
5470 delete fragmentByEnd[g.end];
5475 fragmentByStart[g.start] = fragmentByEnd[f.end] = {start: g.start, end: f.end, ring: g.ring.concat(f.ring)};
5478 delete fragmentByStart[f.start];
5479 f.ring.unshift(start);
5480 fragmentByStart[f.start = startIndex] = f;
5483 fragmentByStart[startIndex] = fragmentByEnd[endIndex] = {start: startIndex, end: endIndex, ring: [start, end]};
5488 function index(point) {
5489 return point[0] * 2 + point[1] * (dx + 1) * 4;
5492 function smoothLinear(ring, values, value) {
5493 ring.forEach(
function(point) {
5499 v1 = values[yt * dx + xt];
5500 if (x > 0 && x < dx && xt === x) {
5501 v0 = values[yt * dx + xt - 1];
5502 point[0] = x + (value - v0) / (v1 - v0) - 0.5;
5504 if (y > 0 && y < dy && yt === y) {
5505 v0 = values[(yt - 1) * dx + xt];
5506 point[1] = y + (value - v0) / (v1 - v0) - 0.5;
5511 contours.contour = contour;
5513 contours.size =
function(_) {
5514 if (!arguments.length)
return [dx, dy];
5515 var _0 = Math.ceil(_[0]), _1 = Math.ceil(_[1]);
5516 if (!(_0 > 0) || !(_1 > 0))
throw new Error(
"invalid size");
5517 return dx = _0, dy = _1, contours;
5520 contours.thresholds =
function(_) {
5521 return arguments.length ? (threshold$$1 = typeof _ ===
"function" ? _ : Array.isArray(_) ? constant$6(slice$3.call(_)) : constant$6(_), contours) : threshold$$1;
5524 contours.smooth =
function(_) {
5525 return arguments.length ? (smooth = _ ? smoothLinear : noop$1, contours) : smooth === smoothLinear;
5534 function blurX(source, target, r) {
5535 var n = source.width,
5538 for (var j = 0; j < m; ++j) {
5539 for (var i = 0, sr = 0; i < n + r; ++i) {
5541 sr += source.data[i + j * n];
5545 sr -= source.data[i - w + j * n];
5547 target.data[i - r + j * n] = sr / Math.min(i + 1, n - 1 + w - i, w);
5556 function blurY(source, target, r) {
5557 var n = source.width,
5560 for (var i = 0; i < n; ++i) {
5561 for (var j = 0, sr = 0; j < m + r; ++j) {
5563 sr += source.data[i + j * n];
5567 sr -= source.data[i + (j - w) * n];
5569 target.data[i + (j - r) * n] = sr / Math.min(j + 1, m - 1 + w - j, w);
5575 function defaultX(d) {
5579 function defaultY(d) {
5583 function defaultWeight() {
5587 function density() {
5590 weight = defaultWeight,
5596 n = (dx + o * 2) >> k,
5597 m = (dy + o * 2) >> k,
5598 threshold$$1 = constant$6(20);
5600 function density(data) {
5601 var values0 =
new Float32Array(n * m),
5602 values1 =
new Float32Array(n * m);
5604 data.forEach(
function(d, i, data) {
5605 var xi = (+x(d, i, data) + o) >> k,
5606 yi = (+y(d, i, data) + o) >> k,
5607 wi = +weight(d, i, data);
5608 if (xi >= 0 && xi < n && yi >= 0 && yi < m) {
5609 values0[xi + yi * n] += wi;
5614 blurX({width: n, height: m, data: values0}, {width: n, height: m, data: values1}, r >> k);
5615 blurY({width: n, height: m, data: values1}, {width: n, height: m, data: values0}, r >> k);
5616 blurX({width: n, height: m, data: values0}, {width: n, height: m, data: values1}, r >> k);
5617 blurY({width: n, height: m, data: values1}, {width: n, height: m, data: values0}, r >> k);
5618 blurX({width: n, height: m, data: values0}, {width: n, height: m, data: values1}, r >> k);
5619 blurY({width: n, height: m, data: values1}, {width: n, height: m, data: values0}, r >> k);
5621 var tz = threshold$$1(values0);
5624 if (!Array.isArray(tz)) {
5625 var stop = max(values0);
5626 tz = tickStep(0, stop, tz);
5627 tz = sequence(0, Math.floor(stop / tz) * tz, tz);
5638 function transform(geometry) {
5639 geometry.value *= Math.pow(2, -2 * k);
5640 geometry.coordinates.forEach(transformPolygon);
5644 function transformPolygon(coordinates) {
5645 coordinates.forEach(transformRing);
5648 function transformRing(coordinates) {
5649 coordinates.forEach(transformPoint);
5653 function transformPoint(coordinates) {
5654 coordinates[0] = coordinates[0] * Math.pow(2, k) - o;
5655 coordinates[1] = coordinates[1] * Math.pow(2, k) - o;
5660 n = (dx + o * 2) >> k;
5661 m = (dy + o * 2) >> k;
5665 density.x =
function(_) {
5666 return arguments.length ? (x = typeof _ ===
"function" ? _ : constant$6(+_), density) : x;
5669 density.y =
function(_) {
5670 return arguments.length ? (y = typeof _ ===
"function" ? _ : constant$6(+_), density) : y;
5673 density.weight =
function(_) {
5674 return arguments.length ? (weight = typeof _ ===
"function" ? _ : constant$6(+_), density) : weight;
5677 density.size =
function(_) {
5678 if (!arguments.length)
return [dx, dy];
5679 var _0 = Math.ceil(_[0]), _1 = Math.ceil(_[1]);
5680 if (!(_0 >= 0) && !(_0 >= 0))
throw new Error(
"invalid size");
5681 return dx = _0, dy = _1, resize();
5684 density.cellSize =
function(_) {
5685 if (!arguments.length)
return 1 << k;
5686 if (!((_ = +_) >= 1))
throw new Error(
"invalid cell size");
5687 return k = Math.floor(Math.log(_) / Math.LN2), resize();
5690 density.thresholds =
function(_) {
5691 return arguments.length ? (threshold$$1 = typeof _ ===
"function" ? _ : Array.isArray(_) ? constant$6(slice$3.call(_)) : constant$6(_), density) : threshold$$1;
5694 density.bandwidth =
function(_) {
5695 if (!arguments.length)
return Math.sqrt(r * (r + 1));
5696 if (!((_ = +_) >= 0))
throw new Error(
"invalid bandwidth");
5697 return r = Math.round((Math.sqrt(4 * _ * _ + 1) - 1) / 2), resize();
5709 function objectConverter(columns) {
5710 return new Function(
"d",
"return {" + columns.map(
function(name, i) {
5711 return JSON.stringify(name) +
": d[" + i +
"]";
5712 }).join(
",") +
"}");
5715 function customConverter(columns, f) {
5716 var
object = objectConverter(columns);
5717 return function(row, i) {
5718 return f(
object(row), i, columns);
5723 function inferColumns(rows) {
5724 var columnSet = Object.create(null),
5727 rows.forEach(
function(row) {
5728 for (var column in row) {
5729 if (!(column in columnSet)) {
5730 columns.push(columnSet[column] = column);
5738 function dsvFormat(delimiter) {
5739 var reFormat =
new RegExp(
"[\"" + delimiter +
"\n\r]"),
5740 DELIMITER = delimiter.charCodeAt(0);
5742 function parse(text, f) {
5743 var convert, columns, rows = parseRows(text,
function(row, i) {
5744 if (convert)
return convert(row, i - 1);
5745 columns = row, convert = f ? customConverter(row, f) : objectConverter(row);
5747 rows.columns = columns || [];
5751 function parseRows(text, f) {
5761 if (text.charCodeAt(N - 1) === NEWLINE) --N;
5762 if (text.charCodeAt(N - 1) === RETURN) --N;
5765 if (eof)
return EOF;
5766 if (eol)
return eol =
false, EOL;
5770 if (text.charCodeAt(j) === QUOTE) {
5771 while (I++ < N && text.charCodeAt(I) !== QUOTE || text.charCodeAt(++I) === QUOTE);
5772 if ((i = I) >= N) eof =
true;
5773 else if ((c = text.charCodeAt(I++)) === NEWLINE) eol =
true;
5774 else if (c === RETURN) { eol =
true;
if (text.charCodeAt(I) === NEWLINE) ++I; }
5775 return text.slice(j + 1, i - 1).replace(/
""/g,
"\"");
5780 if ((c = text.charCodeAt(i = I++)) === NEWLINE) eol =
true;
5781 else if (c === RETURN) { eol =
true;
if (text.charCodeAt(I) === NEWLINE) ++I; }
5782 else if (c !== DELIMITER)
continue;
5783 return text.slice(j, i);
5787 return eof =
true, text.slice(j, N);
5790 while ((t = token()) !== EOF) {
5792 while (t !== EOL && t !== EOF) row.push(t), t = token();
5793 if (f && (row = f(row, n++)) == null)
continue;
5800 function format(rows, columns) {
5801 if (columns == null) columns = inferColumns(rows);
5802 return [columns.map(formatValue).join(delimiter)].concat(rows.map(
function(row) {
5803 return columns.map(
function(column) {
5804 return formatValue(row[column]);
5809 function formatRows(rows) {
5810 return rows.map(formatRow).join(
"\n");
5813 function formatRow(row) {
5814 return row.map(formatValue).join(delimiter);
5817 function formatValue(text) {
5818 return text == null ?
""
5819 : reFormat.test(text +=
"") ?
"\"" + text.replace(/
"/g, "\
"\"") +
"\""
5825 parseRows: parseRows,
5827 formatRows: formatRows
5831 var csv = dsvFormat(
",");
5833 var csvParse = csv.parse;
5834 var csvParseRows = csv.parseRows;
5835 var csvFormat = csv.format;
5836 var csvFormatRows = csv.formatRows;
5838 var tsv = dsvFormat(
"\t");
5840 var tsvParse = tsv.parse;
5841 var tsvParseRows = tsv.parseRows;
5842 var tsvFormat = tsv.format;
5843 var tsvFormatRows = tsv.formatRows;
5845 function responseBlob(response) {
5846 if (!response.ok)
throw new Error(response.status +
" " + response.statusText);
5847 return response.blob();
5850 function blob(input, init) {
5851 return fetch(input, init).then(responseBlob);
5854 function responseArrayBuffer(response) {
5855 if (!response.ok)
throw new Error(response.status +
" " + response.statusText);
5856 return response.arrayBuffer();
5859 function buffer(input, init) {
5860 return fetch(input, init).then(responseArrayBuffer);
5863 function responseText(response) {
5864 if (!response.ok)
throw new Error(response.status +
" " + response.statusText);
5865 return response.text();
5868 function text(input, init) {
5869 return fetch(input, init).then(responseText);
5872 function dsvParse(parse) {
5873 return function(input, init, row) {
5874 if (arguments.length === 2 && typeof init ===
"function") row = init, init = undefined;
5875 return text(input, init).then(
function(response) {
5876 return parse(response, row);
5881 function dsv(delimiter, input, init, row) {
5882 if (arguments.length === 3 && typeof init ===
"function") row = init, init = undefined;
5883 var format = dsvFormat(delimiter);
5884 return text(input, init).then(
function(response) {
5885 return format.parse(response, row);
5889 var csv$1 = dsvParse(csvParse);
5890 var tsv$1 = dsvParse(tsvParse);
5892 function image(input, init) {
5893 return new Promise(
function(resolve, reject) {
5894 var image =
new Image;
5895 for (var key in init) image[key] = init[key];
5896 image.onerror = reject;
5897 image.onload =
function() { resolve(image); };
5902 function responseJson(response) {
5903 if (!response.ok)
throw new Error(response.status +
" " + response.statusText);
5904 return response.json();
5907 function json(input, init) {
5908 return fetch(input, init).then(responseJson);
5911 function parser(type) {
5912 return function(input, init) {
5913 return text(input, init).then(
function(text$$1) {
5914 return (
new DOMParser).parseFromString(text$$1, type);
5919 var xml = parser(
"application/xml");
5921 var html = parser(
"text/html");
5923 var svg = parser(
"image/svg+xml");
5925 function center$1(x, y) {
5928 if (x == null) x = 0;
5929 if (y == null) y = 0;
5938 for (i = 0; i < n; ++i) {
5939 node = nodes[i], sx += node.x, sy += node.y;
5942 for (sx = sx / n - x, sy = sy / n - y, i = 0; i < n; ++i) {
5943 node = nodes[i], node.x -= sx, node.y -= sy;
5947 force.initialize =
function(_) {
5951 force.x =
function(_) {
5952 return arguments.length ? (x = +_, force) : x;
5955 force.y =
function(_) {
5956 return arguments.length ? (y = +_, force) : y;
5962 function constant$7(x) {
5969 return (Math.random() - 0.5) * 1e-6;
5972 function tree_add(d) {
5973 var x = +this._x.call(null, d),
5974 y = +this._y.call(null, d);
5975 return add(this.cover(x, y), x, y, d);
5978 function add(tree, x, y, d) {
5979 if (isNaN(x) || isNaN(y))
return tree;
5998 if (!node)
return tree._root = leaf, tree;
6001 while (node.length) {
6002 if (right = x >= (xm = (x0 + x1) / 2)) x0 = xm;
else x1 = xm;
6003 if (bottom = y >= (ym = (y0 + y1) / 2)) y0 = ym;
else y1 = ym;
6004 if (parent = node, !(node = node[i = bottom << 1 | right]))
return parent[i] = leaf, tree;
6008 xp = +tree._x.call(null, node.data);
6009 yp = +tree._y.call(null, node.data);
6010 if (x === xp && y === yp)
return leaf.next = node, parent ? parent[i] = leaf : tree._root = leaf, tree;
6014 parent = parent ? parent[i] =
new Array(4) : tree._root = new Array(4);
6015 if (right = x >= (xm = (x0 + x1) / 2)) x0 = xm;
else x1 = xm;
6016 if (bottom = y >= (ym = (y0 + y1) / 2)) y0 = ym;
else y1 = ym;
6017 }
while ((i = bottom << 1 | right) === (j = (yp >= ym) << 1 | (xp >= xm)));
6018 return parent[j] = node, parent[i] = leaf, tree;
6021 function addAll(data) {
6022 var d, i, n = data.length,
6033 for (i = 0; i < n; ++i) {
6034 if (isNaN(x = +this._x.call(null, d = data[i])) || isNaN(y = +this._y.call(null, d)))
continue;
6044 if (x1 < x0) x0 = this._x0, x1 = this._x1;
6045 if (y1 < y0) y0 = this._y0, y1 = this._y1;
6048 this.cover(x0, y0).cover(x1, y1);
6051 for (i = 0; i < n; ++i) {
6052 add(
this, xz[i], yz[i], data[i]);
6058 function tree_cover(x, y) {
6059 if (isNaN(x = +x) || isNaN(y = +y))
return this;
6070 x1 = (x0 = Math.floor(x)) + 1;
6071 y1 = (y0 = Math.floor(y)) + 1;
6075 else if (x0 > x || x > x1 || y0 > y || y > y1) {
6081 switch (i = (y < (y0 + y1) / 2) << 1 | (x < (x0 + x1) / 2)) {
6083 do parent =
new Array(4), parent[i] = node, node = parent;
6084 while (z *= 2, x1 = x0 + z, y1 = y0 + z, x > x1 || y > y1);
6088 do parent =
new Array(4), parent[i] = node, node = parent;
6089 while (z *= 2, x0 = x1 - z, y1 = y0 + z, x0 > x || y > y1);
6093 do parent =
new Array(4), parent[i] = node, node = parent;
6094 while (z *= 2, x1 = x0 + z, y0 = y1 - z, x > x1 || y0 > y);
6098 do parent =
new Array(4), parent[i] = node, node = parent;
6099 while (z *= 2, x0 = x1 - z, y0 = y1 - z, x0 > x || y0 > y);
6104 if (this._root && this._root.length) this._root = node;
6117 function tree_data() {
6119 this.visit(
function(node) {
6120 if (!node.length)
do data.push(node.data);
while (node = node.next)
6125 function tree_extent(_) {
6126 return arguments.length
6127 ? this.cover(+_[0][0], +_[0][1]).cover(+_[1][0], +_[1][1])
6128 : isNaN(this._x0) ? undefined : [[this._x0, this._y0], [this._x1, this._y1]];
6131 function Quad(node, x0, y0, x1, y1) {
6139 function tree_find(x, y, radius) {
6154 if (node) quads.push(
new Quad(node, x0, y0, x3, y3));
6155 if (radius == null) radius = Infinity;
6157 x0 = x - radius, y0 = y - radius;
6158 x3 = x + radius, y3 = y + radius;
6162 while (q = quads.pop()) {
6165 if (!(node = q.node)
6169 || (y2 = q.y1) < y0)
continue;
6173 var xm = (x1 + x2) / 2,
6177 new Quad(node[3], xm, ym, x2, y2),
6178 new Quad(node[2], x1, ym, xm, y2),
6179 new Quad(node[1], xm, y1, x2, ym),
6180 new Quad(node[0], x1, y1, xm, ym)
6184 if (i = (y >= ym) << 1 | (x >= xm)) {
6185 q = quads[quads.length - 1];
6186 quads[quads.length - 1] = quads[quads.length - 1 - i];
6187 quads[quads.length - 1 - i] = q;
6193 var dx = x - +this._x.call(null, node.data),
6194 dy = y - +this._y.call(null, node.data),
6195 d2 = dx * dx + dy * dy;
6197 var d = Math.sqrt(radius = d2);
6198 x0 = x - d, y0 = y - d;
6199 x3 = x + d, y3 = y + d;
6208 function tree_remove(d) {
6209 if (isNaN(x = +this._x.call(null, d)) || isNaN(y = +this._y.call(null, d)))
return this;
6230 if (!node)
return this;
6234 if (node.length)
while (
true) {
6235 if (right = x >= (xm = (x0 + x1) / 2)) x0 = xm;
else x1 = xm;
6236 if (bottom = y >= (ym = (y0 + y1) / 2)) y0 = ym;
else y1 = ym;
6237 if (!(parent = node, node = node[i = bottom << 1 | right]))
return this;
6238 if (!node.length)
break;
6239 if (parent[(i + 1) & 3] || parent[(i + 2) & 3] || parent[(i + 3) & 3]) retainer = parent, j = i;
6243 while (node.data !== d)
if (!(previous = node, node = node.next))
return this;
6244 if (next = node.next)
delete node.next;
6247 if (previous)
return (next ? previous.next = next :
delete previous.next),
this;
6250 if (!parent)
return this._root = next,
this;
6253 next ? parent[i] = next :
delete parent[i];
6256 if ((node = parent[0] || parent[1] || parent[2] || parent[3])
6257 && node === (parent[3] || parent[2] || parent[1] || parent[0])
6259 if (retainer) retainer[j] = node;
6260 else this._root = node;
6266 function removeAll(data) {
6267 for (var i = 0, n = data.length; i < n; ++i) this.
remove(data[i]);
6271 function tree_root() {
6275 function tree_size() {
6277 this.visit(
function(node) {
6278 if (!node.length)
do ++size; while (node = node.next)
6283 function tree_visit(callback) {
6284 var quads = [], q, node = this._root, child, x0, y0, x1, y1;
6285 if (node) quads.push(
new Quad(node, this._x0, this._y0, this._x1, this._y1));
6286 while (q = quads.pop()) {
6287 if (!callback(node = q.node, x0 = q.x0, y0 = q.y0, x1 = q.x1, y1 = q.y1) && node.length) {
6288 var xm = (x0 + x1) / 2, ym = (y0 + y1) / 2;
6289 if (child = node[3]) quads.push(
new Quad(child, xm, ym, x1, y1));
6290 if (child = node[2]) quads.push(
new Quad(child, x0, ym, xm, y1));
6291 if (child = node[1]) quads.push(
new Quad(child, xm, y0, x1, ym));
6292 if (child = node[0]) quads.push(
new Quad(child, x0, y0, xm, ym));
6298 function tree_visitAfter(callback) {
6299 var quads = [], next = [], q;
6300 if (this._root) quads.push(
new Quad(this._root, this._x0, this._y0, this._x1, this._y1));
6301 while (q = quads.pop()) {
6304 var child, x0 = q.x0, y0 = q.y0, x1 = q.x1, y1 = q.y1, xm = (x0 + x1) / 2, ym = (y0 + y1) / 2;
6305 if (child = node[0]) quads.push(
new Quad(child, x0, y0, xm, ym));
6306 if (child = node[1]) quads.push(
new Quad(child, xm, y0, x1, ym));
6307 if (child = node[2]) quads.push(
new Quad(child, x0, ym, xm, y1));
6308 if (child = node[3]) quads.push(
new Quad(child, xm, ym, x1, y1));
6312 while (q = next.pop()) {
6313 callback(q.node, q.x0, q.y0, q.x1, q.y1);
6318 function defaultX$1(d) {
6322 function tree_x(_) {
6323 return arguments.length ? (this._x = _,
this) : this._x;
6326 function defaultY$1(d) {
6330 function tree_y(_) {
6331 return arguments.length ? (this._y = _,
this) : this._y;
6334 function quadtree(nodes, x, y) {
6335 var tree =
new Quadtree(x == null ? defaultX$1 : x, y == null ? defaultY$1 : y, NaN, NaN, NaN, NaN);
6336 return nodes == null ? tree : tree.addAll(nodes);
6339 function Quadtree(x, y, x0, y0, x1, y1) {
6346 this._root = undefined;
6349 function leaf_copy(leaf) {
6350 var copy = {data: leaf.data}, next = copy;
6351 while (leaf = leaf.next) next = next.next = {data: leaf.data};
6355 var treeProto = quadtree.prototype = Quadtree.prototype;
6357 treeProto.copy =
function() {
6358 var copy =
new Quadtree(this._x, this._y, this._x0, this._y0, this._x1, this._y1),
6363 if (!node)
return copy;
6365 if (!node.length)
return copy._root = leaf_copy(node), copy;
6367 nodes = [{source: node, target: copy._root =
new Array(4)}];
6368 while (node = nodes.pop()) {
6369 for (var i = 0; i < 4; ++i) {
6370 if (child = node.source[i]) {
6371 if (child.length) nodes.push({source: child, target: node.target[i] =
new Array(4)});
6372 else node.target[i] = leaf_copy(child);
6380 treeProto.add = tree_add;
6381 treeProto.addAll = addAll;
6382 treeProto.cover = tree_cover;
6383 treeProto.data = tree_data;
6384 treeProto.extent = tree_extent;
6385 treeProto.find = tree_find;
6386 treeProto.remove = tree_remove;
6387 treeProto.removeAll = removeAll;
6388 treeProto.root = tree_root;
6389 treeProto.size = tree_size;
6390 treeProto.visit = tree_visit;
6391 treeProto.visitAfter = tree_visitAfter;
6392 treeProto.x = tree_x;
6393 treeProto.y = tree_y;
6403 function collide(radius) {
6409 if (typeof radius !==
"function") radius = constant$7(radius == null ? 1 : +radius);
6412 var i, n = nodes.length,
6420 for (var k = 0; k < iterations; ++k) {
6421 tree = quadtree(nodes, x, y).visitAfter(prepare);
6422 for (i = 0; i < n; ++i) {
6424 ri = radii[node.index], ri2 = ri * ri;
6425 xi = node.x + node.vx;
6426 yi = node.y + node.vy;
6431 function apply(quad, x0, y0, x1, y1) {
6432 var data = quad.data, rj = quad.r, r = ri + rj;
6434 if (data.index > node.index) {
6435 var x = xi - data.x - data.vx,
6436 y = yi - data.y - data.vy,
6439 if (x === 0) x = jiggle(), l += x * x;
6440 if (y === 0) y = jiggle(), l += y * y;
6441 l = (r - (l = Math.sqrt(l))) / l * strength;
6442 node.vx += (x *= l) * (r = (rj *= rj) / (ri2 + rj));
6443 node.vy += (y *= l) * r;
6444 data.vx -= x * (r = 1 - r);
6450 return x0 > xi + r || x1 < xi - r || y0 > yi + r || y1 < yi - r;
6454 function prepare(quad) {
6455 if (quad.data)
return quad.r = radii[quad.data.index];
6456 for (var i = quad.r = 0; i < 4; ++i) {
6457 if (quad[i] && quad[i].r > quad.r) {
6463 function initialize() {
6465 var i, n = nodes.length, node;
6466 radii =
new Array(n);
6467 for (i = 0; i < n; ++i) node = nodes[i], radii[node.index] = +radius(node, i, nodes);
6470 force.initialize =
function(_) {
6475 force.iterations =
function(_) {
6476 return arguments.length ? (iterations = +_, force) : iterations;
6479 force.strength =
function(_) {
6480 return arguments.length ? (strength = +_, force) : strength;
6483 force.radius =
function(_) {
6484 return arguments.length ? (radius = typeof _ ===
"function" ? _ : constant$7(+_), initialize(), force) : radius;
6494 function find(nodeById, nodeId) {
6495 var node = nodeById.get(nodeId);
6496 if (!node)
throw new Error(
"missing: " + nodeId);
6500 function link(links) {
6502 strength = defaultStrength,
6504 distance = constant$7(30),
6511 if (links == null) links = [];
6513 function defaultStrength(link) {
6514 return 1 / Math.min(count[link.source.index], count[link.target.index]);
6517 function force(alpha) {
6518 for (var k = 0, n = links.length; k < iterations; ++k) {
6519 for (var i = 0, link, source, target, x, y, l, b; i < n; ++i) {
6520 link = links[i], source = link.source, target = link.target;
6521 x = target.x + target.vx - source.x - source.vx || jiggle();
6522 y = target.y + target.vy - source.y - source.vy || jiggle();
6523 l = Math.sqrt(x * x + y * y);
6524 l = (l - distances[i]) / l * alpha * strengths[i];
6526 target.vx -= x * (b = bias[i]);
6528 source.vx += x * (b = 1 - b);
6534 function initialize() {
6540 nodeById = map$1(nodes, id),
6543 for (i = 0, count =
new Array(n); i < m; ++i) {
6544 link = links[i], link.index = i;
6545 if (typeof link.source !==
"object") link.source = find(nodeById, link.source);
6546 if (typeof link.target !==
"object") link.target = find(nodeById, link.target);
6547 count[link.source.index] = (count[link.source.index] || 0) + 1;
6548 count[link.target.index] = (count[link.target.index] || 0) + 1;
6551 for (i = 0, bias =
new Array(m); i < m; ++i) {
6552 link = links[i], bias[i] = count[link.source.index] / (count[link.source.index] + count[link.target.index]);
6555 strengths =
new Array(m), initializeStrength();
6556 distances =
new Array(m), initializeDistance();
6559 function initializeStrength() {
6562 for (var i = 0, n = links.length; i < n; ++i) {
6563 strengths[i] = +strength(links[i], i, links);
6567 function initializeDistance() {
6570 for (var i = 0, n = links.length; i < n; ++i) {
6571 distances[i] = +distance(links[i], i, links);
6575 force.initialize =
function(_) {
6580 force.links =
function(_) {
6581 return arguments.length ? (links = _, initialize(), force) : links;
6584 force.id =
function(_) {
6585 return arguments.length ? (
id = _, force) :
id;
6588 force.iterations =
function(_) {
6589 return arguments.length ? (iterations = +_, force) : iterations;
6592 force.strength =
function(_) {
6593 return arguments.length ? (strength = typeof _ ===
"function" ? _ : constant$7(+_), initializeStrength(), force) : strength;
6596 force.distance =
function(_) {
6597 return arguments.length ? (distance = typeof _ ===
"function" ? _ : constant$7(+_), initializeDistance(), force) : distance;
6611 var initialRadius = 10,
6612 initialAngle = Math.PI * (3 - Math.sqrt(5));
6614 function simulation(nodes) {
6618 alphaDecay = 1 - Math.pow(alphaMin, 1 / 300),
6620 velocityDecay = 0.6,
6622 stepper = timer(step),
6623 event = dispatch(
"tick",
"end");
6625 if (nodes == null) nodes = [];
6629 event.call(
"tick", simulation);
6630 if (alpha < alphaMin) {
6632 event.call(
"end", simulation);
6637 var i, n = nodes.length, node;
6639 alpha += (alphaTarget - alpha) * alphaDecay;
6641 forces.each(
function(force) {
6645 for (i = 0; i < n; ++i) {
6647 if (node.fx == null) node.x += node.vx *= velocityDecay;
6648 else node.x = node.fx, node.vx = 0;
6649 if (node.fy == null) node.y += node.vy *= velocityDecay;
6650 else node.y = node.fy, node.vy = 0;
6654 function initializeNodes() {
6655 for (var i = 0, n = nodes.length, node; i < n; ++i) {
6656 node = nodes[i], node.index = i;
6657 if (isNaN(node.x) || isNaN(node.y)) {
6658 var radius = initialRadius * Math.sqrt(i), angle = i * initialAngle;
6659 node.x = radius * Math.cos(angle);
6660 node.y = radius * Math.sin(angle);
6662 if (isNaN(node.vx) || isNaN(node.vy)) {
6663 node.vx = node.vy = 0;
6668 function initializeForce(force) {
6669 if (force.initialize) force.initialize(nodes);
6675 return simulation = {
6678 restart:
function() {
6679 return stepper.restart(step), simulation;
6683 return stepper.stop(), simulation;
6686 nodes:
function(_) {
6687 return arguments.length ? (nodes = _, initializeNodes(), forces.each(initializeForce), simulation) : nodes;
6690 alpha:
function(_) {
6691 return arguments.length ? (alpha = +_, simulation) : alpha;
6694 alphaMin:
function(_) {
6695 return arguments.length ? (alphaMin = +_, simulation) : alphaMin;
6698 alphaDecay:
function(_) {
6699 return arguments.length ? (alphaDecay = +_, simulation) : +alphaDecay;
6702 alphaTarget:
function(_) {
6703 return arguments.length ? (alphaTarget = +_, simulation) : alphaTarget;
6706 velocityDecay:
function(_) {
6707 return arguments.length ? (velocityDecay = 1 - _, simulation) : 1 - velocityDecay;
6710 force:
function(name, _) {
6711 return arguments.length > 1 ? ((_ == null ? forces.remove(name) : forces.set(name, initializeForce(_))), simulation) : forces.get(name);
6714 find:
function(x, y, radius) {
6723 if (radius == null) radius = Infinity;
6724 else radius *= radius;
6726 for (i = 0; i < n; ++i) {
6730 d2 = dx * dx + dy * dy;
6731 if (d2 < radius) closest = node, radius = d2;
6737 on:
function(name, _) {
6738 return arguments.length > 1 ? (
event.on(name, _), simulation) : event.on(name);
6743 function manyBody() {
6747 strength = constant$7(-30),
6750 distanceMax2 = Infinity,
6754 var i, n = nodes.length, tree = quadtree(nodes, x$1, y$1).visitAfter(accumulate);
6755 for (alpha = _, i = 0; i < n; ++i) node = nodes[i], tree.visit(apply);
6758 function initialize() {
6760 var i, n = nodes.length, node;
6761 strengths =
new Array(n);
6762 for (i = 0; i < n; ++i) node = nodes[i], strengths[node.index] = +strength(node, i, nodes);
6765 function accumulate(quad) {
6766 var strength = 0, q, c, weight = 0, x, y, i;
6770 for (x = y = i = 0; i < 4; ++i) {
6771 if ((q = quad[i]) && (c = Math.abs(q.value))) {
6772 strength += q.value, weight += c, x += c * q.x, y += c * q.y;
6775 quad.x = x / weight;
6776 quad.y = y / weight;
6784 do strength += strengths[q.data.index];
6788 quad.value = strength;
6791 function apply(quad, x1, _, x2) {
6792 if (!quad.value)
return true;
6794 var x = quad.x - node.x,
6795 y = quad.y - node.y,
6801 if (w * w / theta2 < l) {
6802 if (l < distanceMax2) {
6803 if (x === 0) x = jiggle(), l += x * x;
6804 if (y === 0) y = jiggle(), l += y * y;
6805 if (l < distanceMin2) l = Math.sqrt(distanceMin2 * l);
6806 node.vx += x * quad.value * alpha / l;
6807 node.vy += y * quad.value * alpha / l;
6813 else if (quad.length || l >= distanceMax2)
return;
6816 if (quad.data !== node || quad.next) {
6817 if (x === 0) x = jiggle(), l += x * x;
6818 if (y === 0) y = jiggle(), l += y * y;
6819 if (l < distanceMin2) l = Math.sqrt(distanceMin2 * l);
6822 do if (quad.data !== node) {
6823 w = strengths[quad.data.index] * alpha / l;
6826 }
while (quad = quad.next);
6829 force.initialize =
function(_) {
6834 force.strength =
function(_) {
6835 return arguments.length ? (strength = typeof _ ===
"function" ? _ : constant$7(+_), initialize(), force) : strength;
6838 force.distanceMin =
function(_) {
6839 return arguments.length ? (distanceMin2 = _ * _, force) : Math.sqrt(distanceMin2);
6842 force.distanceMax =
function(_) {
6843 return arguments.length ? (distanceMax2 = _ * _, force) : Math.sqrt(distanceMax2);
6846 force.theta =
function(_) {
6847 return arguments.length ? (theta2 = _ * _, force) : Math.sqrt(theta2);
6853 function radial(radius, x, y) {
6855 strength = constant$7(0.1),
6859 if (typeof radius !==
"function") radius = constant$7(+radius);
6860 if (x == null) x = 0;
6861 if (y == null) y = 0;
6863 function force(alpha) {
6864 for (var i = 0, n = nodes.length; i < n; ++i) {
6865 var node = nodes[i],
6866 dx = node.x - x || 1e-6,
6867 dy = node.y - y || 1e-6,
6868 r = Math.sqrt(dx * dx + dy * dy),
6869 k = (radiuses[i] - r) * strengths[i] * alpha / r;
6875 function initialize() {
6877 var i, n = nodes.length;
6878 strengths =
new Array(n);
6879 radiuses =
new Array(n);
6880 for (i = 0; i < n; ++i) {
6881 radiuses[i] = +radius(nodes[i], i, nodes);
6882 strengths[i] = isNaN(radiuses[i]) ? 0 : +strength(nodes[i], i, nodes);
6886 force.initialize =
function(_) {
6887 nodes = _, initialize();
6890 force.strength =
function(_) {
6891 return arguments.length ? (strength = typeof _ ===
"function" ? _ : constant$7(+_), initialize(), force) : strength;
6894 force.radius =
function(_) {
6895 return arguments.length ? (radius = typeof _ ===
"function" ? _ : constant$7(+_), initialize(), force) : radius;
6898 force.x =
function(_) {
6899 return arguments.length ? (x = +_, force) : x;
6902 force.y =
function(_) {
6903 return arguments.length ? (y = +_, force) : y;
6910 var strength = constant$7(0.1),
6915 if (typeof x !==
"function") x = constant$7(x == null ? 0 : +x);
6917 function force(alpha) {
6918 for (var i = 0, n = nodes.length, node; i < n; ++i) {
6919 node = nodes[i], node.vx += (xz[i] - node.x) * strengths[i] * alpha;
6923 function initialize() {
6925 var i, n = nodes.length;
6926 strengths =
new Array(n);
6928 for (i = 0; i < n; ++i) {
6929 strengths[i] = isNaN(xz[i] = +x(nodes[i], i, nodes)) ? 0 : +strength(nodes[i], i, nodes);
6933 force.initialize =
function(_) {
6938 force.strength =
function(_) {
6939 return arguments.length ? (strength = typeof _ ===
"function" ? _ : constant$7(+_), initialize(), force) : strength;
6942 force.x =
function(_) {
6943 return arguments.length ? (x = typeof _ ===
"function" ? _ : constant$7(+_), initialize(), force) : x;
6950 var strength = constant$7(0.1),
6955 if (typeof y !==
"function") y = constant$7(y == null ? 0 : +y);
6957 function force(alpha) {
6958 for (var i = 0, n = nodes.length, node; i < n; ++i) {
6959 node = nodes[i], node.vy += (yz[i] - node.y) * strengths[i] * alpha;
6963 function initialize() {
6965 var i, n = nodes.length;
6966 strengths =
new Array(n);
6968 for (i = 0; i < n; ++i) {
6969 strengths[i] = isNaN(yz[i] = +y(nodes[i], i, nodes)) ? 0 : +strength(nodes[i], i, nodes);
6973 force.initialize =
function(_) {
6978 force.strength =
function(_) {
6979 return arguments.length ? (strength = typeof _ ===
"function" ? _ : constant$7(+_), initialize(), force) : strength;
6982 force.y =
function(_) {
6983 return arguments.length ? (y = typeof _ ===
"function" ? _ : constant$7(+_), initialize(), force) : y;
6992 function formatDecimal(x, p) {
6993 if ((i = (x = p ? x.toExponential(p - 1) : x.toExponential()).indexOf(
"e")) < 0)
return null;
6994 var i, coefficient = x.slice(0, i);
6999 coefficient.length > 1 ? coefficient[0] + coefficient.slice(2) : coefficient,
7004 function exponent$1(x) {
7005 return x = formatDecimal(Math.abs(x)), x ? x[1] : NaN;
7008 function formatGroup(grouping, thousands) {
7009 return function(value, width) {
7010 var i = value.length,
7016 while (i > 0 && g > 0) {
7017 if (length + g + 1 > width) g = Math.max(1, width - length);
7018 t.push(value.substring(i -= g, i + g));
7019 if ((length += g + 1) > width)
break;
7020 g = grouping[j = (j + 1) % grouping.length];
7023 return t.reverse().join(thousands);
7027 function formatNumerals(numerals) {
7028 return function(value) {
7029 return value.replace(/[0-9]/g,
function(i) {
7030 return numerals[+i];
7036 var re = /^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;
7038 function formatSpecifier(specifier) {
7039 return new FormatSpecifier(specifier);
7042 formatSpecifier.prototype = FormatSpecifier.prototype;
7044 function FormatSpecifier(specifier) {
7045 if (!(match = re.exec(specifier)))
throw new Error(
"invalid format: " + specifier);
7047 this.fill = match[1] ||
" ";
7048 this.align = match[2] ||
">";
7049 this.sign = match[3] ||
"-";
7050 this.symbol = match[4] ||
"";
7051 this.zero = !!match[5];
7052 this.width = match[6] && +match[6];
7053 this.comma = !!match[7];
7054 this.precision = match[8] && +match[8].slice(1);
7055 this.trim = !!match[9];
7056 this.type = match[10] ||
"";
7059 FormatSpecifier.prototype.toString =
function() {
7064 + (this.zero ?
"0" :
"")
7065 + (this.width == null ?
"" : Math.max(1,
this.width | 0))
7066 + (this.comma ?
"," :
"")
7067 + (this.precision == null ?
"" :
"." + Math.max(0, this.precision | 0))
7068 + (this.trim ?
"~" :
"")
7073 function formatTrim(s) {
7074 out:
for (var n = s.length, i = 1, i0 = -1, i1; i < n; ++i) {
7076 case ".": i0 = i1 = i;
break;
7077 case "0":
if (i0 === 0) i0 = i; i1 = i;
break;
7078 default:
if (i0 > 0) {
if (!+s[i])
break out; i0 = 0; }
break;
7081 return i0 > 0 ? s.slice(0, i0) + s.slice(i1 + 1) : s;
7086 function formatPrefixAuto(x, p) {
7087 var d = formatDecimal(x, p);
7088 if (!d)
return x +
"";
7089 var coefficient = d[0],
7091 i = exponent - (prefixExponent = Math.max(-8, Math.min(8, Math.floor(exponent / 3))) * 3) + 1,
7092 n = coefficient.length;
7093 return i === n ? coefficient
7094 : i > n ? coefficient +
new Array(i - n + 1).join(
"0")
7095 : i > 0 ? coefficient.slice(0, i) +
"." + coefficient.slice(i)
7096 :
"0." +
new Array(1 - i).join(
"0") + formatDecimal(x, Math.max(0, p + i - 1))[0];
7099 function formatRounded(x, p) {
7100 var d = formatDecimal(x, p);
7101 if (!d)
return x +
"";
7102 var coefficient = d[0],
7104 return exponent < 0 ?
"0." +
new Array(-exponent).join(
"0") + coefficient
7105 : coefficient.length > exponent + 1 ? coefficient.slice(0, exponent + 1) +
"." + coefficient.slice(exponent + 1)
7106 : coefficient +
new Array(exponent - coefficient.length + 2).join(
"0");
7110 "%":
function(x, p) {
return (x * 100).toFixed(p); },
7111 "b":
function(x) {
return Math.round(x).toString(2); },
7112 "c":
function(x) {
return x +
""; },
7113 "d":
function(x) {
return Math.round(x).toString(10); },
7114 "e":
function(x, p) {
return x.toExponential(p); },
7115 "f":
function(x, p) {
return x.toFixed(p); },
7116 "g":
function(x, p) {
return x.toPrecision(p); },
7117 "o":
function(x) {
return Math.round(x).toString(8); },
7118 "p":
function(x, p) {
return formatRounded(x * 100, p); },
7120 "s": formatPrefixAuto,
7121 "X":
function(x) {
return Math.round(x).toString(16).toUpperCase(); },
7122 "x":
function(x) {
return Math.round(x).toString(16); }
7125 function identity$3(x) {
7129 var prefixes = [
"y",
"z",
"a",
"f",
"p",
"n",
"\xB5",
"m",
"",
"k",
"M",
"G",
"T",
"P",
"E",
"Z",
"Y"];
7131 function formatLocale(locale) {
7132 var group = locale.grouping && locale.thousands ? formatGroup(locale.grouping, locale.thousands) : identity$3,
7133 currency = locale.currency,
7134 decimal = locale.decimal,
7135 numerals = locale.numerals ? formatNumerals(locale.numerals) : identity$3,
7136 percent = locale.percent ||
"%";
7138 function newFormat(specifier) {
7139 specifier = formatSpecifier(specifier);
7141 var fill = specifier.fill,
7142 align = specifier.align,
7143 sign = specifier.sign,
7144 symbol = specifier.symbol,
7145 zero = specifier.zero,
7146 width = specifier.width,
7147 comma = specifier.comma,
7148 precision = specifier.precision,
7149 trim = specifier.trim,
7150 type = specifier.type;
7153 if (type ===
"n") comma =
true, type =
"g";
7156 else if (!formatTypes[type]) precision == null && (precision = 12), trim =
true, type =
"g";
7159 if (zero || (fill ===
"0" && align ===
"=")) zero =
true, fill =
"0", align =
"=";
7163 var prefix = symbol ===
"$" ? currency[0] : symbol ===
"#" && /[boxX]/.test(type) ?
"0" + type.toLowerCase() :
"",
7164 suffix = symbol ===
"$" ? currency[1] : /[%p]/.test(type) ? percent :
"";
7169 var formatType = formatTypes[type],
7170 maybeSuffix = /[defgprs%]/.test(type);
7176 precision = precision == null ? 6
7177 : /[gprs]/.test(type) ? Math.max(1, Math.min(21, precision))
7178 : Math.max(0, Math.min(20, precision));
7180 function format(value) {
7181 var valuePrefix = prefix,
7182 valueSuffix = suffix,
7186 valueSuffix = formatType(value) + valueSuffix;
7192 var valueNegative = value < 0;
7193 value = formatType(Math.abs(value), precision);
7196 if (trim) value = formatTrim(value);
7199 if (valueNegative && +value === 0) valueNegative =
false;
7202 valuePrefix = (valueNegative ? (sign ===
"(" ? sign :
"-") : sign ===
"-" || sign ===
"(" ?
"" : sign) + valuePrefix;
7203 valueSuffix = (type ===
"s" ? prefixes[8 + prefixExponent / 3] :
"") + valueSuffix + (valueNegative && sign ===
"(" ?
")" :
"");
7208 i = -1, n = value.length;
7210 if (c = value.charCodeAt(i), 48 > c || c > 57) {
7211 valueSuffix = (c === 46 ? decimal + value.slice(i + 1) : value.slice(i)) + valueSuffix;
7212 value = value.slice(0, i);
7220 if (comma && !zero) value = group(value, Infinity);
7223 var length = valuePrefix.length + value.length + valueSuffix.length,
7224 padding = length < width ?
new Array(width - length + 1).join(fill) :
"";
7227 if (comma && zero) value = group(padding + value, padding.length ? width - valueSuffix.length : Infinity), padding =
"";
7231 case "<": value = valuePrefix + value + valueSuffix + padding;
break;
7232 case "=": value = valuePrefix + padding + value + valueSuffix;
break;
7233 case "^": value = padding.slice(0, length = padding.length >> 1) + valuePrefix + value + valueSuffix + padding.slice(length);
break;
7234 default: value = padding + valuePrefix + value + valueSuffix;
break;
7237 return numerals(value);
7240 format.toString =
function() {
7241 return specifier +
"";
7247 function formatPrefix(specifier, value) {
7248 var f = newFormat((specifier = formatSpecifier(specifier), specifier.type =
"f", specifier)),
7249 e = Math.max(-8, Math.min(8, Math.floor(exponent$1(value) / 3))) * 3,
7250 k = Math.pow(10, -e),
7251 prefix = prefixes[8 + e / 3];
7252 return function(value) {
7253 return f(k * value) + prefix;
7259 formatPrefix: formatPrefix
7272 function defaultLocale(definition) {
7273 locale = formatLocale(definition);
7274 exports.format = locale.format;
7275 exports.formatPrefix = locale.formatPrefix;
7279 function precisionFixed(step) {
7280 return Math.max(0, -exponent$1(Math.abs(step)));
7283 function precisionPrefix(step, value) {
7284 return Math.max(0, Math.max(-8, Math.min(8, Math.floor(exponent$1(value) / 3))) * 3 - exponent$1(Math.abs(step)));
7287 function precisionRound(step, max) {
7288 step = Math.abs(step), max = Math.abs(max) - step;
7289 return Math.max(0, exponent$1(max) - exponent$1(step)) + 1;
7314 add$1(temp, y, this.t);
7315 add$1(
this, temp.s, this.s);
7316 if (this.s) this.t += temp.t;
7317 else this.s = temp.t;
7319 valueOf:
function() {
7324 var temp =
new Adder;
7326 function add$1(adder, a, b) {
7327 var x = adder.s = a + b,
7330 adder.t = (a - av) + (b - bv);
7333 var epsilon$2 = 1e-6;
7334 var epsilon2$1 = 1e-12;
7336 var halfPi$2 = pi$3 / 2;
7337 var quarterPi = pi$3 / 4;
7338 var tau$3 = pi$3 * 2;
7340 var degrees$1 = 180 / pi$3;
7341 var radians = pi$3 / 180;
7344 var atan = Math.atan;
7345 var atan2 = Math.atan2;
7346 var cos$1 = Math.cos;
7347 var ceil = Math.ceil;
7351 var sin$1 = Math.sin;
7352 var sign = Math.sign ||
function(x) {
return x > 0 ? 1 : x < 0 ? -1 : 0; };
7353 var sqrt = Math.sqrt;
7357 return x > 1 ? 0 : x < -1 ? pi$3 : Math.acos(x);
7361 return x > 1 ? halfPi$2 : x < -1 ? -halfPi$2 : Math.asin(x);
7364 function haversin(x) {
7365 return (x = sin$1(x / 2)) * x;
7368 function noop$2() {}
7370 function streamGeometry(geometry, stream) {
7371 if (geometry && streamGeometryType.hasOwnProperty(geometry.type)) {
7372 streamGeometryType[geometry.type](geometry, stream);
7376 var streamObjectType = {
7377 Feature:
function(object, stream) {
7378 streamGeometry(
object.geometry, stream);
7380 FeatureCollection:
function(object, stream) {
7381 var features =
object.features, i = -1, n = features.length;
7382 while (++i < n) streamGeometry(features[i].geometry, stream);
7386 var streamGeometryType = {
7387 Sphere:
function(object, stream) {
7390 Point:
function(object, stream) {
7391 object =
object.coordinates;
7392 stream.point(
object[0],
object[1],
object[2]);
7394 MultiPoint:
function(object, stream) {
7395 var coordinates =
object.coordinates, i = -1, n = coordinates.length;
7396 while (++i < n)
object = coordinates[i], stream.point(
object[0],
object[1],
object[2]);
7398 LineString:
function(object, stream) {
7399 streamLine(
object.coordinates, stream, 0);
7401 MultiLineString:
function(object, stream) {
7402 var coordinates =
object.coordinates, i = -1, n = coordinates.length;
7403 while (++i < n) streamLine(coordinates[i], stream, 0);
7405 Polygon:
function(object, stream) {
7406 streamPolygon(
object.coordinates, stream);
7408 MultiPolygon:
function(object, stream) {
7409 var coordinates =
object.coordinates, i = -1, n = coordinates.length;
7410 while (++i < n) streamPolygon(coordinates[i], stream);
7412 GeometryCollection:
function(object, stream) {
7413 var geometries =
object.geometries, i = -1, n = geometries.length;
7414 while (++i < n) streamGeometry(geometries[i], stream);
7418 function streamLine(coordinates, stream, closed) {
7419 var i = -1, n = coordinates.length - closed, coordinate;
7421 while (++i < n) coordinate = coordinates[i], stream.point(coordinate[0], coordinate[1], coordinate[2]);
7425 function streamPolygon(coordinates, stream) {
7426 var i = -1, n = coordinates.length;
7427 stream.polygonStart();
7428 while (++i < n) streamLine(coordinates[i], stream, 1);
7429 stream.polygonEnd();
7432 function geoStream(
object, stream) {
7433 if (
object && streamObjectType.hasOwnProperty(
object.type)) {
7434 streamObjectType[
object.type](object, stream);
7436 streamGeometry(
object, stream);
7440 var areaRingSum = adder();
7442 var areaSum = adder(),
7453 polygonStart:
function() {
7454 areaRingSum.reset();
7455 areaStream.lineStart = areaRingStart;
7456 areaStream.lineEnd = areaRingEnd;
7458 polygonEnd:
function() {
7459 var areaRing = +areaRingSum;
7460 areaSum.add(areaRing < 0 ? tau$3 + areaRing : areaRing);
7461 this.lineStart = this.lineEnd = this.point = noop$2;
7463 sphere:
function() {
7468 function areaRingStart() {
7469 areaStream.point = areaPointFirst;
7472 function areaRingEnd() {
7473 areaPoint(lambda00, phi00);
7476 function areaPointFirst(lambda, phi) {
7477 areaStream.point = areaPoint;
7478 lambda00 = lambda, phi00 = phi;
7479 lambda *= radians, phi *= radians;
7480 lambda0 = lambda, cosPhi0 = cos$1(phi = phi / 2 + quarterPi), sinPhi0 = sin$1(phi);
7483 function areaPoint(lambda, phi) {
7484 lambda *= radians, phi *= radians;
7485 phi = phi / 2 + quarterPi;
7490 var dLambda = lambda - lambda0,
7491 sdLambda = dLambda >= 0 ? 1 : -1,
7492 adLambda = sdLambda * dLambda,
7493 cosPhi = cos$1(phi),
7494 sinPhi = sin$1(phi),
7495 k = sinPhi0 * sinPhi,
7496 u = cosPhi0 * cosPhi + k * cos$1(adLambda),
7497 v = k * sdLambda * sin$1(adLambda);
7498 areaRingSum.add(atan2(v, u));
7501 lambda0 = lambda, cosPhi0 = cosPhi, sinPhi0 = sinPhi;
7504 function area$1(object) {
7506 geoStream(
object, areaStream);
7510 function spherical(cartesian) {
7511 return [atan2(cartesian[1], cartesian[0]), asin(cartesian[2])];
7514 function cartesian(spherical) {
7515 var lambda = spherical[0], phi = spherical[1], cosPhi = cos$1(phi);
7516 return [cosPhi * cos$1(lambda), cosPhi * sin$1(lambda), sin$1(phi)];
7519 function cartesianDot(a, b) {
7520 return a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
7523 function cartesianCross(a, b) {
7524 return [a[1] * b[2] - a[2] * b[1], a[2] * b[0] - a[0] * b[2], a[0] * b[1] - a[1] * b[0]];
7528 function cartesianAddInPlace(a, b) {
7529 a[0] += b[0], a[1] += b[1], a[2] += b[2];
7532 function cartesianScale(vector, k) {
7533 return [vector[0] * k, vector[1] * k, vector[2] * k];
7537 function cartesianNormalizeInPlace(d) {
7538 var l = sqrt(d[0] * d[0] + d[1] * d[1] + d[2] * d[2]);
7539 d[0] /= l, d[1] /= l, d[2] /= l;
7542 var lambda0$1, phi0, lambda1, phi1,
7544 lambda00$1, phi00$1,
7550 var boundsStream = {
7552 lineStart: boundsLineStart,
7553 lineEnd: boundsLineEnd,
7554 polygonStart:
function() {
7555 boundsStream.point = boundsRingPoint;
7556 boundsStream.lineStart = boundsRingStart;
7557 boundsStream.lineEnd = boundsRingEnd;
7559 areaStream.polygonStart();
7561 polygonEnd:
function() {
7562 areaStream.polygonEnd();
7563 boundsStream.point = boundsPoint;
7564 boundsStream.lineStart = boundsLineStart;
7565 boundsStream.lineEnd = boundsLineEnd;
7566 if (areaRingSum < 0) lambda0$1 = -(lambda1 = 180), phi0 = -(phi1 = 90);
7567 else if (deltaSum > epsilon$2) phi1 = 90;
7568 else if (deltaSum < -epsilon$2) phi0 = -90;
7569 range[0] = lambda0$1, range[1] = lambda1;
7573 function boundsPoint(lambda, phi) {
7574 ranges.push(range = [lambda0$1 = lambda, lambda1 = lambda]);
7575 if (phi < phi0) phi0 = phi;
7576 if (phi > phi1) phi1 = phi;
7579 function linePoint(lambda, phi) {
7580 var p = cartesian([lambda * radians, phi * radians]);
7582 var normal = cartesianCross(p0, p),
7583 equatorial = [normal[1], -normal[0], 0],
7584 inflection = cartesianCross(equatorial, normal);
7585 cartesianNormalizeInPlace(inflection);
7586 inflection = spherical(inflection);
7587 var delta = lambda - lambda2,
7588 sign$$1 = delta > 0 ? 1 : -1,
7589 lambdai = inflection[0] * degrees$1 * sign$$1,
7591 antimeridian = abs(delta) > 180;
7592 if (antimeridian ^ (sign$$1 * lambda2 < lambdai && lambdai < sign$$1 * lambda)) {
7593 phii = inflection[1] * degrees$1;
7594 if (phii > phi1) phi1 = phii;
7595 }
else if (lambdai = (lambdai + 360) % 360 - 180, antimeridian ^ (sign$$1 * lambda2 < lambdai && lambdai < sign$$1 * lambda)) {
7596 phii = -inflection[1] * degrees$1;
7597 if (phii < phi0) phi0 = phii;
7599 if (phi < phi0) phi0 = phi;
7600 if (phi > phi1) phi1 = phi;
7603 if (lambda < lambda2) {
7604 if (angle(lambda0$1, lambda) > angle(lambda0$1, lambda1)) lambda1 = lambda;
7606 if (angle(lambda, lambda1) > angle(lambda0$1, lambda1)) lambda0$1 = lambda;
7609 if (lambda1 >= lambda0$1) {
7610 if (lambda < lambda0$1) lambda0$1 = lambda;
7611 if (lambda > lambda1) lambda1 = lambda;
7613 if (lambda > lambda2) {
7614 if (angle(lambda0$1, lambda) > angle(lambda0$1, lambda1)) lambda1 = lambda;
7616 if (angle(lambda, lambda1) > angle(lambda0$1, lambda1)) lambda0$1 = lambda;
7621 ranges.push(range = [lambda0$1 = lambda, lambda1 = lambda]);
7623 if (phi < phi0) phi0 = phi;
7624 if (phi > phi1) phi1 = phi;
7625 p0 = p, lambda2 = lambda;
7628 function boundsLineStart() {
7629 boundsStream.point = linePoint;
7632 function boundsLineEnd() {
7633 range[0] = lambda0$1, range[1] = lambda1;
7634 boundsStream.point = boundsPoint;
7638 function boundsRingPoint(lambda, phi) {
7640 var delta = lambda - lambda2;
7641 deltaSum.add(abs(delta) > 180 ? delta + (delta > 0 ? 360 : -360) : delta);
7643 lambda00$1 = lambda, phi00$1 = phi;
7645 areaStream.point(lambda, phi);
7646 linePoint(lambda, phi);
7649 function boundsRingStart() {
7650 areaStream.lineStart();
7653 function boundsRingEnd() {
7654 boundsRingPoint(lambda00$1, phi00$1);
7655 areaStream.lineEnd();
7656 if (abs(deltaSum) > epsilon$2) lambda0$1 = -(lambda1 = 180);
7657 range[0] = lambda0$1, range[1] = lambda1;
7664 function angle(lambda0, lambda1) {
7665 return (lambda1 -= lambda0) < 0 ? lambda1 + 360 : lambda1;
7668 function rangeCompare(a, b) {
7672 function rangeContains(range, x) {
7673 return range[0] <= range[1] ? range[0] <= x && x <= range[1] : x < range[0] || range[1] < x;
7676 function bounds(feature) {
7677 var i, n, a, b, merged, deltaMax, delta;
7679 phi1 = lambda1 = -(lambda0$1 = phi0 = Infinity);
7681 geoStream(feature, boundsStream);
7684 if (n = ranges.length) {
7685 ranges.sort(rangeCompare);
7688 for (i = 1, a = ranges[0], merged = [a]; i < n; ++i) {
7690 if (rangeContains(a, b[0]) || rangeContains(a, b[1])) {
7691 if (angle(a[0], b[1]) > angle(a[0], a[1])) a[1] = b[1];
7692 if (angle(b[0], a[1]) > angle(a[0], a[1])) a[0] = b[0];
7700 for (deltaMax = -Infinity, n = merged.length - 1, i = 0, a = merged[n]; i <= n; a = b, ++i) {
7702 if ((delta = angle(a[1], b[0])) > deltaMax) deltaMax = delta, lambda0$1 = b[0], lambda1 = a[1];
7706 ranges = range = null;
7708 return lambda0$1 === Infinity || phi0 === Infinity
7709 ? [[NaN, NaN], [NaN, NaN]]
7710 : [[lambda0$1, phi0], [lambda1, phi1]];
7717 lambda00$2, phi00$2,
7720 var centroidStream = {
7722 point: centroidPoint,
7723 lineStart: centroidLineStart,
7724 lineEnd: centroidLineEnd,
7725 polygonStart:
function() {
7726 centroidStream.lineStart = centroidRingStart;
7727 centroidStream.lineEnd = centroidRingEnd;
7729 polygonEnd:
function() {
7730 centroidStream.lineStart = centroidLineStart;
7731 centroidStream.lineEnd = centroidLineEnd;
7736 function centroidPoint(lambda, phi) {
7737 lambda *= radians, phi *= radians;
7738 var cosPhi = cos$1(phi);
7739 centroidPointCartesian(cosPhi * cos$1(lambda), cosPhi * sin$1(lambda), sin$1(phi));
7742 function centroidPointCartesian(x, y, z) {
7744 X0 += (x - X0) / W0;
7745 Y0 += (y - Y0) / W0;
7746 Z0 += (z - Z0) / W0;
7749 function centroidLineStart() {
7750 centroidStream.point = centroidLinePointFirst;
7753 function centroidLinePointFirst(lambda, phi) {
7754 lambda *= radians, phi *= radians;
7755 var cosPhi = cos$1(phi);
7756 x0 = cosPhi * cos$1(lambda);
7757 y0 = cosPhi * sin$1(lambda);
7759 centroidStream.point = centroidLinePoint;
7760 centroidPointCartesian(x0, y0, z0);
7763 function centroidLinePoint(lambda, phi) {
7764 lambda *= radians, phi *= radians;
7765 var cosPhi = cos$1(phi),
7766 x = cosPhi * cos$1(lambda),
7767 y = cosPhi * sin$1(lambda),
7769 w = atan2(sqrt((w = y0 * z - z0 * y) * w + (w = z0 * x - x0 * z) * w + (w = x0 * y - y0 * x) * w), x0 * x + y0 * y + z0 * z);
7771 X1 += w * (x0 + (x0 = x));
7772 Y1 += w * (y0 + (y0 = y));
7773 Z1 += w * (z0 + (z0 = z));
7774 centroidPointCartesian(x0, y0, z0);
7777 function centroidLineEnd() {
7778 centroidStream.point = centroidPoint;
7783 function centroidRingStart() {
7784 centroidStream.point = centroidRingPointFirst;
7787 function centroidRingEnd() {
7788 centroidRingPoint(lambda00$2, phi00$2);
7789 centroidStream.point = centroidPoint;
7792 function centroidRingPointFirst(lambda, phi) {
7793 lambda00$2 = lambda, phi00$2 = phi;
7794 lambda *= radians, phi *= radians;
7795 centroidStream.point = centroidRingPoint;
7796 var cosPhi = cos$1(phi);
7797 x0 = cosPhi * cos$1(lambda);
7798 y0 = cosPhi * sin$1(lambda);
7800 centroidPointCartesian(x0, y0, z0);
7803 function centroidRingPoint(lambda, phi) {
7804 lambda *= radians, phi *= radians;
7805 var cosPhi = cos$1(phi),
7806 x = cosPhi * cos$1(lambda),
7807 y = cosPhi * sin$1(lambda),
7809 cx = y0 * z - z0 * y,
7810 cy = z0 * x - x0 * z,
7811 cz = x0 * y - y0 * x,
7812 m = sqrt(cx * cx + cy * cy + cz * cz),
7819 X1 += w * (x0 + (x0 = x));
7820 Y1 += w * (y0 + (y0 = y));
7821 Z1 += w * (z0 + (z0 = z));
7822 centroidPointCartesian(x0, y0, z0);
7825 function centroid(
object) {
7830 geoStream(
object, centroidStream);
7835 m = x * x + y * y + z * z;
7838 if (m < epsilon2$1) {
7839 x = X1, y = Y1, z = Z1;
7841 if (W1 < epsilon$2) x = X0, y = Y0, z = Z0;
7842 m = x * x + y * y + z * z;
7844 if (m < epsilon2$1)
return [NaN, NaN];
7847 return [atan2(y, x) * degrees$1, asin(z / sqrt(m)) * degrees$1];
7850 function constant$8(x) {
7856 function compose(a, b) {
7858 function compose(x, y) {
7859 return x = a(x, y), b(x[0], x[1]);
7862 if (a.invert && b.invert) compose.invert =
function(x, y) {
7863 return x = b.invert(x, y), x && a.invert(x[0], x[1]);
7869 function rotationIdentity(lambda, phi) {
7870 return [lambda > pi$3 ? lambda - tau$3 : lambda < -pi$3 ? lambda + tau$3 : lambda, phi];
7873 rotationIdentity.invert = rotationIdentity;
7875 function rotateRadians(deltaLambda, deltaPhi, deltaGamma) {
7876 return (deltaLambda %= tau$3) ? (deltaPhi || deltaGamma ? compose(rotationLambda(deltaLambda), rotationPhiGamma(deltaPhi, deltaGamma))
7877 : rotationLambda(deltaLambda))
7878 : (deltaPhi || deltaGamma ? rotationPhiGamma(deltaPhi, deltaGamma)
7879 : rotationIdentity);
7882 function forwardRotationLambda(deltaLambda) {
7883 return function(lambda, phi) {
7884 return lambda += deltaLambda, [lambda > pi$3 ? lambda - tau$3 : lambda < -pi$3 ? lambda + tau$3 : lambda, phi];
7888 function rotationLambda(deltaLambda) {
7889 var rotation = forwardRotationLambda(deltaLambda);
7890 rotation.invert = forwardRotationLambda(-deltaLambda);
7894 function rotationPhiGamma(deltaPhi, deltaGamma) {
7895 var cosDeltaPhi = cos$1(deltaPhi),
7896 sinDeltaPhi = sin$1(deltaPhi),
7897 cosDeltaGamma = cos$1(deltaGamma),
7898 sinDeltaGamma = sin$1(deltaGamma);
7900 function rotation(lambda, phi) {
7901 var cosPhi = cos$1(phi),
7902 x = cos$1(lambda) * cosPhi,
7903 y = sin$1(lambda) * cosPhi,
7905 k = z * cosDeltaPhi + x * sinDeltaPhi;
7907 atan2(y * cosDeltaGamma - k * sinDeltaGamma, x * cosDeltaPhi - z * sinDeltaPhi),
7908 asin(k * cosDeltaGamma + y * sinDeltaGamma)
7912 rotation.invert =
function(lambda, phi) {
7913 var cosPhi = cos$1(phi),
7914 x = cos$1(lambda) * cosPhi,
7915 y = sin$1(lambda) * cosPhi,
7917 k = z * cosDeltaGamma - y * sinDeltaGamma;
7919 atan2(y * cosDeltaGamma + z * sinDeltaGamma, x * cosDeltaPhi + k * sinDeltaPhi),
7920 asin(k * cosDeltaPhi - x * sinDeltaPhi)
7927 function rotation(rotate) {
7928 rotate = rotateRadians(rotate[0] * radians, rotate[1] * radians, rotate.length > 2 ? rotate[2] * radians : 0);
7930 function forward(coordinates) {
7931 coordinates = rotate(coordinates[0] * radians, coordinates[1] * radians);
7932 return coordinates[0] *= degrees$1, coordinates[1] *= degrees$1, coordinates;
7935 forward.invert =
function(coordinates) {
7936 coordinates = rotate.invert(coordinates[0] * radians, coordinates[1] * radians);
7937 return coordinates[0] *= degrees$1, coordinates[1] *= degrees$1, coordinates;
7944 function circleStream(stream, radius, delta, direction, t0, t1) {
7946 var cosRadius = cos$1(radius),
7947 sinRadius = sin$1(radius),
7948 step = direction * delta;
7950 t0 = radius + direction * tau$3;
7951 t1 = radius - step / 2;
7953 t0 = circleRadius(cosRadius, t0);
7954 t1 = circleRadius(cosRadius, t1);
7955 if (direction > 0 ? t0 < t1 : t0 > t1) t0 += direction * tau$3;
7957 for (var point, t = t0; direction > 0 ? t > t1 : t < t1; t -= step) {
7958 point = spherical([cosRadius, -sinRadius * cos$1(t), -sinRadius * sin$1(t)]);
7959 stream.point(point[0], point[1]);
7964 function circleRadius(cosRadius, point) {
7965 point = cartesian(point), point[0] -= cosRadius;
7966 cartesianNormalizeInPlace(point);
7967 var radius = acos(-point[1]);
7968 return ((-point[2] < 0 ? -radius : radius) + tau$3 - epsilon$2) % tau$3;
7972 var center = constant$8([0, 0]),
7973 radius = constant$8(90),
7974 precision = constant$8(6),
7977 stream = {point: point};
7979 function point(x, y) {
7980 ring.push(x = rotate(x, y));
7981 x[0] *= degrees$1, x[1] *= degrees$1;
7985 var c = center.apply(
this, arguments),
7986 r = radius.apply(
this, arguments) * radians,
7987 p = precision.apply(
this, arguments) * radians;
7989 rotate = rotateRadians(-c[0] * radians, -c[1] * radians, 0).invert;
7990 circleStream(stream, r, p, 1);
7991 c = {type:
"Polygon", coordinates: [ring]};
7992 ring = rotate = null;
7996 circle.center =
function(_) {
7997 return arguments.length ? (center = typeof _ ===
"function" ? _ : constant$8([+_[0], +_[1]]), circle) : center;
8000 circle.radius =
function(_) {
8001 return arguments.length ? (radius = typeof _ ===
"function" ? _ : constant$8(+_), circle) : radius;
8004 circle.precision =
function(_) {
8005 return arguments.length ? (precision = typeof _ ===
"function" ? _ : constant$8(+_), circle) : precision;
8011 function clipBuffer() {
8015 point:
function(x, y) {
8018 lineStart:
function() {
8019 lines.push(line = []);
8022 rejoin:
function() {
8023 if (lines.length > 1) lines.push(lines.pop().concat(lines.shift()));
8025 result:
function() {
8034 function pointEqual(a, b) {
8035 return abs(a[0] - b[0]) < epsilon$2 && abs(a[1] - b[1]) < epsilon$2;
8038 function Intersection(point, points, other, entry) {
8044 this.n = this.p = null;
8050 function clipRejoin(segments, compareIntersection, startInside, interpolate, stream) {
8056 segments.forEach(
function(segment) {
8057 if ((n = segment.length - 1) <= 0)
return;
8058 var n, p0 = segment[0], p1 = segment[n], x;
8063 if (pointEqual(p0, p1)) {
8065 for (i = 0; i < n; ++i) stream.point((p0 = segment[i])[0], p0[1]);
8070 subject.push(x =
new Intersection(p0, segment, null,
true));
8071 clip.push(x.o =
new Intersection(p0, null, x,
false));
8072 subject.push(x =
new Intersection(p1, segment, null,
false));
8073 clip.push(x.o =
new Intersection(p1, null, x,
true));
8076 if (!subject.length)
return;
8078 clip.sort(compareIntersection);
8082 for (i = 0, n = clip.length; i < n; ++i) {
8083 clip[i].e = startInside = !startInside;
8086 var start = subject[0],
8092 var current = start,
8094 while (current.v)
if ((current = current.n) === start)
return;
8098 current.v = current.o.v =
true;
8101 for (i = 0, n = points.length; i < n; ++i) stream.point((point = points[i])[0], point[1]);
8103 interpolate(current.x, current.n.x, 1, stream);
8105 current = current.n;
8108 points = current.p.z;
8109 for (i = points.length - 1; i >= 0; --i) stream.point((point = points[i])[0], point[1]);
8111 interpolate(current.x, current.p.x, -1, stream);
8113 current = current.p;
8115 current = current.o;
8117 isSubject = !isSubject;
8118 }
while (!current.v);
8123 function link$1(array) {
8124 if (!(n = array.length))
return;
8138 var sum$1 = adder();
8140 function polygonContains(polygon, point) {
8141 var lambda = point[0],
8143 sinPhi = sin$1(phi),
8144 normal = [sin$1(lambda), -cos$1(lambda), 0],
8150 if (sinPhi === 1) phi = halfPi$2 + epsilon$2;
8151 else if (sinPhi === -1) phi = -halfPi$2 - epsilon$2;
8153 for (var i = 0, n = polygon.length; i < n; ++i) {
8154 if (!(m = (ring = polygon[i]).length))
continue;
8157 point0 = ring[m - 1],
8158 lambda0 = point0[0],
8159 phi0 = point0[1] / 2 + quarterPi,
8160 sinPhi0 = sin$1(phi0),
8161 cosPhi0 = cos$1(phi0);
8163 for (var j = 0; j < m; ++j, lambda0 = lambda1, sinPhi0 = sinPhi1, cosPhi0 = cosPhi1, point0 = point1) {
8164 var point1 = ring[j],
8165 lambda1 = point1[0],
8166 phi1 = point1[1] / 2 + quarterPi,
8167 sinPhi1 = sin$1(phi1),
8168 cosPhi1 = cos$1(phi1),
8169 delta = lambda1 - lambda0,
8170 sign$$1 = delta >= 0 ? 1 : -1,
8171 absDelta = sign$$1 * delta,
8172 antimeridian = absDelta > pi$3,
8173 k = sinPhi0 * sinPhi1;
8175 sum$1.add(atan2(k * sign$$1 * sin$1(absDelta), cosPhi0 * cosPhi1 + k * cos$1(absDelta)));
8176 angle += antimeridian ? delta + sign$$1 * tau$3 : delta;
8180 if (antimeridian ^ lambda0 >= lambda ^ lambda1 >= lambda) {
8181 var arc = cartesianCross(cartesian(point0), cartesian(point1));
8182 cartesianNormalizeInPlace(arc);
8183 var intersection = cartesianCross(normal, arc);
8184 cartesianNormalizeInPlace(intersection);
8185 var phiArc = (antimeridian ^ delta >= 0 ? -1 : 1) * asin(intersection[2]);
8186 if (phi > phiArc || phi === phiArc && (arc[0] || arc[1])) {
8187 winding += antimeridian ^ delta >= 0 ? 1 : -1;
8204 return (angle < -epsilon$2 || angle < epsilon$2 && sum$1 < -epsilon$2) ^ (winding & 1);
8207 function clip(pointVisible, clipLine, interpolate, start) {
8208 return function(sink) {
8209 var line = clipLine(sink),
8210 ringBuffer = clipBuffer(),
8211 ringSink = clipLine(ringBuffer),
8212 polygonStarted =
false,
8219 lineStart: lineStart,
8221 polygonStart:
function() {
8222 clip.point = pointRing;
8223 clip.lineStart = ringStart;
8224 clip.lineEnd = ringEnd;
8228 polygonEnd:
function() {
8230 clip.lineStart = lineStart;
8231 clip.lineEnd = lineEnd;
8232 segments = merge(segments);
8233 var startInside = polygonContains(polygon, start);
8234 if (segments.length) {
8235 if (!polygonStarted) sink.polygonStart(), polygonStarted =
true;
8236 clipRejoin(segments, compareIntersection, startInside, interpolate, sink);
8237 }
else if (startInside) {
8238 if (!polygonStarted) sink.polygonStart(), polygonStarted =
true;
8240 interpolate(null, null, 1, sink);
8243 if (polygonStarted) sink.polygonEnd(), polygonStarted =
false;
8244 segments = polygon = null;
8246 sphere:
function() {
8247 sink.polygonStart();
8249 interpolate(null, null, 1, sink);
8255 function point(lambda, phi) {
8256 if (pointVisible(lambda, phi)) sink.point(lambda, phi);
8259 function pointLine(lambda, phi) {
8260 line.point(lambda, phi);
8263 function lineStart() {
8264 clip.point = pointLine;
8268 function lineEnd() {
8273 function pointRing(lambda, phi) {
8274 ring.push([lambda, phi]);
8275 ringSink.point(lambda, phi);
8278 function ringStart() {
8279 ringSink.lineStart();
8283 function ringEnd() {
8284 pointRing(ring[0][0], ring[0][1]);
8287 var clean = ringSink.clean(),
8288 ringSegments = ringBuffer.result(),
8289 i, n = ringSegments.length, m,
8301 segment = ringSegments[0];
8302 if ((m = segment.length - 1) > 0) {
8303 if (!polygonStarted) sink.polygonStart(), polygonStarted =
true;
8305 for (i = 0; i < m; ++i) sink.point((point = segment[i])[0], point[1]);
8313 if (n > 1 && clean & 2) ringSegments.push(ringSegments.pop().concat(ringSegments.shift()));
8315 segments.push(ringSegments.filter(validSegment));
8322 function validSegment(segment) {
8323 return segment.length > 1;
8328 function compareIntersection(a, b) {
8329 return ((a = a.x)[0] < 0 ? a[1] - halfPi$2 - epsilon$2 : halfPi$2 - a[1])
8330 - ((b = b.x)[0] < 0 ? b[1] - halfPi$2 - epsilon$2 : halfPi$2 - b[1]);
8333 var clipAntimeridian = clip(
8334 function() {
return true; },
8335 clipAntimeridianLine,
8336 clipAntimeridianInterpolate,
8343 function clipAntimeridianLine(stream) {
8350 lineStart:
function() {
8354 point:
function(lambda1, phi1) {
8355 var sign1 = lambda1 > 0 ? pi$3 : -pi$3,
8356 delta = abs(lambda1 - lambda0);
8357 if (abs(delta - pi$3) < epsilon$2) {
8358 stream.point(lambda0, phi0 = (phi0 + phi1) / 2 > 0 ? halfPi$2 : -halfPi$2);
8359 stream.point(sign0, phi0);
8362 stream.point(sign1, phi0);
8363 stream.point(lambda1, phi0);
8365 }
else if (sign0 !== sign1 && delta >= pi$3) {
8366 if (abs(lambda0 - sign0) < epsilon$2) lambda0 -= sign0 * epsilon$2;
8367 if (abs(lambda1 - sign1) < epsilon$2) lambda1 -= sign1 * epsilon$2;
8368 phi0 = clipAntimeridianIntersect(lambda0, phi0, lambda1, phi1);
8369 stream.point(sign0, phi0);
8372 stream.point(sign1, phi0);
8375 stream.point(lambda0 = lambda1, phi0 = phi1);
8378 lineEnd:
function() {
8380 lambda0 = phi0 = NaN;
8388 function clipAntimeridianIntersect(lambda0, phi0, lambda1, phi1) {
8391 sinLambda0Lambda1 = sin$1(lambda0 - lambda1);
8392 return abs(sinLambda0Lambda1) > epsilon$2
8393 ? atan((sin$1(phi0) * (cosPhi1 = cos$1(phi1)) * sin$1(lambda1)
8394 - sin$1(phi1) * (cosPhi0 = cos$1(phi0)) * sin$1(lambda0))
8395 / (cosPhi0 * cosPhi1 * sinLambda0Lambda1))
8396 : (phi0 + phi1) / 2;
8399 function clipAntimeridianInterpolate(from, to, direction, stream) {
8402 phi = direction * halfPi$2;
8403 stream.point(-pi$3, phi);
8404 stream.point(0, phi);
8405 stream.point(pi$3, phi);
8406 stream.point(pi$3, 0);
8407 stream.point(pi$3, -phi);
8408 stream.point(0, -phi);
8409 stream.point(-pi$3, -phi);
8410 stream.point(-pi$3, 0);
8411 stream.point(-pi$3, phi);
8412 }
else if (abs(from[0] - to[0]) > epsilon$2) {
8413 var lambda = from[0] < to[0] ? pi$3 : -pi$3;
8414 phi = direction * lambda / 2;
8415 stream.point(-lambda, phi);
8416 stream.point(0, phi);
8417 stream.point(lambda, phi);
8419 stream.point(to[0], to[1]);
8423 function clipCircle(radius) {
8424 var cr = cos$1(radius),
8425 delta = 6 * radians,
8426 smallRadius = cr > 0,
8427 notHemisphere = abs(cr) > epsilon$2;
8429 function interpolate(from, to, direction, stream) {
8430 circleStream(stream, radius, delta, direction, from, to);
8433 function visible(lambda, phi) {
8434 return cos$1(lambda) * cos$1(phi) > cr;
8441 function clipLine(stream) {
8448 lineStart:
function() {
8452 point:
function(lambda, phi) {
8453 var point1 = [lambda, phi],
8455 v = visible(lambda, phi),
8457 ? v ? 0 : code(lambda, phi)
8458 : v ? code(lambda + (lambda < 0 ? pi$3 : -pi$3), phi) : 0;
8459 if (!point0 && (v00 = v0 = v)) stream.lineStart();
8463 point2 = intersect(point0, point1);
8464 if (!point2 || pointEqual(point0, point2) || pointEqual(point1, point2)) {
8465 point1[0] += epsilon$2;
8466 point1[1] += epsilon$2;
8467 v = visible(point1[0], point1[1]);
8475 point2 = intersect(point1, point0);
8476 stream.point(point2[0], point2[1]);
8479 point2 = intersect(point0, point1);
8480 stream.point(point2[0], point2[1]);
8484 }
else if (notHemisphere && point0 && smallRadius ^ v) {
8488 if (!(c & c0) && (t = intersect(point1, point0,
true))) {
8492 stream.point(t[0][0], t[0][1]);
8493 stream.point(t[1][0], t[1][1]);
8496 stream.point(t[1][0], t[1][1]);
8499 stream.point(t[0][0], t[0][1]);
8503 if (v && (!point0 || !pointEqual(point0, point1))) {
8504 stream.point(point1[0], point1[1]);
8506 point0 = point1, v0 = v, c0 = c;
8508 lineEnd:
function() {
8509 if (v0) stream.lineEnd();
8515 return clean | ((v00 && v0) << 1);
8521 function intersect(a, b, two) {
8522 var pa = cartesian(a),
8528 n2 = cartesianCross(pa, pb),
8529 n2n2 = cartesianDot(n2, n2),
8531 determinant = n2n2 - n1n2 * n1n2;
8534 if (!determinant)
return !two && a;
8536 var c1 = cr * n2n2 / determinant,
8537 c2 = -cr * n1n2 / determinant,
8538 n1xn2 = cartesianCross(n1, n2),
8539 A = cartesianScale(n1, c1),
8540 B = cartesianScale(n2, c2);
8541 cartesianAddInPlace(A, B);
8545 w = cartesianDot(A, u),
8546 uu = cartesianDot(u, u),
8547 t2 = w * w - uu * (cartesianDot(A, A) - 1);
8552 q = cartesianScale(u, (-w - t) / uu);
8553 cartesianAddInPlace(q, A);
8565 if (lambda1 < lambda0) z = lambda0, lambda0 = lambda1, lambda1 = z;
8567 var delta = lambda1 - lambda0,
8568 polar = abs(delta - pi$3) < epsilon$2,
8569 meridian = polar || delta < epsilon$2;
8571 if (!polar && phi1 < phi0) z = phi0, phi0 = phi1, phi1 = z;
8576 ? phi0 + phi1 > 0 ^ q[1] < (abs(q[0] - lambda0) < epsilon$2 ? phi0 : phi1)
8577 : phi0 <= q[1] && q[1] <= phi1
8578 : delta > pi$3 ^ (lambda0 <= q[0] && q[0] <= lambda1)) {
8579 var q1 = cartesianScale(u, (-w + t) / uu);
8580 cartesianAddInPlace(q1, A);
8581 return [q, spherical(q1)];
8587 function code(lambda, phi) {
8588 var r = smallRadius ? radius : pi$3 - radius,
8590 if (lambda < -r) code |= 1;
8591 else if (lambda > r) code |= 2;
8592 if (phi < -r) code |= 4;
8593 else if (phi > r) code |= 8;
8597 return clip(visible, clipLine, interpolate, smallRadius ? [0, -radius] : [-pi$3, radius - pi$3]);
8600 function clipLine(a, b, x0, y0, x1, y1) {
8612 if (!dx && r > 0)
return;
8617 }
else if (dx > 0) {
8623 if (!dx && r < 0)
return;
8628 }
else if (dx > 0) {
8634 if (!dy && r > 0)
return;
8639 }
else if (dy > 0) {
8645 if (!dy && r < 0)
return;
8650 }
else if (dy > 0) {
8655 if (t0 > 0) a[0] = ax + t0 * dx, a[1] = ay + t0 * dy;
8656 if (t1 < 1) b[0] = ax + t1 * dx, b[1] = ay + t1 * dy;
8660 var clipMax = 1e9, clipMin = -clipMax;
8665 function clipRectangle(x0, y0, x1, y1) {
8667 function visible(x, y) {
8668 return x0 <= x && x <= x1 && y0 <= y && y <= y1;
8671 function interpolate(from, to, direction, stream) {
8674 || (a = corner(from, direction)) !== (a1 = corner(to, direction))
8675 || comparePoint(from, to) < 0 ^ direction > 0) {
8676 do stream.point(a === 0 || a === 3 ? x0 : x1, a > 1 ? y1 : y0);
8677 while ((a = (a + direction + 4) % 4) !== a1);
8679 stream.point(to[0], to[1]);
8683 function corner(p, direction) {
8684 return abs(p[0] - x0) < epsilon$2 ? direction > 0 ? 0 : 3
8685 : abs(p[0] - x1) < epsilon$2 ? direction > 0 ? 2 : 1
8686 : abs(p[1] - y0) < epsilon$2 ? direction > 0 ? 1 : 0
8687 : direction > 0 ? 3 : 2;
8690 function compareIntersection(a, b) {
8691 return comparePoint(a.x, b.x);
8694 function comparePoint(a, b) {
8695 var ca = corner(a, 1),
8697 return ca !== cb ? ca - cb
8698 : ca === 0 ? b[1] - a[1]
8699 : ca === 1 ? a[0] - b[0]
8700 : ca === 2 ? a[1] - b[1]
8704 return function(stream) {
8705 var activeStream = stream,
8706 bufferStream = clipBuffer(),
8717 lineStart: lineStart,
8719 polygonStart: polygonStart,
8720 polygonEnd: polygonEnd
8723 function point(x, y) {
8724 if (visible(x, y)) activeStream.point(x, y);
8727 function polygonInside() {
8730 for (var i = 0, n = polygon.length; i < n; ++i) {
8731 for (var ring = polygon[i], j = 1, m = ring.length, point = ring[0], a0, a1, b0 = point[0], b1 = point[1]; j < m; ++j) {
8732 a0 = b0, a1 = b1, point = ring[j], b0 = point[0], b1 = point[1];
8733 if (a1 <= y1) {
if (b1 > y1 && (b0 - a0) * (y1 - a1) > (b1 - a1) * (x0 - a0)) ++winding; }
8734 else {
if (b1 <= y1 && (b0 - a0) * (y1 - a1) < (b1 - a1) * (x0 - a0)) --winding; }
8742 function polygonStart() {
8743 activeStream = bufferStream, segments = [], polygon = [], clean =
true;
8746 function polygonEnd() {
8747 var startInside = polygonInside(),
8748 cleanInside = clean && startInside,
8749 visible = (segments = merge(segments)).length;
8750 if (cleanInside || visible) {
8751 stream.polygonStart();
8754 interpolate(null, null, 1, stream);
8758 clipRejoin(segments, compareIntersection, startInside, interpolate, stream);
8760 stream.polygonEnd();
8762 activeStream = stream, segments = polygon = ring = null;
8765 function lineStart() {
8766 clipStream.point = linePoint;
8767 if (polygon) polygon.push(ring = []);
8776 function lineEnd() {
8778 linePoint(x__, y__);
8779 if (v__ && v_) bufferStream.rejoin();
8780 segments.push(bufferStream.result());
8782 clipStream.point = point;
8783 if (v_) activeStream.lineEnd();
8786 function linePoint(x, y) {
8787 var v = visible(x, y);
8788 if (polygon) ring.push([x, y]);
8790 x__ = x, y__ = y, v__ = v;
8793 activeStream.lineStart();
8794 activeStream.point(x, y);
8797 if (v && v_) activeStream.point(x, y);
8799 var a = [x_ = Math.max(clipMin, Math.min(clipMax, x_)), y_ = Math.max(clipMin, Math.min(clipMax, y_))],
8800 b = [x = Math.max(clipMin, Math.min(clipMax, x)), y = Math.max(clipMin, Math.min(clipMax, y))];
8801 if (clipLine(a, b, x0, y0, x1, y1)) {
8803 activeStream.lineStart();
8804 activeStream.point(a[0], a[1]);
8806 activeStream.point(b[0], b[1]);
8807 if (!v) activeStream.lineEnd();
8810 activeStream.lineStart();
8811 activeStream.point(x, y);
8816 x_ = x, y_ = y, v_ = v;
8823 function extent$1() {
8833 stream:
function(stream) {
8834 return cache && cacheStream === stream ? cache : cache = clipRectangle(x0, y0, x1, y1)(cacheStream = stream);
8836 extent:
function(_) {
8837 return arguments.length ? (x0 = +_[0][0], y0 = +_[0][1], x1 = +_[1][0], y1 = +_[1][1], cache = cacheStream = null, clip) : [[x0, y0], [x1, y1]];
8842 var lengthSum = adder(),
8847 var lengthStream = {
8850 lineStart: lengthLineStart,
8852 polygonStart: noop$2,
8856 function lengthLineStart() {
8857 lengthStream.point = lengthPointFirst;
8858 lengthStream.lineEnd = lengthLineEnd;
8861 function lengthLineEnd() {
8862 lengthStream.point = lengthStream.lineEnd = noop$2;
8865 function lengthPointFirst(lambda, phi) {
8866 lambda *= radians, phi *= radians;
8867 lambda0$2 = lambda, sinPhi0$1 = sin$1(phi), cosPhi0$1 = cos$1(phi);
8868 lengthStream.point = lengthPoint;
8871 function lengthPoint(lambda, phi) {
8872 lambda *= radians, phi *= radians;
8873 var sinPhi = sin$1(phi),
8874 cosPhi = cos$1(phi),
8875 delta = abs(lambda - lambda0$2),
8876 cosDelta = cos$1(delta),
8877 sinDelta = sin$1(delta),
8878 x = cosPhi * sinDelta,
8879 y = cosPhi0$1 * sinPhi - sinPhi0$1 * cosPhi * cosDelta,
8880 z = sinPhi0$1 * sinPhi + cosPhi0$1 * cosPhi * cosDelta;
8881 lengthSum.add(atan2(sqrt(x * x + y * y), z));
8882 lambda0$2 = lambda, sinPhi0$1 = sinPhi, cosPhi0$1 = cosPhi;
8885 function length$1(object) {
8887 geoStream(
object, lengthStream);
8891 var coordinates = [null, null],
8892 object$1 = {type:
"LineString", coordinates: coordinates};
8894 function distance(a, b) {
8897 return length$1(
object$1);
8900 var containsObjectType = {
8901 Feature:
function(object, point) {
8902 return containsGeometry(
object.geometry, point);
8904 FeatureCollection:
function(object, point) {
8905 var features =
object.features, i = -1, n = features.length;
8906 while (++i < n)
if (containsGeometry(features[i].geometry, point))
return true;
8911 var containsGeometryType = {
8912 Sphere:
function() {
8915 Point:
function(object, point) {
8916 return containsPoint(
object.coordinates, point);
8918 MultiPoint:
function(object, point) {
8919 var coordinates =
object.coordinates, i = -1, n = coordinates.length;
8920 while (++i < n)
if (containsPoint(coordinates[i], point))
return true;
8923 LineString:
function(object, point) {
8924 return containsLine(
object.coordinates, point);
8926 MultiLineString:
function(object, point) {
8927 var coordinates =
object.coordinates, i = -1, n = coordinates.length;
8928 while (++i < n)
if (containsLine(coordinates[i], point))
return true;
8931 Polygon:
function(object, point) {
8932 return containsPolygon(
object.coordinates, point);
8934 MultiPolygon:
function(object, point) {
8935 var coordinates =
object.coordinates, i = -1, n = coordinates.length;
8936 while (++i < n)
if (containsPolygon(coordinates[i], point))
return true;
8939 GeometryCollection:
function(object, point) {
8940 var geometries =
object.geometries, i = -1, n = geometries.length;
8941 while (++i < n)
if (containsGeometry(geometries[i], point))
return true;
8946 function containsGeometry(geometry, point) {
8947 return geometry && containsGeometryType.hasOwnProperty(geometry.type)
8948 ? containsGeometryType[geometry.type](geometry, point)
8952 function containsPoint(coordinates, point) {
8953 return distance(coordinates, point) === 0;
8956 function containsLine(coordinates, point) {
8957 var ab = distance(coordinates[0], coordinates[1]),
8958 ao = distance(coordinates[0], point),
8959 ob = distance(point, coordinates[1]);
8960 return ao + ob <= ab + epsilon$2;
8963 function containsPolygon(coordinates, point) {
8964 return !!polygonContains(coordinates.map(ringRadians), pointRadians(point));
8967 function ringRadians(ring) {
8968 return ring = ring.map(pointRadians), ring.pop(), ring;
8971 function pointRadians(point) {
8972 return [point[0] * radians, point[1] * radians];
8975 function contains$1(object, point) {
8976 return (
object && containsObjectType.hasOwnProperty(
object.type)
8977 ? containsObjectType[
object.type]
8978 : containsGeometry)(
object, point);
8981 function graticuleX(y0, y1, dy) {
8982 var y = sequence(y0, y1 - epsilon$2, dy).concat(y1);
8983 return function(x) {
return y.map(
function(y) {
return [x, y]; }); };
8986 function graticuleY(x0, x1, dx) {
8987 var x = sequence(x0, x1 - epsilon$2, dx).concat(x1);
8988 return function(y) {
return x.map(
function(x) {
return [x, y]; }); };
8991 function graticule() {
8994 dx = 10, dy = dx, DX = 90, DY = 360,
8998 function graticule() {
8999 return {type:
"MultiLineString", coordinates: lines()};
9003 return sequence(ceil(X0 / DX) * DX, X1, DX).map(X)
9004 .concat(sequence(ceil(Y0 / DY) * DY, Y1, DY).map(Y))
9005 .concat(sequence(ceil(x0 / dx) * dx, x1, dx).filter(
function(x) {
return abs(x % DX) > epsilon$2; }).map(x))
9006 .concat(sequence(ceil(y0 / dy) * dy, y1, dy).filter(
function(y) {
return abs(y % DY) > epsilon$2; }).map(y));
9009 graticule.lines =
function() {
9010 return lines().map(
function(coordinates) {
return {type:
"LineString", coordinates: coordinates}; });
9013 graticule.outline =
function() {
9019 X(X1).reverse().slice(1),
9020 Y(Y0).reverse().slice(1))
9025 graticule.extent =
function(_) {
9026 if (!arguments.length)
return graticule.extentMinor();
9027 return graticule.extentMajor(_).extentMinor(_);
9030 graticule.extentMajor =
function(_) {
9031 if (!arguments.length)
return [[X0, Y0], [X1, Y1]];
9032 X0 = +_[0][0], X1 = +_[1][0];
9033 Y0 = +_[0][1], Y1 = +_[1][1];
9034 if (X0 > X1) _ = X0, X0 = X1, X1 = _;
9035 if (Y0 > Y1) _ = Y0, Y0 = Y1, Y1 = _;
9036 return graticule.precision(precision);
9039 graticule.extentMinor =
function(_) {
9040 if (!arguments.length)
return [[x0, y0], [x1, y1]];
9041 x0 = +_[0][0], x1 = +_[1][0];
9042 y0 = +_[0][1], y1 = +_[1][1];
9043 if (x0 > x1) _ = x0, x0 = x1, x1 = _;
9044 if (y0 > y1) _ = y0, y0 = y1, y1 = _;
9045 return graticule.precision(precision);
9048 graticule.step =
function(_) {
9049 if (!arguments.length)
return graticule.stepMinor();
9050 return graticule.stepMajor(_).stepMinor(_);
9053 graticule.stepMajor =
function(_) {
9054 if (!arguments.length)
return [DX, DY];
9055 DX = +_[0], DY = +_[1];
9059 graticule.stepMinor =
function(_) {
9060 if (!arguments.length)
return [dx, dy];
9061 dx = +_[0], dy = +_[1];
9065 graticule.precision =
function(_) {
9066 if (!arguments.length)
return precision;
9068 x = graticuleX(y0, y1, 90);
9069 y = graticuleY(x0, x1, precision);
9070 X = graticuleX(Y0, Y1, 90);
9071 Y = graticuleY(X0, X1, precision);
9076 .extentMajor([[-180, -90 + epsilon$2], [180, 90 - epsilon$2]])
9077 .extentMinor([[-180, -80 - epsilon$2], [180, 80 + epsilon$2]]);
9080 function graticule10() {
9081 return graticule()();
9084 function interpolate$1(a, b) {
9085 var x0 = a[0] * radians,
9086 y0 = a[1] * radians,
9087 x1 = b[0] * radians,
9088 y1 = b[1] * radians,
9093 kx0 = cy0 * cos$1(x0),
9094 ky0 = cy0 * sin$1(x0),
9095 kx1 = cy1 * cos$1(x1),
9096 ky1 = cy1 * sin$1(x1),
9097 d = 2 * asin(sqrt(haversin(y1 - y0) + cy0 * cy1 * haversin(x1 - x0))),
9100 var interpolate = d ?
function(t) {
9101 var B = sin$1(t *= d) / k,
9102 A = sin$1(d - t) / k,
9103 x = A * kx0 + B * kx1,
9104 y = A * ky0 + B * ky1,
9105 z = A * sy0 + B * sy1;
9107 atan2(y, x) * degrees$1,
9108 atan2(z, sqrt(x * x + y * y)) * degrees$1
9111 return [x0 * degrees$1, y0 * degrees$1];
9114 interpolate.distance = d;
9119 function identity$4(x) {
9123 var areaSum$1 = adder(),
9124 areaRingSum$1 = adder(),
9130 var areaStream$1 = {
9134 polygonStart:
function() {
9135 areaStream$1.lineStart = areaRingStart$1;
9136 areaStream$1.lineEnd = areaRingEnd$1;
9138 polygonEnd:
function() {
9139 areaStream$1.lineStart = areaStream$1.lineEnd = areaStream$1.point = noop$2;
9140 areaSum$1.add(abs(areaRingSum$1));
9141 areaRingSum$1.reset();
9143 result:
function() {
9144 var area = areaSum$1 / 2;
9150 function areaRingStart$1() {
9151 areaStream$1.point = areaPointFirst$1;
9154 function areaPointFirst$1(x, y) {
9155 areaStream$1.point = areaPoint$1;
9156 x00 = x0$1 = x, y00 = y0$1 = y;
9159 function areaPoint$1(x, y) {
9160 areaRingSum$1.add(y0$1 * x - x0$1 * y);
9164 function areaRingEnd$1() {
9165 areaPoint$1(x00, y00);
9168 var x0$2 = Infinity,
9173 var boundsStream$1 = {
9174 point: boundsPoint$1,
9177 polygonStart: noop$2,
9179 result:
function() {
9180 var bounds = [[x0$2, y0$2], [x1, y1]];
9181 x1 = y1 = -(y0$2 = x0$2 = Infinity);
9186 function boundsPoint$1(x, y) {
9187 if (x < x0$2) x0$2 = x;
9189 if (y < y0$2) y0$2 = y;
9209 var centroidStream$1 = {
9210 point: centroidPoint$1,
9211 lineStart: centroidLineStart$1,
9212 lineEnd: centroidLineEnd$1,
9213 polygonStart:
function() {
9214 centroidStream$1.lineStart = centroidRingStart$1;
9215 centroidStream$1.lineEnd = centroidRingEnd$1;
9217 polygonEnd:
function() {
9218 centroidStream$1.point = centroidPoint$1;
9219 centroidStream$1.lineStart = centroidLineStart$1;
9220 centroidStream$1.lineEnd = centroidLineEnd$1;
9222 result:
function() {
9223 var centroid = Z2$1 ? [X2$1 / Z2$1, Y2$1 / Z2$1]
9224 : Z1$1 ? [X1$1 / Z1$1, Y1$1 / Z1$1]
9225 : Z0$1 ? [X0$1 / Z0$1, Y0$1 / Z0$1]
9227 X0$1 = Y0$1 = Z0$1 =
9228 X1$1 = Y1$1 = Z1$1 =
9229 X2$1 = Y2$1 = Z2$1 = 0;
9234 function centroidPoint$1(x, y) {
9240 function centroidLineStart$1() {
9241 centroidStream$1.point = centroidPointFirstLine;
9244 function centroidPointFirstLine(x, y) {
9245 centroidStream$1.point = centroidPointLine;
9246 centroidPoint$1(x0$3 = x, y0$3 = y);
9249 function centroidPointLine(x, y) {
9250 var dx = x - x0$3, dy = y - y0$3, z = sqrt(dx * dx + dy * dy);
9251 X1$1 += z * (x0$3 + x) / 2;
9252 Y1$1 += z * (y0$3 + y) / 2;
9254 centroidPoint$1(x0$3 = x, y0$3 = y);
9257 function centroidLineEnd$1() {
9258 centroidStream$1.point = centroidPoint$1;
9261 function centroidRingStart$1() {
9262 centroidStream$1.point = centroidPointFirstRing;
9265 function centroidRingEnd$1() {
9266 centroidPointRing(x00$1, y00$1);
9269 function centroidPointFirstRing(x, y) {
9270 centroidStream$1.point = centroidPointRing;
9271 centroidPoint$1(x00$1 = x0$3 = x, y00$1 = y0$3 = y);
9274 function centroidPointRing(x, y) {
9277 z = sqrt(dx * dx + dy * dy);
9279 X1$1 += z * (x0$3 + x) / 2;
9280 Y1$1 += z * (y0$3 + y) / 2;
9283 z = y0$3 * x - x0$3 * y;
9284 X2$1 += z * (x0$3 + x);
9285 Y2$1 += z * (y0$3 + y);
9287 centroidPoint$1(x0$3 = x, y0$3 = y);
9290 function PathContext(context) {
9291 this._context = context;
9294 PathContext.prototype = {
9296 pointRadius:
function(_) {
9297 return this._radius = _,
this;
9299 polygonStart:
function() {
9302 polygonEnd:
function() {
9305 lineStart:
function() {
9308 lineEnd:
function() {
9309 if (this._line === 0) this._context.closePath();
9312 point:
function(x, y) {
9313 switch (this._point) {
9315 this._context.moveTo(x, y);
9320 this._context.lineTo(x, y);
9324 this._context.moveTo(x + this._radius, y);
9325 this._context.arc(x, y, this._radius, 0, tau$3);
9333 var lengthSum$1 = adder(),
9340 var lengthStream$1 = {
9342 lineStart:
function() {
9343 lengthStream$1.point = lengthPointFirst$1;
9345 lineEnd:
function() {
9346 if (lengthRing) lengthPoint$1(x00$2, y00$2);
9347 lengthStream$1.point = noop$2;
9349 polygonStart:
function() {
9352 polygonEnd:
function() {
9355 result:
function() {
9356 var length = +lengthSum$1;
9357 lengthSum$1.reset();
9362 function lengthPointFirst$1(x, y) {
9363 lengthStream$1.point = lengthPoint$1;
9364 x00$2 = x0$4 = x, y00$2 = y0$4 = y;
9367 function lengthPoint$1(x, y) {
9368 x0$4 -= x, y0$4 -= y;
9369 lengthSum$1.add(sqrt(x0$4 * x0$4 + y0$4 * y0$4));
9373 function PathString() {
9377 PathString.prototype = {
9379 _circle: circle$1(4.5),
9380 pointRadius:
function(_) {
9381 if ((_ = +_) !== this._radius) this._radius = _, this._circle = null;
9384 polygonStart:
function() {
9387 polygonEnd:
function() {
9390 lineStart:
function() {
9393 lineEnd:
function() {
9394 if (this._line === 0) this._string.push(
"Z");
9397 point:
function(x, y) {
9398 switch (this._point) {
9400 this._string.push(
"M", x,
",", y);
9405 this._string.push(
"L", x,
",", y);
9409 if (this._circle == null) this._circle = circle$1(this._radius);
9410 this._string.push(
"M", x,
",", y, this._circle);
9415 result:
function() {
9416 if (this._string.length) {
9417 var result = this._string.join(
"");
9426 function circle$1(radius) {
9427 return "m0," + radius
9428 +
"a" + radius +
"," + radius +
" 0 1,1 0," + -2 * radius
9429 +
"a" + radius +
"," + radius +
" 0 1,1 0," + 2 * radius
9433 function index$1(projection, context) {
9434 var pointRadius = 4.5,
9438 function path(
object) {
9440 if (typeof pointRadius ===
"function") contextStream.pointRadius(+pointRadius.apply(
this, arguments));
9441 geoStream(
object, projectionStream(contextStream));
9443 return contextStream.result();
9446 path.area =
function(object) {
9447 geoStream(
object, projectionStream(areaStream$1));
9448 return areaStream$1.result();
9451 path.measure =
function(object) {
9452 geoStream(
object, projectionStream(lengthStream$1));
9453 return lengthStream$1.result();
9456 path.bounds =
function(object) {
9457 geoStream(
object, projectionStream(boundsStream$1));
9458 return boundsStream$1.result();
9461 path.centroid =
function(object) {
9462 geoStream(
object, projectionStream(centroidStream$1));
9463 return centroidStream$1.result();
9466 path.projection =
function(_) {
9467 return arguments.length ? (projectionStream = _ == null ? (projection = null, identity$4) : (projection = _).stream, path) : projection;
9470 path.context =
function(_) {
9471 if (!arguments.length)
return context;
9472 contextStream = _ == null ? (context = null,
new PathString) :
new PathContext(context = _);
9473 if (typeof pointRadius !==
"function") contextStream.pointRadius(pointRadius);
9477 path.pointRadius =
function(_) {
9478 if (!arguments.length)
return pointRadius;
9479 pointRadius = typeof _ ===
"function" ? _ : (contextStream.pointRadius(+_), +_);
9483 return path.projection(projection).context(context);
9486 function transform(methods) {
9488 stream: transformer(methods)
9492 function transformer(methods) {
9493 return function(stream) {
9494 var s =
new TransformStream;
9495 for (var key in methods) s[key] = methods[key];
9501 function TransformStream() {}
9503 TransformStream.prototype = {
9504 constructor: TransformStream,
9505 point:
function(x, y) { this.stream.point(x, y); },
9506 sphere:
function() { this.stream.sphere(); },
9507 lineStart:
function() { this.stream.lineStart(); },
9508 lineEnd:
function() { this.stream.lineEnd(); },
9509 polygonStart:
function() { this.stream.polygonStart(); },
9510 polygonEnd:
function() { this.stream.polygonEnd(); }
9513 function fit(projection, fitBounds,
object) {
9514 var clip = projection.clipExtent && projection.clipExtent();
9515 projection.scale(150).translate([0, 0]);
9516 if (clip != null) projection.clipExtent(null);
9517 geoStream(
object, projection.stream(boundsStream$1));
9518 fitBounds(boundsStream$1.result());
9519 if (clip != null) projection.clipExtent(clip);
9523 function fitExtent(projection, extent,
object) {
9524 return fit(projection,
function(b) {
9525 var w = extent[1][0] - extent[0][0],
9526 h = extent[1][1] - extent[0][1],
9527 k = Math.min(w / (b[1][0] - b[0][0]), h / (b[1][1] - b[0][1])),
9528 x = +extent[0][0] + (w - k * (b[1][0] + b[0][0])) / 2,
9529 y = +extent[0][1] + (h - k * (b[1][1] + b[0][1])) / 2;
9530 projection.scale(150 * k).translate([x, y]);
9534 function fitSize(projection, size,
object) {
9535 return fitExtent(projection, [[0, 0], size],
object);
9538 function fitWidth(projection, width,
object) {
9539 return fit(projection,
function(b) {
9541 k = w / (b[1][0] - b[0][0]),
9542 x = (w - k * (b[1][0] + b[0][0])) / 2,
9544 projection.scale(150 * k).translate([x, y]);
9548 function fitHeight(projection, height,
object) {
9549 return fit(projection,
function(b) {
9551 k = h / (b[1][1] - b[0][1]),
9553 y = (h - k * (b[1][1] + b[0][1])) / 2;
9554 projection.scale(150 * k).translate([x, y]);
9559 cosMinDistance = cos$1(30 * radians);
9561 function resample(project, delta2) {
9562 return +delta2 ? resample$1(project, delta2) : resampleNone(project);
9565 function resampleNone(project) {
9566 return transformer({
9567 point:
function(x, y) {
9569 this.stream.point(x[0], x[1]);
9574 function resample$1(project, delta2) {
9576 function resampleLineTo(x0, y0, lambda0, a0, b0, c0, x1, y1, lambda1, a1, b1, c1, depth, stream) {
9579 d2 = dx * dx + dy * dy;
9580 if (d2 > 4 * delta2 && depth--) {
9584 m = sqrt(a * a + b * b + c * c),
9585 phi2 = asin(c /= m),
9586 lambda2 = abs(abs(c) - 1) < epsilon$2 || abs(lambda0 - lambda1) < epsilon$2 ? (lambda0 + lambda1) / 2 : atan2(b, a),
9587 p = project(lambda2, phi2),
9592 dz = dy * dx2 - dx * dy2;
9593 if (dz * dz / d2 > delta2
9594 || abs((dx * dx2 + dy * dy2) / d2 - 0.5) > 0.3
9595 || a0 * a1 + b0 * b1 + c0 * c1 < cosMinDistance) {
9596 resampleLineTo(x0, y0, lambda0, a0, b0, c0, x2, y2, lambda2, a /= m, b /= m, c, depth, stream);
9597 stream.point(x2, y2);
9598 resampleLineTo(x2, y2, lambda2, a, b, c, x1, y1, lambda1, a1, b1, c1, depth, stream);
9602 return function(stream) {
9603 var lambda00, x00, y00, a00, b00, c00,
9604 lambda0, x0, y0, a0, b0, c0;
9606 var resampleStream = {
9608 lineStart: lineStart,
9610 polygonStart:
function() { stream.polygonStart(); resampleStream.lineStart = ringStart; },
9611 polygonEnd:
function() { stream.polygonEnd(); resampleStream.lineStart = lineStart; }
9614 function point(x, y) {
9616 stream.point(x[0], x[1]);
9619 function lineStart() {
9621 resampleStream.point = linePoint;
9625 function linePoint(lambda, phi) {
9626 var c = cartesian([lambda, phi]), p = project(lambda, phi);
9627 resampleLineTo(x0, y0, lambda0, a0, b0, c0, x0 = p[0], y0 = p[1], lambda0 = lambda, a0 = c[0], b0 = c[1], c0 = c[2], maxDepth, stream);
9628 stream.point(x0, y0);
9631 function lineEnd() {
9632 resampleStream.point = point;
9636 function ringStart() {
9638 resampleStream.point = ringPoint;
9639 resampleStream.lineEnd = ringEnd;
9642 function ringPoint(lambda, phi) {
9643 linePoint(lambda00 = lambda, phi), x00 = x0, y00 = y0, a00 = a0, b00 = b0, c00 = c0;
9644 resampleStream.point = linePoint;
9647 function ringEnd() {
9648 resampleLineTo(x0, y0, lambda0, a0, b0, c0, x00, y00, lambda00, a00, b00, c00, maxDepth, stream);
9649 resampleStream.lineEnd = lineEnd;
9653 return resampleStream;
9657 var transformRadians = transformer({
9658 point:
function(x, y) {
9659 this.stream.point(x * radians, y * radians);
9663 function transformRotate(rotate) {
9664 return transformer({
9665 point:
function(x, y) {
9666 var r = rotate(x, y);
9667 return this.stream.point(r[0], r[1]);
9672 function scaleTranslate(k, dx, dy) {
9673 function transform$$1(x, y) {
9674 return [dx + k * x, dy - k * y];
9676 transform$$1.invert =
function(x, y) {
9677 return [(x - dx) / k, (dy - y) / k];
9679 return transform$$1;
9682 function scaleTranslateRotate(k, dx, dy, alpha) {
9683 var cosAlpha = cos$1(alpha),
9684 sinAlpha = sin$1(alpha),
9689 ci = (sinAlpha * dy - cosAlpha * dx) / k,
9690 fi = (sinAlpha * dx + cosAlpha * dy) / k;
9691 function transform$$1(x, y) {
9692 return [a * x - b * y + dx, dy - b * x - a * y];
9694 transform$$1.invert =
function(x, y) {
9695 return [ai * x - bi * y + ci, fi - bi * x - ai * y];
9697 return transform$$1;
9700 function projection(project) {
9701 return projectionMutator(
function() {
return project; })();
9704 function projectionMutator(projectAt) {
9708 lambda = 0, phi = 0,
9709 deltaLambda = 0, deltaPhi = 0, deltaGamma = 0, rotate,
9711 theta = null, preclip = clipAntimeridian,
9712 x0 = null, y0, x1, y1, postclip = identity$4,
9716 projectRotateTransform,
9720 function projection(point) {
9721 return projectRotateTransform(point[0] * radians, point[1] * radians);
9724 function invert(point) {
9725 point = projectRotateTransform.invert(point[0], point[1]);
9726 return point && [point[0] * degrees$1, point[1] * degrees$1];
9729 projection.stream =
function(stream) {
9730 return cache && cacheStream === stream ? cache : cache = transformRadians(transformRotate(rotate)(preclip(projectResample(postclip(cacheStream = stream)))));
9733 projection.preclip =
function(_) {
9734 return arguments.length ? (preclip = _, theta = undefined, reset()) : preclip;
9737 projection.postclip =
function(_) {
9738 return arguments.length ? (postclip = _, x0 = y0 = x1 = y1 = null, reset()) : postclip;
9741 projection.clipAngle =
function(_) {
9742 return arguments.length ? (preclip = +_ ? clipCircle(theta = _ * radians) : (theta = null, clipAntimeridian), reset()) : theta * degrees$1;
9745 projection.clipExtent =
function(_) {
9746 return arguments.length ? (postclip = _ == null ? (x0 = y0 = x1 = y1 = null, identity$4) : clipRectangle(x0 = +_[0][0], y0 = +_[0][1], x1 = +_[1][0], y1 = +_[1][1]), reset()) : x0 == null ? null : [[x0, y0], [x1, y1]];
9749 projection.scale =
function(_) {
9750 return arguments.length ? (k = +_, recenter()) : k;
9753 projection.translate =
function(_) {
9754 return arguments.length ? (x = +_[0], y = +_[1], recenter()) : [x, y];
9757 projection.center =
function(_) {
9758 return arguments.length ? (lambda = _[0] % 360 * radians, phi = _[1] % 360 * radians, recenter()) : [lambda * degrees$1, phi * degrees$1];
9761 projection.rotate =
function(_) {
9762 return arguments.length ? (deltaLambda = _[0] % 360 * radians, deltaPhi = _[1] % 360 * radians, deltaGamma = _.length > 2 ? _[2] % 360 * radians : 0, recenter()) : [deltaLambda * degrees$1, deltaPhi * degrees$1, deltaGamma * degrees$1];
9765 projection.angle =
function(_) {
9766 return arguments.length ? (alpha = _ % 360 * radians, recenter()) : alpha * degrees$1;
9769 projection.precision =
function(_) {
9770 return arguments.length ? (projectResample = resample(projectTransform, delta2 = _ * _), reset()) : sqrt(delta2);
9773 projection.fitExtent =
function(extent, object) {
9774 return fitExtent(projection, extent,
object);
9777 projection.fitSize =
function(size, object) {
9778 return fitSize(projection, size,
object);
9781 projection.fitWidth =
function(width, object) {
9782 return fitWidth(projection, width,
object);
9785 projection.fitHeight =
function(height, object) {
9786 return fitHeight(projection, height,
object);
9789 function recenter() {
9790 var center = scaleTranslateRotate(k, 0, 0, alpha).apply(null, project(lambda, phi)),
9791 transform$$1 = (alpha ? scaleTranslateRotate : scaleTranslate)(k, x - center[0], y - center[1], alpha);
9792 rotate = rotateRadians(deltaLambda, deltaPhi, deltaGamma);
9793 projectTransform = compose(project, transform$$1);
9794 projectRotateTransform = compose(rotate, projectTransform);
9795 projectResample = resample(projectTransform, delta2);
9800 cache = cacheStream = null;
9805 project = projectAt.apply(
this, arguments);
9806 projection.invert = project.invert && invert;
9811 function conicProjection(projectAt) {
9814 m = projectionMutator(projectAt),
9817 p.parallels =
function(_) {
9818 return arguments.length ? m(phi0 = _[0] * radians, phi1 = _[1] * radians) : [phi0 * degrees$1, phi1 * degrees$1];
9824 function cylindricalEqualAreaRaw(phi0) {
9825 var cosPhi0 = cos$1(phi0);
9827 function forward(lambda, phi) {
9828 return [lambda * cosPhi0, sin$1(phi) / cosPhi0];
9831 forward.invert =
function(x, y) {
9832 return [x / cosPhi0, asin(y * cosPhi0)];
9838 function conicEqualAreaRaw(y0, y1) {
9839 var sy0 = sin$1(y0), n = (sy0 + sin$1(y1)) / 2;
9842 if (abs(n) < epsilon$2)
return cylindricalEqualAreaRaw(y0);
9844 var c = 1 + sy0 * (2 * n - sy0), r0 = sqrt(c) / n;
9846 function project(x, y) {
9847 var r = sqrt(c - 2 * n * sin$1(y)) / n;
9848 return [r * sin$1(x *= n), r0 - r * cos$1(x)];
9851 project.invert =
function(x, y) {
9853 return [atan2(x, abs(r0y)) / n * sign(r0y), asin((c - (x * x + r0y * r0y) * n * n) / (2 * n))];
9859 function conicEqualArea() {
9860 return conicProjection(conicEqualAreaRaw)
9862 .center([0, 33.6442]);
9866 return conicEqualArea()
9867 .parallels([29.5, 45.5])
9869 .translate([480, 250])
9871 .center([-0.6, 38.7]);
9876 function multiplex(streams) {
9877 var n = streams.length;
9879 point:
function(x, y) { var i = -1;
while (++i < n) streams[i].point(x, y); },
9880 sphere:
function() { var i = -1;
while (++i < n) streams[i].sphere(); },
9881 lineStart:
function() { var i = -1;
while (++i < n) streams[i].lineStart(); },
9882 lineEnd:
function() { var i = -1;
while (++i < n) streams[i].lineEnd(); },
9883 polygonStart:
function() { var i = -1;
while (++i < n) streams[i].polygonStart(); },
9884 polygonEnd:
function() { var i = -1;
while (++i < n) streams[i].polygonEnd(); }
9893 function albersUsa() {
9896 lower48 = albers(), lower48Point,
9897 alaska = conicEqualArea().rotate([154, 0]).center([-2, 58.5]).parallels([55, 65]), alaskaPoint,
9898 hawaii = conicEqualArea().rotate([157, 0]).center([-3, 19.9]).parallels([8, 18]), hawaiiPoint,
9899 point, pointStream = {point:
function(x, y) { point = [x, y]; }};
9901 function albersUsa(coordinates) {
9902 var x = coordinates[0], y = coordinates[1];
9903 return point = null,
9904 (lower48Point.point(x, y), point)
9905 || (alaskaPoint.point(x, y), point)
9906 || (hawaiiPoint.point(x, y), point);
9909 albersUsa.invert =
function(coordinates) {
9910 var k = lower48.scale(),
9911 t = lower48.translate(),
9912 x = (coordinates[0] - t[0]) / k,
9913 y = (coordinates[1] - t[1]) / k;
9914 return (y >= 0.120 && y < 0.234 && x >= -0.425 && x < -0.214 ? alaska
9915 : y >= 0.166 && y < 0.234 && x >= -0.214 && x < -0.115 ? hawaii
9916 : lower48).invert(coordinates);
9919 albersUsa.stream =
function(stream) {
9920 return cache && cacheStream === stream ? cache : cache = multiplex([lower48.stream(cacheStream = stream), alaska.stream(stream), hawaii.stream(stream)]);
9923 albersUsa.precision =
function(_) {
9924 if (!arguments.length)
return lower48.precision();
9925 lower48.precision(_), alaska.precision(_), hawaii.precision(_);
9929 albersUsa.scale =
function(_) {
9930 if (!arguments.length)
return lower48.scale();
9931 lower48.scale(_), alaska.scale(_ * 0.35), hawaii.scale(_);
9932 return albersUsa.translate(lower48.translate());
9935 albersUsa.translate =
function(_) {
9936 if (!arguments.length)
return lower48.translate();
9937 var k = lower48.scale(), x = +_[0], y = +_[1];
9939 lower48Point = lower48
9941 .clipExtent([[x - 0.455 * k, y - 0.238 * k], [x + 0.455 * k, y + 0.238 * k]])
9942 .stream(pointStream);
9944 alaskaPoint = alaska
9945 .translate([x - 0.307 * k, y + 0.201 * k])
9946 .clipExtent([[x - 0.425 * k + epsilon$2, y + 0.120 * k + epsilon$2], [x - 0.214 * k - epsilon$2, y + 0.234 * k - epsilon$2]])
9947 .stream(pointStream);
9949 hawaiiPoint = hawaii
9950 .translate([x - 0.205 * k, y + 0.212 * k])
9951 .clipExtent([[x - 0.214 * k + epsilon$2, y + 0.166 * k + epsilon$2], [x - 0.115 * k - epsilon$2, y + 0.234 * k - epsilon$2]])
9952 .stream(pointStream);
9957 albersUsa.fitExtent =
function(extent, object) {
9958 return fitExtent(albersUsa, extent,
object);
9961 albersUsa.fitSize =
function(size, object) {
9962 return fitSize(albersUsa, size,
object);
9965 albersUsa.fitWidth =
function(width, object) {
9966 return fitWidth(albersUsa, width,
object);
9969 albersUsa.fitHeight =
function(height, object) {
9970 return fitHeight(albersUsa, height,
object);
9974 cache = cacheStream = null;
9978 return albersUsa.scale(1070);
9981 function azimuthalRaw(scale) {
9982 return function(x, y) {
9993 function azimuthalInvert(angle) {
9994 return function(x, y) {
9995 var z = sqrt(x * x + y * y),
10000 atan2(x * sc, z * cc),
10001 asin(z && y * sc / z)
10006 var azimuthalEqualAreaRaw = azimuthalRaw(
function(cxcy) {
10007 return sqrt(2 / (1 + cxcy));
10010 azimuthalEqualAreaRaw.invert = azimuthalInvert(
function(z) {
10011 return 2 * asin(z / 2);
10014 function azimuthalEqualArea() {
10015 return projection(azimuthalEqualAreaRaw)
10017 .clipAngle(180 - 1e-3);
10020 var azimuthalEquidistantRaw = azimuthalRaw(
function(c) {
10021 return (c = acos(c)) && c / sin$1(c);
10024 azimuthalEquidistantRaw.invert = azimuthalInvert(
function(z) {
10028 function azimuthalEquidistant() {
10029 return projection(azimuthalEquidistantRaw)
10031 .clipAngle(180 - 1e-3);
10034 function mercatorRaw(lambda, phi) {
10035 return [lambda, log(tan((halfPi$2 + phi) / 2))];
10038 mercatorRaw.invert =
function(x, y) {
10039 return [x, 2 * atan(exp(y)) - halfPi$2];
10042 function mercator() {
10043 return mercatorProjection(mercatorRaw)
10044 .scale(961 / tau$3);
10047 function mercatorProjection(project) {
10048 var m = projection(project),
10051 translate = m.translate,
10052 clipExtent = m.clipExtent,
10053 x0 = null, y0, x1, y1;
10055 m.scale =
function(_) {
10056 return arguments.length ? (scale(_), reclip()) : scale();
10059 m.translate =
function(_) {
10060 return arguments.length ? (translate(_), reclip()) : translate();
10063 m.center =
function(_) {
10064 return arguments.length ? (center(_), reclip()) : center();
10067 m.clipExtent =
function(_) {
10068 return arguments.length ? ((_ == null ? x0 = y0 = x1 = y1 = null : (x0 = +_[0][0], y0 = +_[0][1], x1 = +_[1][0], y1 = +_[1][1])), reclip()) : x0 == null ? null : [[x0, y0], [x1, y1]];
10071 function reclip() {
10072 var k = pi$3 * scale(),
10073 t = m(rotation(m.rotate()).invert([0, 0]));
10074 return clipExtent(x0 == null
10075 ? [[t[0] - k, t[1] - k], [t[0] + k, t[1] + k]] : project === mercatorRaw
10076 ? [[Math.max(t[0] - k, x0), y0], [Math.min(t[0] + k, x1), y1]]
10077 : [[x0, Math.max(t[1] - k, y0)], [x1, Math.min(t[1] + k, y1)]]);
10084 return tan((halfPi$2 + y) / 2);
10087 function conicConformalRaw(y0, y1) {
10088 var cy0 = cos$1(y0),
10089 n = y0 === y1 ? sin$1(y0) : log(cy0 / cos$1(y1)) / log(tany(y1) / tany(y0)),
10090 f = cy0 * pow(tany(y0), n) / n;
10092 if (!n)
return mercatorRaw;
10094 function project(x, y) {
10095 if (f > 0) {
if (y < -halfPi$2 + epsilon$2) y = -halfPi$2 + epsilon$2; }
10096 else {
if (y > halfPi$2 - epsilon$2) y = halfPi$2 - epsilon$2; }
10097 var r = f / pow(tany(y), n);
10098 return [r * sin$1(n * x), f - r * cos$1(n * x)];
10101 project.invert =
function(x, y) {
10102 var fy = f - y, r = sign(n) * sqrt(x * x + fy * fy);
10103 return [atan2(x, abs(fy)) / n * sign(fy), 2 * atan(pow(f / r, 1 / n)) - halfPi$2];
10109 function conicConformal() {
10110 return conicProjection(conicConformalRaw)
10112 .parallels([30, 30]);
10115 function equirectangularRaw(lambda, phi) {
10116 return [lambda, phi];
10119 equirectangularRaw.invert = equirectangularRaw;
10121 function equirectangular() {
10122 return projection(equirectangularRaw)
10126 function conicEquidistantRaw(y0, y1) {
10127 var cy0 = cos$1(y0),
10128 n = y0 === y1 ? sin$1(y0) : (cy0 - cos$1(y1)) / (y1 - y0),
10131 if (abs(n) < epsilon$2)
return equirectangularRaw;
10133 function project(x, y) {
10134 var gy = g - y, nx = n * x;
10135 return [gy * sin$1(nx), g - gy * cos$1(nx)];
10138 project.invert =
function(x, y) {
10140 return [atan2(x, abs(gy)) / n * sign(gy), g - sign(n) * sqrt(x * x + gy * gy)];
10146 function conicEquidistant() {
10147 return conicProjection(conicEquidistantRaw)
10149 .center([0, 13.9389]);
10159 function equalEarthRaw(lambda, phi) {
10160 var l = asin(M * sin$1(phi)), l2 = l * l, l6 = l2 * l2 * l2;
10162 lambda * cos$1(l) / (M * (A1 + 3 * A2 * l2 + l6 * (7 * A3 + 9 * A4 * l2))),
10163 l * (A1 + A2 * l2 + l6 * (A3 + A4 * l2))
10167 equalEarthRaw.invert =
function(x, y) {
10168 var l = y, l2 = l * l, l6 = l2 * l2 * l2;
10169 for (var i = 0, delta, fy, fpy; i < iterations; ++i) {
10170 fy = l * (A1 + A2 * l2 + l6 * (A3 + A4 * l2)) - y;
10171 fpy = A1 + 3 * A2 * l2 + l6 * (7 * A3 + 9 * A4 * l2);
10172 l -= delta = fy / fpy, l2 = l * l, l6 = l2 * l2 * l2;
10173 if (abs(delta) < epsilon2$1)
break;
10176 M * x * (A1 + 3 * A2 * l2 + l6 * (7 * A3 + 9 * A4 * l2)) / cos$1(l),
10181 function equalEarth() {
10182 return projection(equalEarthRaw)
10186 function gnomonicRaw(x, y) {
10187 var cy = cos$1(y), k = cos$1(x) * cy;
10188 return [cy * sin$1(x) / k, sin$1(y) / k];
10191 gnomonicRaw.invert = azimuthalInvert(atan);
10193 function gnomonic() {
10194 return projection(gnomonicRaw)
10199 function scaleTranslate$1(kx, ky, tx, ty) {
10200 return kx === 1 && ky === 1 && tx === 0 && ty === 0 ? identity$4 : transformer({
10201 point:
function(x, y) {
10202 this.stream.point(x * kx + tx, y * ky + ty);
10207 function identity$5() {
10208 var k = 1, tx = 0, ty = 0, sx = 1, sy = 1, transform$$1 = identity$4,
10209 x0 = null, y0, x1, y1,
10210 postclip = identity$4,
10216 cache = cacheStream = null;
10220 return projection = {
10221 stream:
function(stream) {
10222 return cache && cacheStream === stream ? cache : cache = transform$$1(postclip(cacheStream = stream));
10224 postclip:
function(_) {
10225 return arguments.length ? (postclip = _, x0 = y0 = x1 = y1 = null, reset()) : postclip;
10227 clipExtent:
function(_) {
10228 return arguments.length ? (postclip = _ == null ? (x0 = y0 = x1 = y1 = null, identity$4) : clipRectangle(x0 = +_[0][0], y0 = +_[0][1], x1 = +_[1][0], y1 = +_[1][1]), reset()) : x0 == null ? null : [[x0, y0], [x1, y1]];
10230 scale:
function(_) {
10231 return arguments.length ? (transform$$1 = scaleTranslate$1((k = +_) * sx, k * sy, tx, ty), reset()) : k;
10233 translate:
function(_) {
10234 return arguments.length ? (transform$$1 = scaleTranslate$1(k * sx, k * sy, tx = +_[0], ty = +_[1]), reset()) : [tx, ty];
10236 reflectX:
function(_) {
10237 return arguments.length ? (transform$$1 = scaleTranslate$1(k * (sx = _ ? -1 : 1), k * sy, tx, ty), reset()) : sx < 0;
10239 reflectY:
function(_) {
10240 return arguments.length ? (transform$$1 = scaleTranslate$1(k * sx, k * (sy = _ ? -1 : 1), tx, ty), reset()) : sy < 0;
10242 fitExtent:
function(extent, object) {
10243 return fitExtent(projection, extent,
object);
10245 fitSize:
function(size, object) {
10246 return fitSize(projection, size,
object);
10248 fitWidth:
function(width, object) {
10249 return fitWidth(projection, width,
object);
10251 fitHeight:
function(height, object) {
10252 return fitHeight(projection, height,
object);
10257 function naturalEarth1Raw(lambda, phi) {
10258 var phi2 = phi * phi, phi4 = phi2 * phi2;
10260 lambda * (0.8707 - 0.131979 * phi2 + phi4 * (-0.013791 + phi4 * (0.003971 * phi2 - 0.001529 * phi4))),
10261 phi * (1.007226 + phi2 * (0.015085 + phi4 * (-0.044475 + 0.028874 * phi2 - 0.005916 * phi4)))
10265 naturalEarth1Raw.invert =
function(x, y) {
10266 var phi = y, i = 25, delta;
10268 var phi2 = phi * phi, phi4 = phi2 * phi2;
10269 phi -= delta = (phi * (1.007226 + phi2 * (0.015085 + phi4 * (-0.044475 + 0.028874 * phi2 - 0.005916 * phi4))) - y) /
10270 (1.007226 + phi2 * (0.015085 * 3 + phi4 * (-0.044475 * 7 + 0.028874 * 9 * phi2 - 0.005916 * 11 * phi4)));
10271 }
while (abs(delta) > epsilon$2 && --i > 0);
10273 x / (0.8707 + (phi2 = phi * phi) * (-0.131979 + phi2 * (-0.013791 + phi2 * phi2 * phi2 * (0.003971 - 0.001529 * phi2)))),
10278 function naturalEarth1() {
10279 return projection(naturalEarth1Raw)
10283 function orthographicRaw(x, y) {
10284 return [cos$1(y) * sin$1(x), sin$1(y)];
10287 orthographicRaw.invert = azimuthalInvert(asin);
10289 function orthographic() {
10290 return projection(orthographicRaw)
10292 .clipAngle(90 + epsilon$2);
10295 function stereographicRaw(x, y) {
10296 var cy = cos$1(y), k = 1 + cos$1(x) * cy;
10297 return [cy * sin$1(x) / k, sin$1(y) / k];
10300 stereographicRaw.invert = azimuthalInvert(
function(z) {
10301 return 2 * atan(z);
10304 function stereographic() {
10305 return projection(stereographicRaw)
10310 function transverseMercatorRaw(lambda, phi) {
10311 return [log(tan((halfPi$2 + phi) / 2)), -lambda];
10314 transverseMercatorRaw.invert =
function(x, y) {
10315 return [-y, 2 * atan(exp(x)) - halfPi$2];
10318 function transverseMercator() {
10319 var m = mercatorProjection(transverseMercatorRaw),
10323 m.center =
function(_) {
10324 return arguments.length ? center([-_[1], _[0]]) : (_ = center(), [_[1], -_[0]]);
10327 m.rotate =
function(_) {
10328 return arguments.length ? rotate([_[0], _[1], _.length > 2 ? _[2] + 90 : 90]) : (_ = rotate(), [_[0], _[1], _[2] - 90]);
10331 return rotate([0, 0, 90])
10335 function defaultSeparation(a, b) {
10336 return a.parent === b.parent ? 1 : 2;
10339 function meanX(children) {
10340 return children.reduce(meanXReduce, 0) / children.length;
10343 function meanXReduce(x, c) {
10347 function maxY(children) {
10348 return 1 + children.reduce(maxYReduce, 0);
10351 function maxYReduce(y, c) {
10352 return Math.max(y, c.y);
10355 function leafLeft(node) {
10357 while (children = node.children) node = children[0];
10361 function leafRight(node) {
10363 while (children = node.children) node = children[children.length - 1];
10367 function cluster() {
10368 var separation = defaultSeparation,
10373 function cluster(root) {
10378 root.eachAfter(
function(node) {
10379 var children = node.children;
10381 node.x = meanX(children);
10382 node.y = maxY(children);
10384 node.x = previousNode ? x += separation(node, previousNode) : 0;
10386 previousNode = node;
10390 var left = leafLeft(root),
10391 right = leafRight(root),
10392 x0 = left.x - separation(left, right) / 2,
10393 x1 = right.x + separation(right, left) / 2;
10396 return root.eachAfter(nodeSize ?
function(node) {
10397 node.x = (node.x - root.x) * dx;
10398 node.y = (root.y - node.y) * dy;
10399 } :
function(node) {
10400 node.x = (node.x - x0) / (x1 - x0) * dx;
10401 node.y = (1 - (root.y ? node.y / root.y : 1)) * dy;
10405 cluster.separation =
function(x) {
10406 return arguments.length ? (separation = x, cluster) : separation;
10409 cluster.size =
function(x) {
10410 return arguments.length ? (nodeSize =
false, dx = +x[0], dy = +x[1], cluster) : (nodeSize ? null : [dx, dy]);
10413 cluster.nodeSize =
function(x) {
10414 return arguments.length ? (nodeSize =
true, dx = +x[0], dy = +x[1], cluster) : (nodeSize ? [dx, dy] : null);
10420 function count(node) {
10422 children = node.children,
10423 i = children && children.length;
10425 else while (--i >= 0) sum += children[i].value;
10429 function node_count() {
10430 return this.eachAfter(count);
10433 function node_each(callback) {
10434 var node =
this, current, next = [node], children, i, n;
10436 current = next.reverse(), next = [];
10437 while (node = current.pop()) {
10438 callback(node), children = node.children;
10439 if (children)
for (i = 0, n = children.length; i < n; ++i) {
10440 next.push(children[i]);
10443 }
while (next.length);
10447 function node_eachBefore(callback) {
10448 var node =
this, nodes = [node], children, i;
10449 while (node = nodes.pop()) {
10450 callback(node), children = node.children;
10451 if (children)
for (i = children.length - 1; i >= 0; --i) {
10452 nodes.push(children[i]);
10458 function node_eachAfter(callback) {
10459 var node =
this, nodes = [node], next = [], children, i, n;
10460 while (node = nodes.pop()) {
10461 next.push(node), children = node.children;
10462 if (children)
for (i = 0, n = children.length; i < n; ++i) {
10463 nodes.push(children[i]);
10466 while (node = next.pop()) {
10472 function node_sum(value) {
10473 return this.eachAfter(
function(node) {
10474 var sum = +value(node.data) || 0,
10475 children = node.children,
10476 i = children && children.length;
10477 while (--i >= 0) sum += children[i].value;
10482 function node_sort(compare) {
10483 return this.eachBefore(
function(node) {
10484 if (node.children) {
10485 node.children.sort(compare);
10490 function node_path(end) {
10492 ancestor = leastCommonAncestor(start, end),
10494 while (start !== ancestor) {
10495 start = start.parent;
10498 var k = nodes.length;
10499 while (end !== ancestor) {
10500 nodes.splice(k, 0, end);
10506 function leastCommonAncestor(a, b) {
10507 if (a === b)
return a;
10508 var aNodes = a.ancestors(),
10509 bNodes = b.ancestors(),
10521 function node_ancestors() {
10522 var node =
this, nodes = [node];
10523 while (node = node.parent) {
10529 function node_descendants() {
10531 this.each(
function(node) {
10537 function node_leaves() {
10539 this.eachBefore(
function(node) {
10540 if (!node.children) {
10547 function node_links() {
10548 var root =
this, links = [];
10549 root.each(
function(node) {
10550 if (node !== root) {
10551 links.push({source: node.parent, target: node});
10557 function hierarchy(data, children) {
10558 var root =
new Node(data),
10559 valued = +data.value && (root.value = data.value),
10567 if (children == null) children = defaultChildren;
10569 while (node = nodes.pop()) {
10570 if (valued) node.value = +node.data.value;
10571 if ((childs = children(node.data)) && (n = childs.length)) {
10572 node.children =
new Array(n);
10573 for (i = n - 1; i >= 0; --i) {
10574 nodes.push(child = node.children[i] =
new Node(childs[i]));
10575 child.parent = node;
10576 child.depth = node.depth + 1;
10581 return root.eachBefore(computeHeight);
10584 function node_copy() {
10585 return hierarchy(
this).eachBefore(copyData);
10588 function defaultChildren(d) {
10592 function copyData(node) {
10593 node.data = node.data.data;
10596 function computeHeight(node) {
10598 do node.height = height;
10599 while ((node = node.parent) && (node.height < ++height));
10602 function Node(data) {
10606 this.parent = null;
10609 Node.prototype = hierarchy.prototype = {
10613 eachAfter: node_eachAfter,
10614 eachBefore: node_eachBefore,
10618 ancestors: node_ancestors,
10619 descendants: node_descendants,
10620 leaves: node_leaves,
10625 var slice$4 = Array.prototype.slice;
10627 function shuffle$1(array) {
10628 var m = array.length,
10633 i = Math.random() * m-- | 0;
10635 array[m] = array[i];
10642 function enclose(circles) {
10643 var i = 0, n = (circles = shuffle$1(slice$4.call(circles))).length, B = [], p, e;
10647 if (e && enclosesWeak(e, p)) ++i;
10648 else e = encloseBasis(B = extendBasis(B, p)), i = 0;
10654 function extendBasis(B, p) {
10657 if (enclosesWeakAll(p, B))
return [p];
10660 for (i = 0; i < B.length; ++i) {
10661 if (enclosesNot(p, B[i])
10662 && enclosesWeakAll(encloseBasis2(B[i], p), B)) {
10668 for (i = 0; i < B.length - 1; ++i) {
10669 for (j = i + 1; j < B.length; ++j) {
10670 if (enclosesNot(encloseBasis2(B[i], B[j]), p)
10671 && enclosesNot(encloseBasis2(B[i], p), B[j])
10672 && enclosesNot(encloseBasis2(B[j], p), B[i])
10673 && enclosesWeakAll(encloseBasis3(B[i], B[j], p), B)) {
10674 return [B[i], B[j], p];
10683 function enclosesNot(a, b) {
10684 var dr = a.r - b.r, dx = b.x - a.x, dy = b.y - a.y;
10685 return dr < 0 || dr * dr < dx * dx + dy * dy;
10688 function enclosesWeak(a, b) {
10689 var dr = a.r - b.r + 1e-6, dx = b.x - a.x, dy = b.y - a.y;
10690 return dr > 0 && dr * dr > dx * dx + dy * dy;
10693 function enclosesWeakAll(a, B) {
10694 for (var i = 0; i < B.length; ++i) {
10695 if (!enclosesWeak(a, B[i])) {
10702 function encloseBasis(B) {
10703 switch (B.length) {
10704 case 1:
return encloseBasis1(B[0]);
10705 case 2:
return encloseBasis2(B[0], B[1]);
10706 case 3:
return encloseBasis3(B[0], B[1], B[2]);
10710 function encloseBasis1(a) {
10718 function encloseBasis2(a, b) {
10719 var x1 = a.x, y1 = a.y, r1 = a.r,
10720 x2 = b.x, y2 = b.y, r2 = b.r,
10721 x21 = x2 - x1, y21 = y2 - y1, r21 = r2 - r1,
10722 l = Math.sqrt(x21 * x21 + y21 * y21);
10724 x: (x1 + x2 + x21 / l * r21) / 2,
10725 y: (y1 + y2 + y21 / l * r21) / 2,
10726 r: (l + r1 + r2) / 2
10730 function encloseBasis3(a, b, c) {
10731 var x1 = a.x, y1 = a.y, r1 = a.r,
10732 x2 = b.x, y2 = b.y, r2 = b.r,
10733 x3 = c.x, y3 = c.y, r3 = c.r,
10740 d1 = x1 * x1 + y1 * y1 - r1 * r1,
10741 d2 = d1 - x2 * x2 - y2 * y2 + r2 * r2,
10742 d3 = d1 - x3 * x3 - y3 * y3 + r3 * r3,
10743 ab = a3 * b2 - a2 * b3,
10744 xa = (b2 * d3 - b3 * d2) / (ab * 2) - x1,
10745 xb = (b3 * c2 - b2 * c3) / ab,
10746 ya = (a3 * d2 - a2 * d3) / (ab * 2) - y1,
10747 yb = (a2 * c3 - a3 * c2) / ab,
10748 A = xb * xb + yb * yb - 1,
10749 B = 2 * (r1 + xa * xb + ya * yb),
10750 C = xa * xa + ya * ya - r1 * r1,
10751 r = -(A ? (B + Math.sqrt(B * B - 4 * A * C)) / (2 * A) : C / B);
10753 x: x1 + xa + xb * r,
10754 y: y1 + ya + yb * r,
10759 function place(b, a, c) {
10760 var dx = b.x - a.x, x, a2,
10761 dy = b.y - a.y, y, b2,
10762 d2 = dx * dx + dy * dy;
10764 a2 = a.r + c.r, a2 *= a2;
10765 b2 = b.r + c.r, b2 *= b2;
10767 x = (d2 + b2 - a2) / (2 * d2);
10768 y = Math.sqrt(Math.max(0, b2 / d2 - x * x));
10769 c.x = b.x - x * dx - y * dy;
10770 c.y = b.y - x * dy + y * dx;
10772 x = (d2 + a2 - b2) / (2 * d2);
10773 y = Math.sqrt(Math.max(0, a2 / d2 - x * x));
10774 c.x = a.x + x * dx - y * dy;
10775 c.y = a.y + x * dy + y * dx;
10783 function intersects(a, b) {
10784 var dr = a.r + b.r - 1e-6, dx = b.x - a.x, dy = b.y - a.y;
10785 return dr > 0 && dr * dr > dx * dx + dy * dy;
10788 function score(node) {
10792 dx = (a.x * b.r + b.x * a.r) / ab,
10793 dy = (a.y * b.r + b.y * a.r) / ab;
10794 return dx * dx + dy * dy;
10797 function Node$1(circle) {
10800 this.previous = null;
10803 function packEnclose(circles) {
10804 if (!(n = circles.length))
return 0;
10806 var a, b, c, n, aa, ca, i, j, k, sj, sk;
10809 a = circles[0], a.x = 0, a.y = 0;
10810 if (!(n > 1))
return a.r;
10813 b = circles[1], a.x = -b.r, b.x = a.r, b.y = 0;
10814 if (!(n > 2))
return a.r + b.r;
10817 place(b, a, c = circles[2]);
10820 a =
new Node$1(a), b =
new Node$1(b), c =
new Node$1(c);
10821 a.next = c.previous = b;
10822 b.next = a.previous = c;
10823 c.next = b.previous = a;
10826 pack:
for (i = 3; i < n; ++i) {
10827 place(a._, b._, c = circles[i]), c =
new Node$1(c);
10832 j = b.next, k = a.previous, sj = b._.r, sk = a._.r;
10835 if (intersects(j._, c._)) {
10836 b = j, a.next = b, b.previous = a, --i;
10839 sj += j._.r, j = j.next;
10841 if (intersects(k._, c._)) {
10842 a = k, a.next = b, b.previous = a, --i;
10845 sk += k._.r, k = k.previous;
10847 }
while (j !== k.next);
10850 c.previous = a, c.next = b, a.next = b.previous = b = c;
10854 while ((c = c.next) !== b) {
10855 if ((ca = score(c)) < aa) {
10863 a = [b._], c = b;
while ((c = c.next) !== b) a.push(c._); c = enclose(a);
10866 for (i = 0; i < n; ++i) a = circles[i], a.x -= c.x, a.y -= c.y;
10871 function siblings(circles) {
10872 packEnclose(circles);
10876 function optional(f) {
10877 return f == null ? null : required(f);
10880 function required(f) {
10881 if (typeof f !==
"function")
throw new Error;
10885 function constantZero() {
10889 function constant$9(x) {
10890 return function() {
10895 function defaultRadius$1(d) {
10896 return Math.sqrt(d.value);
10899 function index$2() {
10903 padding = constantZero;
10905 function pack(root) {
10906 root.x = dx / 2, root.y = dy / 2;
10908 root.eachBefore(radiusLeaf(radius))
10909 .eachAfter(packChildren(padding, 0.5))
10910 .eachBefore(translateChild(1));
10912 root.eachBefore(radiusLeaf(defaultRadius$1))
10913 .eachAfter(packChildren(constantZero, 1))
10914 .eachAfter(packChildren(padding, root.r / Math.min(dx, dy)))
10915 .eachBefore(translateChild(Math.min(dx, dy) / (2 * root.r)));
10920 pack.radius =
function(x) {
10921 return arguments.length ? (radius = optional(x), pack) : radius;
10924 pack.size =
function(x) {
10925 return arguments.length ? (dx = +x[0], dy = +x[1], pack) : [dx, dy];
10928 pack.padding =
function(x) {
10929 return arguments.length ? (padding = typeof x ===
"function" ? x : constant$9(+x), pack) : padding;
10935 function radiusLeaf(radius) {
10936 return function(node) {
10937 if (!node.children) {
10938 node.r = Math.max(0, +radius(node) || 0);
10943 function packChildren(padding, k) {
10944 return function(node) {
10945 if (children = node.children) {
10948 n = children.length,
10949 r = padding(node) * k || 0,
10952 if (r)
for (i = 0; i < n; ++i) children[i].r += r;
10953 e = packEnclose(children);
10954 if (r)
for (i = 0; i < n; ++i) children[i].r -= r;
10960 function translateChild(k) {
10961 return function(node) {
10962 var parent = node.parent;
10965 node.x = parent.x + k * node.x;
10966 node.y = parent.y + k * node.y;
10971 function roundNode(node) {
10972 node.x0 = Math.round(node.x0);
10973 node.y0 = Math.round(node.y0);
10974 node.x1 = Math.round(node.x1);
10975 node.y1 = Math.round(node.y1);
10978 function treemapDice(parent, x0, y0, x1, y1) {
10979 var nodes = parent.children,
10983 k = parent.value && (x1 - x0) / parent.value;
10986 node = nodes[i], node.y0 = y0, node.y1 = y1;
10987 node.x0 = x0, node.x1 = x0 += node.value * k;
10991 function partition() {
10997 function partition(root) {
10998 var n = root.height + 1;
11003 root.eachBefore(positionNode(dy, n));
11004 if (round) root.eachBefore(roundNode);
11008 function positionNode(dy, n) {
11009 return function(node) {
11010 if (node.children) {
11011 treemapDice(node, node.x0, dy * (node.depth + 1) / n, node.x1, dy * (node.depth + 2) / n);
11015 x1 = node.x1 - padding,
11016 y1 = node.y1 - padding;
11017 if (x1 < x0) x0 = x1 = (x0 + x1) / 2;
11018 if (y1 < y0) y0 = y1 = (y0 + y1) / 2;
11026 partition.round =
function(x) {
11027 return arguments.length ? (round = !!x, partition) : round;
11030 partition.size =
function(x) {
11031 return arguments.length ? (dx = +x[0], dy = +x[1], partition) : [dx, dy];
11034 partition.padding =
function(x) {
11035 return arguments.length ? (padding = +x, partition) : padding;
11041 var keyPrefix$1 =
"$",
11042 preroot = {depth: -1},
11045 function defaultId(d) {
11049 function defaultParentId(d) {
11053 function stratify() {
11054 var
id = defaultId,
11055 parentId = defaultParentId;
11057 function stratify(data) {
11064 nodes =
new Array(n),
11069 for (i = 0; i < n; ++i) {
11070 d = data[i], node = nodes[i] =
new Node(d);
11071 if ((nodeId =
id(d, i, data)) != null && (nodeId +=
"")) {
11072 nodeKey = keyPrefix$1 + (node.id = nodeId);
11073 nodeByKey[nodeKey] = nodeKey in nodeByKey ? ambiguous : node;
11077 for (i = 0; i < n; ++i) {
11078 node = nodes[i], nodeId = parentId(data[i], i, data);
11079 if (nodeId == null || !(nodeId +=
"")) {
11080 if (root)
throw new Error(
"multiple roots");
11083 parent = nodeByKey[keyPrefix$1 + nodeId];
11084 if (!parent)
throw new Error(
"missing: " + nodeId);
11085 if (parent === ambiguous)
throw new Error(
"ambiguous: " + nodeId);
11086 if (parent.children) parent.children.push(node);
11087 else parent.children = [node];
11088 node.parent = parent;
11092 if (!root)
throw new Error(
"no root");
11093 root.parent = preroot;
11094 root.eachBefore(
function(node) { node.depth = node.parent.depth + 1; --n; }).eachBefore(computeHeight);
11095 root.parent = null;
11096 if (n > 0)
throw new Error(
"cycle");
11101 stratify.id =
function(x) {
11102 return arguments.length ? (
id = required(x), stratify) :
id;
11105 stratify.parentId =
function(x) {
11106 return arguments.length ? (parentId = required(x), stratify) : parentId;
11112 function defaultSeparation$1(a, b) {
11113 return a.parent === b.parent ? 1 : 2;
11124 function nextLeft(v) {
11125 var children = v.children;
11126 return children ? children[0] : v.t;
11130 function nextRight(v) {
11131 var children = v.children;
11132 return children ? children[children.length - 1] : v.t;
11137 function moveSubtree(wm, wp, shift) {
11138 var change = shift / (wp.i - wm.i);
11149 function executeShifts(v) {
11152 children = v.children,
11153 i = children.length,
11159 shift += w.s + (change += w.c);
11165 function nextAncestor(vim, v, ancestor) {
11166 return vim.a.parent === v.parent ? vim.a : ancestor;
11169 function TreeNode(node, i) {
11171 this.parent = null;
11172 this.children = null;
11183 TreeNode.prototype = Object.create(Node.prototype);
11185 function treeRoot(root) {
11186 var tree =
new TreeNode(root, 0),
11194 while (node = nodes.pop()) {
11195 if (children = node._.children) {
11196 node.children =
new Array(n = children.length);
11197 for (i = n - 1; i >= 0; --i) {
11198 nodes.push(child = node.children[i] =
new TreeNode(children[i], i));
11199 child.parent = node;
11204 (tree.parent =
new TreeNode(null, 0)).children = [tree];
11210 var separation = defaultSeparation$1,
11215 function tree(root) {
11216 var t = treeRoot(root);
11219 t.eachAfter(firstWalk), t.parent.m = -t.z;
11220 t.eachBefore(secondWalk);
11223 if (nodeSize) root.eachBefore(sizeNode);
11231 root.eachBefore(
function(node) {
11232 if (node.x < left.x) left = node;
11233 if (node.x > right.x) right = node;
11234 if (node.depth > bottom.depth) bottom = node;
11236 var s = left === right ? 1 : separation(left, right) / 2,
11238 kx = dx / (right.x + s + tx),
11239 ky = dy / (bottom.depth || 1);
11240 root.eachBefore(
function(node) {
11241 node.x = (node.x + tx) * kx;
11242 node.y = node.depth * ky;
11253 function firstWalk(v) {
11254 var children = v.children,
11255 siblings = v.parent.children,
11256 w = v.i ? siblings[v.i - 1] : null;
11259 var midpoint = (children[0].z + children[children.length - 1].z) / 2;
11261 v.z = w.z + separation(v._, w._);
11262 v.m = v.z - midpoint;
11267 v.z = w.z + separation(v._, w._);
11269 v.parent.A = apportion(v, w, v.parent.A || siblings[0]);
11273 function secondWalk(v) {
11274 v._.x = v.z + v.parent.m;
11289 function apportion(v, w, ancestor) {
11294 vom = vip.parent.children[0],
11300 while (vim = nextRight(vim), vip = nextLeft(vip), vim && vip) {
11301 vom = nextLeft(vom);
11302 vop = nextRight(vop);
11304 shift = vim.z + sim - vip.z - sip + separation(vim._, vip._);
11306 moveSubtree(nextAncestor(vim, v, ancestor), v, shift);
11315 if (vim && !nextRight(vop)) {
11317 vop.m += sim - sop;
11319 if (vip && !nextLeft(vom)) {
11321 vom.m += sip - som;
11328 function sizeNode(node) {
11330 node.y = node.depth * dy;
11333 tree.separation =
function(x) {
11334 return arguments.length ? (separation = x, tree) : separation;
11337 tree.size =
function(x) {
11338 return arguments.length ? (nodeSize =
false, dx = +x[0], dy = +x[1], tree) : (nodeSize ? null : [dx, dy]);
11341 tree.nodeSize =
function(x) {
11342 return arguments.length ? (nodeSize =
true, dx = +x[0], dy = +x[1], tree) : (nodeSize ? [dx, dy] : null);
11348 function treemapSlice(parent, x0, y0, x1, y1) {
11349 var nodes = parent.children,
11353 k = parent.value && (y1 - y0) / parent.value;
11356 node = nodes[i], node.x0 = x0, node.x1 = x1;
11357 node.y0 = y0, node.y1 = y0 += node.value * k;
11361 var phi = (1 + Math.sqrt(5)) / 2;
11363 function squarifyRatio(ratio, parent, x0, y0, x1, y1) {
11365 nodes = parent.children,
11372 value = parent.value,
11382 dx = x1 - x0, dy = y1 - y0;
11385 do sumValue = nodes[i1++].value;
while (!sumValue && i1 < n);
11386 minValue = maxValue = sumValue;
11387 alpha = Math.max(dy / dx, dx / dy) / (value * ratio);
11388 beta = sumValue * sumValue * alpha;
11389 minRatio = Math.max(maxValue / beta, beta / minValue);
11392 for (; i1 < n; ++i1) {
11393 sumValue += nodeValue = nodes[i1].value;
11394 if (nodeValue < minValue) minValue = nodeValue;
11395 if (nodeValue > maxValue) maxValue = nodeValue;
11396 beta = sumValue * sumValue * alpha;
11397 newRatio = Math.max(maxValue / beta, beta / minValue);
11398 if (newRatio > minRatio) { sumValue -= nodeValue;
break; }
11399 minRatio = newRatio;
11403 rows.push(row = {value: sumValue, dice: dx < dy, children: nodes.slice(i0, i1)});
11404 if (row.dice) treemapDice(row, x0, y0, x1, value ? y0 += dy * sumValue / value : y1);
11405 else treemapSlice(row, x0, y0, value ? x0 += dx * sumValue / value : x1, y1);
11406 value -= sumValue, i0 = i1;
11412 var squarify = (
function custom(ratio) {
11414 function squarify(parent, x0, y0, x1, y1) {
11415 squarifyRatio(ratio, parent, x0, y0, x1, y1);
11418 squarify.ratio =
function(x) {
11419 return custom((x = +x) > 1 ? x : 1);
11425 function index$3() {
11426 var tile = squarify,
11430 paddingStack = [0],
11431 paddingInner = constantZero,
11432 paddingTop = constantZero,
11433 paddingRight = constantZero,
11434 paddingBottom = constantZero,
11435 paddingLeft = constantZero;
11437 function treemap(root) {
11442 root.eachBefore(positionNode);
11443 paddingStack = [0];
11444 if (round) root.eachBefore(roundNode);
11448 function positionNode(node) {
11449 var p = paddingStack[node.depth],
11454 if (x1 < x0) x0 = x1 = (x0 + x1) / 2;
11455 if (y1 < y0) y0 = y1 = (y0 + y1) / 2;
11460 if (node.children) {
11461 p = paddingStack[node.depth + 1] = paddingInner(node) / 2;
11462 x0 += paddingLeft(node) - p;
11463 y0 += paddingTop(node) - p;
11464 x1 -= paddingRight(node) - p;
11465 y1 -= paddingBottom(node) - p;
11466 if (x1 < x0) x0 = x1 = (x0 + x1) / 2;
11467 if (y1 < y0) y0 = y1 = (y0 + y1) / 2;
11468 tile(node, x0, y0, x1, y1);
11472 treemap.round =
function(x) {
11473 return arguments.length ? (round = !!x, treemap) : round;
11476 treemap.size =
function(x) {
11477 return arguments.length ? (dx = +x[0], dy = +x[1], treemap) : [dx, dy];
11480 treemap.tile =
function(x) {
11481 return arguments.length ? (tile = required(x), treemap) : tile;
11484 treemap.padding =
function(x) {
11485 return arguments.length ? treemap.paddingInner(x).paddingOuter(x) : treemap.paddingInner();
11488 treemap.paddingInner =
function(x) {
11489 return arguments.length ? (paddingInner = typeof x ===
"function" ? x : constant$9(+x), treemap) : paddingInner;
11492 treemap.paddingOuter =
function(x) {
11493 return arguments.length ? treemap.paddingTop(x).paddingRight(x).paddingBottom(x).paddingLeft(x) : treemap.paddingTop();
11496 treemap.paddingTop =
function(x) {
11497 return arguments.length ? (paddingTop = typeof x ===
"function" ? x : constant$9(+x), treemap) : paddingTop;
11500 treemap.paddingRight =
function(x) {
11501 return arguments.length ? (paddingRight = typeof x ===
"function" ? x : constant$9(+x), treemap) : paddingRight;
11504 treemap.paddingBottom =
function(x) {
11505 return arguments.length ? (paddingBottom = typeof x ===
"function" ? x : constant$9(+x), treemap) : paddingBottom;
11508 treemap.paddingLeft =
function(x) {
11509 return arguments.length ? (paddingLeft = typeof x ===
"function" ? x : constant$9(+x), treemap) : paddingLeft;
11515 function binary(parent, x0, y0, x1, y1) {
11516 var nodes = parent.children,
11517 i, n = nodes.length,
11518 sum, sums =
new Array(n + 1);
11520 for (sums[0] = sum = i = 0; i < n; ++i) {
11521 sums[i + 1] = sum += nodes[i].value;
11524 partition(0, n, parent.value, x0, y0, x1, y1);
11526 function partition(i, j, value, x0, y0, x1, y1) {
11528 var node = nodes[i];
11529 node.x0 = x0, node.y0 = y0;
11530 node.x1 = x1, node.y1 = y1;
11534 var valueOffset = sums[i],
11535 valueTarget = (value / 2) + valueOffset,
11540 var mid = k + hi >>> 1;
11541 if (sums[mid] < valueTarget) k = mid + 1;
11545 if ((valueTarget - sums[k - 1]) < (sums[k] - valueTarget) && i + 1 < k) --k;
11547 var valueLeft = sums[k] - valueOffset,
11548 valueRight = value - valueLeft;
11550 if ((x1 - x0) > (y1 - y0)) {
11551 var xk = (x0 * valueRight + x1 * valueLeft) / value;
11552 partition(i, k, valueLeft, x0, y0, xk, y1);
11553 partition(k, j, valueRight, xk, y0, x1, y1);
11555 var yk = (y0 * valueRight + y1 * valueLeft) / value;
11556 partition(i, k, valueLeft, x0, y0, x1, yk);
11557 partition(k, j, valueRight, x0, yk, x1, y1);
11562 function sliceDice(parent, x0, y0, x1, y1) {
11563 (parent.depth & 1 ? treemapSlice : treemapDice)(parent, x0, y0, x1, y1);
11566 var resquarify = (
function custom(ratio) {
11568 function resquarify(parent, x0, y0, x1, y1) {
11569 if ((rows = parent._squarify) && (rows.ratio === ratio)) {
11577 value = parent.value;
11580 row = rows[j], nodes = row.children;
11581 for (i = row.value = 0, n = nodes.length; i < n; ++i) row.value += nodes[i].value;
11582 if (row.dice) treemapDice(row, x0, y0, x1, y0 += (y1 - y0) * row.value / value);
11583 else treemapSlice(row, x0, y0, x0 += (x1 - x0) * row.value / value, y1);
11584 value -= row.value;
11587 parent._squarify = rows = squarifyRatio(ratio, parent, x0, y0, x1, y1);
11588 rows.ratio = ratio;
11592 resquarify.ratio =
function(x) {
11593 return custom((x = +x) > 1 ? x : 1);
11599 function area$2(polygon) {
11601 n = polygon.length,
11603 b = polygon[n - 1],
11609 area += a[1] * b[0] - a[0] * b[1];
11615 function centroid$1(polygon) {
11617 n = polygon.length,
11621 b = polygon[n - 1],
11628 k += c = a[0] * b[1] - b[0] * a[1];
11629 x += (a[0] + b[0]) * c;
11630 y += (a[1] + b[1]) * c;
11633 return k *= 3, [x / k, y / k];
11640 function cross$1(a, b, c) {
11641 return (b[0] - a[0]) * (c[1] - a[1]) - (b[1] - a[1]) * (c[0] - a[0]);
11644 function lexicographicOrder(a, b) {
11645 return a[0] - b[0] || a[1] - b[1];
11651 function computeUpperHullIndexes(points) {
11652 var n = points.length,
11656 for (var i = 2; i < n; ++i) {
11657 while (size > 1 && cross$1(points[indexes[size - 2]], points[indexes[size - 1]], points[i]) <= 0) --size;
11658 indexes[size++] = i;
11661 return indexes.slice(0, size);
11664 function hull(points) {
11665 if ((n = points.length) < 3)
return null;
11669 sortedPoints =
new Array(n),
11670 flippedPoints =
new Array(n);
11672 for (i = 0; i < n; ++i) sortedPoints[i] = [+points[i][0], +points[i][1], i];
11673 sortedPoints.sort(lexicographicOrder);
11674 for (i = 0; i < n; ++i) flippedPoints[i] = [sortedPoints[i][0], -sortedPoints[i][1]];
11676 var upperIndexes = computeUpperHullIndexes(sortedPoints),
11677 lowerIndexes = computeUpperHullIndexes(flippedPoints);
11680 var skipLeft = lowerIndexes[0] === upperIndexes[0],
11681 skipRight = lowerIndexes[lowerIndexes.length - 1] === upperIndexes[upperIndexes.length - 1],
11686 for (i = upperIndexes.length - 1; i >= 0; --i) hull.push(points[sortedPoints[upperIndexes[i]][2]]);
11687 for (i = +skipLeft; i < lowerIndexes.length - skipRight; ++i) hull.push(points[sortedPoints[lowerIndexes[i]][2]]);
11692 function contains$2(polygon, point) {
11693 var n = polygon.length,
11694 p = polygon[n - 1],
11695 x = point[0], y = point[1],
11696 x0 = p[0], y0 = p[1],
11700 for (var i = 0; i < n; ++i) {
11701 p = polygon[i], x1 = p[0], y1 = p[1];
11702 if (((y1 > y) !== (y0 > y)) && (x < (x0 - x1) * (y - y1) / (y0 - y1) + x1)) inside = !inside;
11709 function length$2(polygon) {
11711 n = polygon.length,
11712 b = polygon[n - 1],
11727 perimeter += Math.sqrt(xa * xa + ya * ya);
11733 function defaultSource$1() {
11734 return Math.random();
11737 var uniform = (
function sourceRandomUniform(source) {
11738 function randomUniform(min, max) {
11739 min = min == null ? 0 : +min;
11740 max = max == null ? 1 : +max;
11741 if (arguments.length === 1) max = min, min = 0;
11743 return function() {
11744 return source() * max + min;
11748 randomUniform.source = sourceRandomUniform;
11750 return randomUniform;
11751 })(defaultSource$1);
11753 var normal = (
function sourceRandomNormal(source) {
11754 function randomNormal(mu, sigma) {
11756 mu = mu == null ? 0 : +mu;
11757 sigma = sigma == null ? 1 : +sigma;
11758 return function() {
11762 if (x != null) y = x, x = null;
11766 x = source() * 2 - 1;
11767 y = source() * 2 - 1;
11769 }
while (!r || r > 1);
11771 return mu + sigma * y * Math.sqrt(-2 * Math.log(r) / r);
11775 randomNormal.source = sourceRandomNormal;
11777 return randomNormal;
11778 })(defaultSource$1);
11780 var logNormal = (
function sourceRandomLogNormal(source) {
11781 function randomLogNormal() {
11782 var randomNormal = normal.source(source).apply(
this, arguments);
11783 return function() {
11784 return Math.exp(randomNormal());
11788 randomLogNormal.source = sourceRandomLogNormal;
11790 return randomLogNormal;
11791 })(defaultSource$1);
11793 var irwinHall = (
function sourceRandomIrwinHall(source) {
11794 function randomIrwinHall(n) {
11795 return function() {
11796 for (var sum = 0, i = 0; i < n; ++i) sum += source();
11801 randomIrwinHall.source = sourceRandomIrwinHall;
11803 return randomIrwinHall;
11804 })(defaultSource$1);
11806 var bates = (
function sourceRandomBates(source) {
11807 function randomBates(n) {
11808 var randomIrwinHall = irwinHall.source(source)(n);
11809 return function() {
11810 return randomIrwinHall() / n;
11814 randomBates.source = sourceRandomBates;
11816 return randomBates;
11817 })(defaultSource$1);
11819 var exponential$1 = (
function sourceRandomExponential(source) {
11820 function randomExponential(lambda) {
11821 return function() {
11822 return -Math.log(1 - source()) / lambda;
11826 randomExponential.source = sourceRandomExponential;
11828 return randomExponential;
11829 })(defaultSource$1);
11831 var array$3 = Array.prototype;
11833 var map$2 = array$3.map;
11834 var slice$5 = array$3.slice;
11836 var implicit = {name:
"implicit"};
11838 function ordinal(range) {
11839 var index = map$1(),
11841 unknown = implicit;
11843 range = range == null ? [] : slice$5.call(range);
11845 function scale(d) {
11846 var key = d +
"", i = index.get(key);
11848 if (unknown !== implicit)
return unknown;
11849 index.set(key, i = domain.push(d));
11851 return range[(i - 1) % range.length];
11854 scale.domain =
function(_) {
11855 if (!arguments.length)
return domain.slice();
11856 domain = [], index = map$1();
11857 var i = -1, n = _.length, d, key;
11858 while (++i < n)
if (!index.has(key = (d = _[i]) +
"")) index.set(key, domain.push(d));
11862 scale.range =
function(_) {
11863 return arguments.length ? (range = slice$5.call(_), scale) : range.slice();
11866 scale.unknown =
function(_) {
11867 return arguments.length ? (unknown = _, scale) : unknown;
11870 scale.copy =
function() {
11881 var scale = ordinal().unknown(undefined),
11882 domain = scale.domain,
11883 ordinalRange = scale.range,
11892 delete scale.unknown;
11894 function rescale() {
11895 var n = domain().length,
11896 reverse = range$$1[1] < range$$1[0],
11897 start = range$$1[reverse - 0],
11898 stop = range$$1[1 - reverse];
11899 step = (stop - start) / Math.max(1, n - paddingInner + paddingOuter * 2);
11900 if (round) step = Math.floor(step);
11901 start += (stop - start - step * (n - paddingInner)) * align;
11902 bandwidth = step * (1 - paddingInner);
11903 if (round) start = Math.round(start), bandwidth = Math.round(bandwidth);
11904 var values = sequence(n).map(
function(i) {
return start + step * i; });
11905 return ordinalRange(reverse ? values.reverse() : values);
11908 scale.domain =
function(_) {
11909 return arguments.length ? (domain(_), rescale()) : domain();
11912 scale.range =
function(_) {
11913 return arguments.length ? (range$$1 = [+_[0], +_[1]], rescale()) : range$$1.slice();
11916 scale.rangeRound =
function(_) {
11917 return range$$1 = [+_[0], +_[1]], round =
true, rescale();
11920 scale.bandwidth =
function() {
11924 scale.step =
function() {
11928 scale.round =
function(_) {
11929 return arguments.length ? (round = !!_, rescale()) : round;
11932 scale.padding =
function(_) {
11933 return arguments.length ? (paddingInner = paddingOuter = Math.max(0, Math.min(1, _)), rescale()) : paddingInner;
11936 scale.paddingInner =
function(_) {
11937 return arguments.length ? (paddingInner = Math.max(0, Math.min(1, _)), rescale()) : paddingInner;
11940 scale.paddingOuter =
function(_) {
11941 return arguments.length ? (paddingOuter = Math.max(0, Math.min(1, _)), rescale()) : paddingOuter;
11944 scale.align =
function(_) {
11945 return arguments.length ? (align = Math.max(0, Math.min(1, _)), rescale()) : align;
11948 scale.copy =
function() {
11953 .paddingInner(paddingInner)
11954 .paddingOuter(paddingOuter)
11961 function pointish(scale) {
11962 var copy = scale.copy;
11964 scale.padding = scale.paddingOuter;
11965 delete scale.paddingInner;
11966 delete scale.paddingOuter;
11968 scale.copy =
function() {
11969 return pointish(copy());
11975 function point$1() {
11976 return pointish(band().paddingInner(1));
11979 function constant$a(x) {
11980 return function() {
11985 function number$2(x) {
11991 function deinterpolateLinear(a, b) {
11992 return (b -= (a = +a))
11993 ?
function(x) {
return (x - a) / b; }
11997 function deinterpolateClamp(deinterpolate) {
11998 return function(a, b) {
11999 var d = deinterpolate(a = +a, b = +b);
12000 return function(x) {
return x <= a ? 0 : x >= b ? 1 : d(x); };
12004 function reinterpolateClamp(reinterpolate) {
12005 return function(a, b) {
12006 var r = reinterpolate(a = +a, b = +b);
12007 return function(t) {
return t <= 0 ? a : t >= 1 ? b : r(t); };
12011 function bimap(domain, range, deinterpolate, reinterpolate) {
12012 var d0 = domain[0], d1 = domain[1], r0 = range[0], r1 = range[1];
12013 if (d1 < d0) d0 = deinterpolate(d1, d0), r0 = reinterpolate(r1, r0);
12014 else d0 = deinterpolate(d0, d1), r0 = reinterpolate(r0, r1);
12015 return function(x) {
return r0(d0(x)); };
12018 function polymap(domain, range, deinterpolate, reinterpolate) {
12019 var j = Math.min(domain.length, range.length) - 1,
12025 if (domain[j] < domain[0]) {
12026 domain = domain.slice().reverse();
12027 range = range.slice().reverse();
12031 d[i] = deinterpolate(domain[i], domain[i + 1]);
12032 r[i] = reinterpolate(range[i], range[i + 1]);
12035 return function(x) {
12036 var i = bisectRight(domain, x, 1, j) - 1;
12037 return r[i](d[i](x));
12041 function copy(source, target) {
12043 .domain(source.domain())
12044 .range(source.range())
12045 .interpolate(source.interpolate())
12046 .clamp(source.clamp());
12051 function continuous(deinterpolate, reinterpolate) {
12054 interpolate$$1 = interpolateValue,
12060 function rescale() {
12061 piecewise$$1 = Math.min(domain.length, range.length) > 2 ? polymap : bimap;
12062 output = input = null;
12066 function scale(x) {
12067 return (output || (output = piecewise$$1(domain, range, clamp ? deinterpolateClamp(deinterpolate) : deinterpolate, interpolate$$1)))(+x);
12070 scale.invert =
function(y) {
12071 return (input || (input = piecewise$$1(range, domain, deinterpolateLinear, clamp ? reinterpolateClamp(reinterpolate) : reinterpolate)))(+y);
12074 scale.domain =
function(_) {
12075 return arguments.length ? (domain = map$2.call(_, number$2), rescale()) : domain.slice();
12078 scale.range =
function(_) {
12079 return arguments.length ? (range = slice$5.call(_), rescale()) : range.slice();
12082 scale.rangeRound =
function(_) {
12083 return range = slice$5.call(_), interpolate$$1 = interpolateRound, rescale();
12086 scale.clamp =
function(_) {
12087 return arguments.length ? (clamp = !!_, rescale()) : clamp;
12090 scale.interpolate =
function(_) {
12091 return arguments.length ? (interpolate$$1 = _, rescale()) : interpolate$$1;
12097 function tickFormat(domain, count, specifier) {
12098 var start = domain[0],
12099 stop = domain[domain.length - 1],
12100 step = tickStep(start, stop, count == null ? 10 : count),
12102 specifier = formatSpecifier(specifier == null ?
",f" : specifier);
12103 switch (specifier.type) {
12105 var value = Math.max(Math.abs(start), Math.abs(stop));
12106 if (specifier.precision == null && !isNaN(precision = precisionPrefix(step, value))) specifier.precision = precision;
12107 return exports.formatPrefix(specifier, value);
12114 if (specifier.precision == null && !isNaN(precision = precisionRound(step, Math.max(Math.abs(start), Math.abs(stop))))) specifier.precision = precision - (specifier.type ===
"e");
12119 if (specifier.precision == null && !isNaN(precision = precisionFixed(step))) specifier.precision = precision - (specifier.type ===
"%") * 2;
12123 return exports.format(specifier);
12126 function linearish(scale) {
12127 var domain = scale.domain;
12129 scale.ticks =
function(count) {
12131 return ticks(d[0], d[d.length - 1], count == null ? 10 : count);
12134 scale.tickFormat =
function(count, specifier) {
12135 return tickFormat(domain(), count, specifier);
12138 scale.nice =
function(count) {
12139 if (count == null) count = 10;
12148 if (stop < start) {
12149 step = start, start = stop, stop = step;
12150 step = i0, i0 = i1, i1 = step;
12153 step = tickIncrement(start, stop, count);
12156 start = Math.floor(start / step) * step;
12157 stop = Math.ceil(stop / step) * step;
12158 step = tickIncrement(start, stop, count);
12159 }
else if (step < 0) {
12160 start = Math.ceil(start * step) / step;
12161 stop = Math.floor(stop * step) / step;
12162 step = tickIncrement(start, stop, count);
12166 d[i0] = Math.floor(start / step) * step;
12167 d[i1] = Math.ceil(stop / step) * step;
12169 }
else if (step < 0) {
12170 d[i0] = Math.ceil(start * step) / step;
12171 d[i1] = Math.floor(stop * step) / step;
12181 function linear$2() {
12182 var scale = continuous(deinterpolateLinear, interpolateNumber);
12184 scale.copy =
function() {
12185 return copy(scale, linear$2());
12188 return linearish(scale);
12191 function identity$6() {
12192 var domain = [0, 1];
12194 function scale(x) {
12198 scale.invert = scale;
12200 scale.domain = scale.range =
function(_) {
12201 return arguments.length ? (domain = map$2.call(_, number$2), scale) : domain.slice();
12204 scale.copy =
function() {
12205 return identity$6().domain(domain);
12208 return linearish(scale);
12211 function nice(domain, interval) {
12212 domain = domain.slice();
12215 i1 = domain.length - 1,
12221 t = i0, i0 = i1, i1 = t;
12222 t = x0, x0 = x1, x1 = t;
12225 domain[i0] = interval.floor(x0);
12226 domain[i1] = interval.ceil(x1);
12230 function deinterpolate(a, b) {
12231 return (b = Math.log(b / a))
12232 ?
function(x) {
return Math.log(x / a) / b; }
12236 function reinterpolate(a, b) {
12238 ?
function(t) {
return -Math.pow(-b, t) * Math.pow(-a, 1 - t); }
12239 :
function(t) {
return Math.pow(b, t) * Math.pow(a, 1 - t); };
12242 function pow10(x) {
12243 return isFinite(x) ? +(
"1e" + x) : x < 0 ? 0 : x;
12246 function powp(base) {
12247 return base === 10 ? pow10
12248 : base === Math.E ? Math.exp
12249 :
function(x) {
return Math.pow(base, x); };
12252 function logp(base) {
12253 return base === Math.E ? Math.log
12254 : base === 10 && Math.log10
12255 || base === 2 && Math.log2
12256 || (base = Math.log(base),
function(x) {
return Math.log(x) / base; });
12259 function reflect(f) {
12260 return function(x) {
12266 var scale = continuous(deinterpolate, reinterpolate).domain([1, 10]),
12267 domain = scale.domain,
12272 function rescale() {
12273 logs = logp(base), pows = powp(base);
12274 if (domain()[0] < 0) logs = reflect(logs), pows = reflect(pows);
12278 scale.base =
function(_) {
12279 return arguments.length ? (base = +_, rescale()) : base;
12282 scale.domain =
function(_) {
12283 return arguments.length ? (domain(_), rescale()) : domain();
12286 scale.ticks =
function(count) {
12289 v = d[d.length - 1],
12292 if (r = v < u) i = u, u = v, v = i;
12299 n = count == null ? 10 : +count,
12302 if (!(base % 1) && j - i < n) {
12303 i = Math.round(i) - 1, j = Math.round(j) + 1;
12304 if (u > 0)
for (; i < j; ++i) {
12305 for (k = 1, p = pows(i); k < base; ++k) {
12307 if (t < u)
continue;
12311 }
else for (; i < j; ++i) {
12312 for (k = base - 1, p = pows(i); k >= 1; --k) {
12314 if (t < u)
continue;
12320 z = ticks(i, j, Math.min(j - i, n)).map(pows);
12323 return r ? z.reverse() : z;
12326 scale.tickFormat =
function(count, specifier) {
12327 if (specifier == null) specifier = base === 10 ?
".0e" :
",";
12328 if (typeof specifier !==
"function") specifier = exports.format(specifier);
12329 if (count === Infinity)
return specifier;
12330 if (count == null) count = 10;
12331 var k = Math.max(1, base * count / scale.ticks().length);
12332 return function(d) {
12333 var i = d / pows(Math.round(logs(d)));
12334 if (i * base < base - 0.5) i *= base;
12335 return i <= k ? specifier(d) :
"";
12339 scale.nice =
function() {
12340 return domain(nice(domain(), {
12341 floor:
function(x) {
return pows(Math.floor(logs(x))); },
12342 ceil:
function(x) {
return pows(Math.ceil(logs(x))); }
12346 scale.copy =
function() {
12347 return copy(scale, log$1().base(base));
12353 function raise$1(x, exponent) {
12354 return x < 0 ? -Math.pow(-x, exponent) : Math.pow(x, exponent);
12359 scale = continuous(deinterpolate, reinterpolate),
12360 domain = scale.domain;
12362 function deinterpolate(a, b) {
12363 return (b =
raise$1(b, exponent) - (a =
raise$1(a, exponent)))
12364 ?
function(x) {
return (
raise$1(x, exponent) - a) / b; }
12368 function reinterpolate(a, b) {
12369 b =
raise$1(b, exponent) - (a =
raise$1(a, exponent));
12370 return function(t) {
return raise$1(a + b * t, 1 / exponent); };
12373 scale.exponent =
function(_) {
12374 return arguments.length ? (exponent = +_, domain(domain())) : exponent;
12377 scale.copy =
function() {
12378 return copy(scale, pow$1().exponent(exponent));
12381 return linearish(scale);
12384 function sqrt$1() {
12385 return pow$1().exponent(0.5);
12388 function quantile$$1() {
12393 function rescale() {
12394 var i = 0, n = Math.max(1, range.length);
12395 thresholds =
new Array(n - 1);
12396 while (++i < n) thresholds[i - 1] = threshold(domain, i / n);
12400 function scale(x) {
12401 if (!isNaN(x = +x))
return range[bisectRight(thresholds, x)];
12404 scale.invertExtent =
function(y) {
12405 var i = range.indexOf(y);
12406 return i < 0 ? [NaN, NaN] : [
12407 i > 0 ? thresholds[i - 1] : domain[0],
12408 i < thresholds.length ? thresholds[i] : domain[domain.length - 1]
12412 scale.domain =
function(_) {
12413 if (!arguments.length)
return domain.slice();
12415 for (var i = 0, n = _.length, d; i < n; ++i)
if (d = _[i], d != null && !isNaN(d = +d)) domain.push(d);
12416 domain.sort(ascending);
12420 scale.range =
function(_) {
12421 return arguments.length ? (range = slice$5.call(_), rescale()) : range.slice();
12424 scale.quantiles =
function() {
12425 return thresholds.slice();
12428 scale.copy =
function() {
12429 return quantile$$1()
12437 function quantize$1() {
12444 function scale(x) {
12445 if (x <= x)
return range[bisectRight(domain, x, 0, n)];
12448 function rescale() {
12450 domain =
new Array(n);
12451 while (++i < n) domain[i] = ((i + 1) * x1 - (i - n) * x0) / (n + 1);
12455 scale.domain =
function(_) {
12456 return arguments.length ? (x0 = +_[0], x1 = +_[1], rescale()) : [x0, x1];
12459 scale.range =
function(_) {
12460 return arguments.length ? (n = (range = slice$5.call(_)).length - 1, rescale()) : range.slice();
12463 scale.invertExtent =
function(y) {
12464 var i = range.indexOf(y);
12465 return i < 0 ? [NaN, NaN]
12466 : i < 1 ? [x0, domain[0]]
12467 : i >= n ? [domain[n - 1], x1]
12468 : [domain[i - 1], domain[i]];
12471 scale.copy =
function() {
12472 return quantize$1()
12477 return linearish(scale);
12480 function threshold$1() {
12481 var domain = [0.5],
12485 function scale(x) {
12486 if (x <= x)
return range[bisectRight(domain, x, 0, n)];
12489 scale.domain =
function(_) {
12490 return arguments.length ? (domain = slice$5.call(_), n = Math.min(domain.length, range.length - 1), scale) : domain.slice();
12493 scale.range =
function(_) {
12494 return arguments.length ? (range = slice$5.call(_), n = Math.min(domain.length, range.length - 1), scale) : range.slice();
12497 scale.invertExtent =
function(y) {
12498 var i = range.indexOf(y);
12499 return [domain[i - 1], domain[i]];
12502 scale.copy =
function() {
12503 return threshold$1()
12511 var t0$1 =
new Date,
12514 function newInterval(floori, offseti, count, field) {
12516 function interval(date) {
12517 return floori(date =
new Date(+date)), date;
12520 interval.floor = interval;
12522 interval.ceil =
function(date) {
12523 return floori(date =
new Date(date - 1)), offseti(date, 1), floori(date), date;
12526 interval.round =
function(date) {
12527 var d0 = interval(date),
12528 d1 = interval.ceil(date);
12529 return date - d0 < d1 - date ? d0 : d1;
12532 interval.offset =
function(date, step) {
12533 return offseti(date =
new Date(+date), step == null ? 1 : Math.floor(step)), date;
12536 interval.range =
function(start, stop, step) {
12537 var range = [], previous;
12538 start = interval.ceil(start);
12539 step = step == null ? 1 : Math.floor(step);
12540 if (!(start < stop) || !(step > 0))
return range;
12541 do range.push(previous =
new Date(+start)), offseti(start, step), floori(start);
12542 while (previous < start && start < stop);
12546 interval.filter =
function(test) {
12547 return newInterval(
function(date) {
12548 if (date >= date)
while (floori(date), !test(date)) date.setTime(date - 1);
12549 },
function(date, step) {
12550 if (date >= date) {
12551 if (step < 0)
while (++step <= 0) {
12552 while (offseti(date, -1), !test(date)) {}
12553 }
else while (--step >= 0) {
12554 while (offseti(date, +1), !test(date)) {}
12561 interval.count =
function(start, end) {
12562 t0$1.setTime(+start), t1$1.setTime(+end);
12563 floori(t0$1), floori(t1$1);
12564 return Math.floor(count(t0$1, t1$1));
12567 interval.every =
function(step) {
12568 step = Math.floor(step);
12569 return !isFinite(step) || !(step > 0) ? null
12570 : !(step > 1) ? interval
12571 : interval.filter(field
12572 ?
function(d) {
return field(d) % step === 0; }
12573 :
function(d) {
return interval.count(0, d) % step === 0; });
12580 var millisecond = newInterval(
function() {
12582 },
function(date, step) {
12583 date.setTime(+date + step);
12584 },
function(start, end) {
12585 return end - start;
12589 millisecond.every =
function(k) {
12591 if (!isFinite(k) || !(k > 0))
return null;
12592 if (!(k > 1))
return millisecond;
12593 return newInterval(
function(date) {
12594 date.setTime(Math.floor(date / k) * k);
12595 },
function(date, step) {
12596 date.setTime(+date + step * k);
12597 },
function(start, end) {
12598 return (end - start) / k;
12601 var milliseconds = millisecond.range;
12603 var durationSecond = 1e3;
12604 var durationMinute = 6e4;
12605 var durationHour = 36e5;
12606 var durationDay = 864e5;
12607 var durationWeek = 6048e5;
12609 var second = newInterval(
function(date) {
12610 date.setTime(Math.floor(date / durationSecond) * durationSecond);
12611 },
function(date, step) {
12612 date.setTime(+date + step * durationSecond);
12613 },
function(start, end) {
12614 return (end - start) / durationSecond;
12615 },
function(date) {
12616 return date.getUTCSeconds();
12618 var seconds = second.range;
12620 var minute = newInterval(
function(date) {
12621 date.setTime(Math.floor(date / durationMinute) * durationMinute);
12622 },
function(date, step) {
12623 date.setTime(+date + step * durationMinute);
12624 },
function(start, end) {
12625 return (end - start) / durationMinute;
12626 },
function(date) {
12627 return date.getMinutes();
12629 var minutes = minute.range;
12631 var hour = newInterval(
function(date) {
12632 var offset = date.getTimezoneOffset() * durationMinute % durationHour;
12633 if (offset < 0) offset += durationHour;
12634 date.setTime(Math.floor((+date - offset) / durationHour) * durationHour + offset);
12635 },
function(date, step) {
12636 date.setTime(+date + step * durationHour);
12637 },
function(start, end) {
12638 return (end - start) / durationHour;
12639 },
function(date) {
12640 return date.getHours();
12642 var hours = hour.range;
12644 var day = newInterval(
function(date) {
12645 date.setHours(0, 0, 0, 0);
12646 },
function(date, step) {
12647 date.setDate(date.getDate() + step);
12648 },
function(start, end) {
12649 return (end - start - (end.getTimezoneOffset() - start.getTimezoneOffset()) * durationMinute) / durationDay;
12650 },
function(date) {
12651 return date.getDate() - 1;
12653 var days = day.range;
12655 function weekday(i) {
12656 return newInterval(
function(date) {
12657 date.setDate(date.getDate() - (date.getDay() + 7 - i) % 7);
12658 date.setHours(0, 0, 0, 0);
12659 },
function(date, step) {
12660 date.setDate(date.getDate() + step * 7);
12661 },
function(start, end) {
12662 return (end - start - (end.getTimezoneOffset() - start.getTimezoneOffset()) * durationMinute) / durationWeek;
12666 var sunday = weekday(0);
12667 var monday = weekday(1);
12668 var tuesday = weekday(2);
12669 var wednesday = weekday(3);
12670 var thursday = weekday(4);
12671 var friday = weekday(5);
12672 var saturday = weekday(6);
12674 var sundays = sunday.range;
12675 var mondays = monday.range;
12676 var tuesdays = tuesday.range;
12677 var wednesdays = wednesday.range;
12678 var thursdays = thursday.range;
12679 var fridays = friday.range;
12680 var saturdays = saturday.range;
12682 var month = newInterval(
function(date) {
12684 date.setHours(0, 0, 0, 0);
12685 },
function(date, step) {
12686 date.setMonth(date.getMonth() + step);
12687 },
function(start, end) {
12688 return end.getMonth() - start.getMonth() + (end.getFullYear() - start.getFullYear()) * 12;
12689 },
function(date) {
12690 return date.getMonth();
12692 var months = month.range;
12694 var year = newInterval(
function(date) {
12695 date.setMonth(0, 1);
12696 date.setHours(0, 0, 0, 0);
12697 },
function(date, step) {
12698 date.setFullYear(date.getFullYear() + step);
12699 },
function(start, end) {
12700 return end.getFullYear() - start.getFullYear();
12701 },
function(date) {
12702 return date.getFullYear();
12706 year.every =
function(k) {
12707 return !isFinite(k = Math.floor(k)) || !(k > 0) ? null : newInterval(
function(date) {
12708 date.setFullYear(Math.floor(date.getFullYear() / k) * k);
12709 date.setMonth(0, 1);
12710 date.setHours(0, 0, 0, 0);
12711 },
function(date, step) {
12712 date.setFullYear(date.getFullYear() + step * k);
12715 var years = year.range;
12717 var utcMinute = newInterval(
function(date) {
12718 date.setUTCSeconds(0, 0);
12719 },
function(date, step) {
12720 date.setTime(+date + step * durationMinute);
12721 },
function(start, end) {
12722 return (end - start) / durationMinute;
12723 },
function(date) {
12724 return date.getUTCMinutes();
12726 var utcMinutes = utcMinute.range;
12728 var utcHour = newInterval(
function(date) {
12729 date.setUTCMinutes(0, 0, 0);
12730 },
function(date, step) {
12731 date.setTime(+date + step * durationHour);
12732 },
function(start, end) {
12733 return (end - start) / durationHour;
12734 },
function(date) {
12735 return date.getUTCHours();
12737 var utcHours = utcHour.range;
12739 var utcDay = newInterval(
function(date) {
12740 date.setUTCHours(0, 0, 0, 0);
12741 },
function(date, step) {
12742 date.setUTCDate(date.getUTCDate() + step);
12743 },
function(start, end) {
12744 return (end - start) / durationDay;
12745 },
function(date) {
12746 return date.getUTCDate() - 1;
12748 var utcDays = utcDay.range;
12750 function utcWeekday(i) {
12751 return newInterval(
function(date) {
12752 date.setUTCDate(date.getUTCDate() - (date.getUTCDay() + 7 - i) % 7);
12753 date.setUTCHours(0, 0, 0, 0);
12754 },
function(date, step) {
12755 date.setUTCDate(date.getUTCDate() + step * 7);
12756 },
function(start, end) {
12757 return (end - start) / durationWeek;
12761 var utcSunday = utcWeekday(0);
12762 var utcMonday = utcWeekday(1);
12763 var utcTuesday = utcWeekday(2);
12764 var utcWednesday = utcWeekday(3);
12765 var utcThursday = utcWeekday(4);
12766 var utcFriday = utcWeekday(5);
12767 var utcSaturday = utcWeekday(6);
12769 var utcSundays = utcSunday.range;
12770 var utcMondays = utcMonday.range;
12771 var utcTuesdays = utcTuesday.range;
12772 var utcWednesdays = utcWednesday.range;
12773 var utcThursdays = utcThursday.range;
12774 var utcFridays = utcFriday.range;
12775 var utcSaturdays = utcSaturday.range;
12777 var utcMonth = newInterval(
function(date) {
12778 date.setUTCDate(1);
12779 date.setUTCHours(0, 0, 0, 0);
12780 },
function(date, step) {
12781 date.setUTCMonth(date.getUTCMonth() + step);
12782 },
function(start, end) {
12783 return end.getUTCMonth() - start.getUTCMonth() + (end.getUTCFullYear() - start.getUTCFullYear()) * 12;
12784 },
function(date) {
12785 return date.getUTCMonth();
12787 var utcMonths = utcMonth.range;
12789 var utcYear = newInterval(
function(date) {
12790 date.setUTCMonth(0, 1);
12791 date.setUTCHours(0, 0, 0, 0);
12792 },
function(date, step) {
12793 date.setUTCFullYear(date.getUTCFullYear() + step);
12794 },
function(start, end) {
12795 return end.getUTCFullYear() - start.getUTCFullYear();
12796 },
function(date) {
12797 return date.getUTCFullYear();
12801 utcYear.every =
function(k) {
12802 return !isFinite(k = Math.floor(k)) || !(k > 0) ? null : newInterval(
function(date) {
12803 date.setUTCFullYear(Math.floor(date.getUTCFullYear() / k) * k);
12804 date.setUTCMonth(0, 1);
12805 date.setUTCHours(0, 0, 0, 0);
12806 },
function(date, step) {
12807 date.setUTCFullYear(date.getUTCFullYear() + step * k);
12810 var utcYears = utcYear.range;
12812 function localDate(d) {
12813 if (0 <= d.y && d.y < 100) {
12814 var date =
new Date(-1, d.m, d.d, d.H, d.M, d.S, d.L);
12815 date.setFullYear(d.y);
12818 return new Date(d.y, d.m, d.d, d.H, d.M, d.S, d.L);
12821 function utcDate(d) {
12822 if (0 <= d.y && d.y < 100) {
12823 var date =
new Date(Date.UTC(-1, d.m, d.d, d.H, d.M, d.S, d.L));
12824 date.setUTCFullYear(d.y);
12827 return new Date(Date.UTC(d.y, d.m, d.d, d.H, d.M, d.S, d.L));
12830 function newYear(y) {
12831 return {y: y, m: 0, d: 1, H: 0, M: 0, S: 0, L: 0};
12834 function formatLocale$1(locale) {
12835 var locale_dateTime = locale.dateTime,
12836 locale_date = locale.date,
12837 locale_time = locale.time,
12838 locale_periods = locale.periods,
12839 locale_weekdays = locale.days,
12840 locale_shortWeekdays = locale.shortDays,
12841 locale_months = locale.months,
12842 locale_shortMonths = locale.shortMonths;
12844 var periodRe = formatRe(locale_periods),
12845 periodLookup = formatLookup(locale_periods),
12846 weekdayRe = formatRe(locale_weekdays),
12847 weekdayLookup = formatLookup(locale_weekdays),
12848 shortWeekdayRe = formatRe(locale_shortWeekdays),
12849 shortWeekdayLookup = formatLookup(locale_shortWeekdays),
12850 monthRe = formatRe(locale_months),
12851 monthLookup = formatLookup(locale_months),
12852 shortMonthRe = formatRe(locale_shortMonths),
12853 shortMonthLookup = formatLookup(locale_shortMonths);
12856 "a": formatShortWeekday,
12857 "A": formatWeekday,
12858 "b": formatShortMonth,
12861 "d": formatDayOfMonth,
12862 "e": formatDayOfMonth,
12863 "f": formatMicroseconds,
12866 "j": formatDayOfYear,
12867 "L": formatMilliseconds,
12868 "m": formatMonthNumber,
12869 "M": formatMinutes,
12871 "Q": formatUnixTimestamp,
12872 "s": formatUnixTimestampSeconds,
12873 "S": formatSeconds,
12874 "u": formatWeekdayNumberMonday,
12875 "U": formatWeekNumberSunday,
12876 "V": formatWeekNumberISO,
12877 "w": formatWeekdayNumberSunday,
12878 "W": formatWeekNumberMonday,
12882 "Y": formatFullYear,
12884 "%": formatLiteralPercent
12888 "a": formatUTCShortWeekday,
12889 "A": formatUTCWeekday,
12890 "b": formatUTCShortMonth,
12891 "B": formatUTCMonth,
12893 "d": formatUTCDayOfMonth,
12894 "e": formatUTCDayOfMonth,
12895 "f": formatUTCMicroseconds,
12896 "H": formatUTCHour24,
12897 "I": formatUTCHour12,
12898 "j": formatUTCDayOfYear,
12899 "L": formatUTCMilliseconds,
12900 "m": formatUTCMonthNumber,
12901 "M": formatUTCMinutes,
12902 "p": formatUTCPeriod,
12903 "Q": formatUnixTimestamp,
12904 "s": formatUnixTimestampSeconds,
12905 "S": formatUTCSeconds,
12906 "u": formatUTCWeekdayNumberMonday,
12907 "U": formatUTCWeekNumberSunday,
12908 "V": formatUTCWeekNumberISO,
12909 "w": formatUTCWeekdayNumberSunday,
12910 "W": formatUTCWeekNumberMonday,
12913 "y": formatUTCYear,
12914 "Y": formatUTCFullYear,
12915 "Z": formatUTCZone,
12916 "%": formatLiteralPercent
12920 "a": parseShortWeekday,
12922 "b": parseShortMonth,
12924 "c": parseLocaleDateTime,
12925 "d": parseDayOfMonth,
12926 "e": parseDayOfMonth,
12927 "f": parseMicroseconds,
12930 "j": parseDayOfYear,
12931 "L": parseMilliseconds,
12932 "m": parseMonthNumber,
12935 "Q": parseUnixTimestamp,
12936 "s": parseUnixTimestampSeconds,
12938 "u": parseWeekdayNumberMonday,
12939 "U": parseWeekNumberSunday,
12940 "V": parseWeekNumberISO,
12941 "w": parseWeekdayNumberSunday,
12942 "W": parseWeekNumberMonday,
12943 "x": parseLocaleDate,
12944 "X": parseLocaleTime,
12946 "Y": parseFullYear,
12948 "%": parseLiteralPercent
12952 formats.x = newFormat(locale_date, formats);
12953 formats.X = newFormat(locale_time, formats);
12954 formats.c = newFormat(locale_dateTime, formats);
12955 utcFormats.x = newFormat(locale_date, utcFormats);
12956 utcFormats.X = newFormat(locale_time, utcFormats);
12957 utcFormats.c = newFormat(locale_dateTime, utcFormats);
12959 function newFormat(specifier, formats) {
12960 return function(date) {
12964 n = specifier.length,
12969 if (!(date instanceof Date)) date =
new Date(+date);
12972 if (specifier.charCodeAt(i) === 37) {
12973 string.push(specifier.slice(j, i));
12974 if ((pad = pads[c = specifier.charAt(++i)]) != null) c = specifier.charAt(++i);
12975 else pad = c ===
"e" ?
" " :
"0";
12976 if (format = formats[c]) c = format(date, pad);
12982 string.push(specifier.slice(j, i));
12983 return string.join(
"");
12987 function newParse(specifier, newDate) {
12988 return function(string) {
12989 var d = newYear(1900),
12990 i = parseSpecifier(d, specifier,
string +=
"", 0),
12992 if (i !=
string.length)
return null;
12995 if (
"Q" in d)
return new Date(d.Q);
12998 if (
"p" in d) d.H = d.H % 12 + d.p * 12;
13002 if (d.V < 1 || d.V > 53)
return null;
13003 if (!(
"w" in d)) d.w = 1;
13005 week = utcDate(newYear(d.y)), day$$1 = week.getUTCDay();
13006 week = day$$1 > 4 || day$$1 === 0 ? utcMonday.ceil(week) : utcMonday(week);
13007 week = utcDay.offset(week, (d.V - 1) * 7);
13008 d.y = week.getUTCFullYear();
13009 d.m = week.getUTCMonth();
13010 d.d = week.getUTCDate() + (d.w + 6) % 7;
13012 week = newDate(newYear(d.y)), day$$1 = week.getDay();
13013 week = day$$1 > 4 || day$$1 === 0 ? monday.ceil(week) : monday(week);
13014 week = day.offset(week, (d.V - 1) * 7);
13015 d.y = week.getFullYear();
13016 d.m = week.getMonth();
13017 d.d = week.getDate() + (d.w + 6) % 7;
13019 }
else if (
"W" in d ||
"U" in d) {
13020 if (!(
"w" in d)) d.w =
"u" in d ? d.u % 7 :
"W" in d ? 1 : 0;
13021 day$$1 =
"Z" in d ? utcDate(newYear(d.y)).getUTCDay() : newDate(newYear(d.y)).getDay();
13023 d.d =
"W" in d ? (d.w + 6) % 7 + d.W * 7 - (day$$1 + 5) % 7 : d.w + d.U * 7 - (day$$1 + 6) % 7;
13029 d.H += d.Z / 100 | 0;
13039 function parseSpecifier(d, specifier,
string, j) {
13041 n = specifier.length,
13047 if (j >= m)
return -1;
13048 c = specifier.charCodeAt(i++);
13050 c = specifier.charAt(i++);
13051 parse = parses[c in pads ? specifier.charAt(i++) : c];
13052 if (!parse || ((j = parse(d,
string, j)) < 0))
return -1;
13053 }
else if (c !=
string.charCodeAt(j++)) {
13061 function parsePeriod(d,
string, i) {
13062 var n = periodRe.exec(
string.slice(i));
13063 return n ? (d.p = periodLookup[n[0].toLowerCase()], i + n[0].length) : -1;
13066 function parseShortWeekday(d,
string, i) {
13067 var n = shortWeekdayRe.exec(
string.slice(i));
13068 return n ? (d.w = shortWeekdayLookup[n[0].toLowerCase()], i + n[0].length) : -1;
13071 function parseWeekday(d,
string, i) {
13072 var n = weekdayRe.exec(
string.slice(i));
13073 return n ? (d.w = weekdayLookup[n[0].toLowerCase()], i + n[0].length) : -1;
13076 function parseShortMonth(d,
string, i) {
13077 var n = shortMonthRe.exec(
string.slice(i));
13078 return n ? (d.m = shortMonthLookup[n[0].toLowerCase()], i + n[0].length) : -1;
13081 function parseMonth(d,
string, i) {
13082 var n = monthRe.exec(
string.slice(i));
13083 return n ? (d.m = monthLookup[n[0].toLowerCase()], i + n[0].length) : -1;
13086 function parseLocaleDateTime(d,
string, i) {
13087 return parseSpecifier(d, locale_dateTime,
string, i);
13090 function parseLocaleDate(d,
string, i) {
13091 return parseSpecifier(d, locale_date,
string, i);
13094 function parseLocaleTime(d,
string, i) {
13095 return parseSpecifier(d, locale_time,
string, i);
13098 function formatShortWeekday(d) {
13099 return locale_shortWeekdays[d.getDay()];
13102 function formatWeekday(d) {
13103 return locale_weekdays[d.getDay()];
13106 function formatShortMonth(d) {
13107 return locale_shortMonths[d.getMonth()];
13110 function formatMonth(d) {
13111 return locale_months[d.getMonth()];
13114 function formatPeriod(d) {
13115 return locale_periods[+(d.getHours() >= 12)];
13118 function formatUTCShortWeekday(d) {
13119 return locale_shortWeekdays[d.getUTCDay()];
13122 function formatUTCWeekday(d) {
13123 return locale_weekdays[d.getUTCDay()];
13126 function formatUTCShortMonth(d) {
13127 return locale_shortMonths[d.getUTCMonth()];
13130 function formatUTCMonth(d) {
13131 return locale_months[d.getUTCMonth()];
13134 function formatUTCPeriod(d) {
13135 return locale_periods[+(d.getUTCHours() >= 12)];
13139 format:
function(specifier) {
13140 var f = newFormat(specifier +=
"", formats);
13141 f.toString =
function() {
return specifier; };
13144 parse:
function(specifier) {
13145 var p = newParse(specifier +=
"", localDate);
13146 p.toString =
function() {
return specifier; };
13149 utcFormat:
function(specifier) {
13150 var f = newFormat(specifier +=
"", utcFormats);
13151 f.toString =
function() {
return specifier; };
13154 utcParse:
function(specifier) {
13155 var p = newParse(specifier, utcDate);
13156 p.toString =
function() {
return specifier; };
13162 var pads = {
"-":
"",
"_":
" ",
"0":
"0"},
13163 numberRe = /^\s*\d+/,
13165 requoteRe = /[\\^$*+?|[\]().{}]/g;
13167 function pad(value, fill, width) {
13168 var sign = value < 0 ?
"-" :
"",
13169 string = (sign ? -value : value) +
"",
13170 length =
string.length;
13171 return sign + (length < width ?
new Array(width - length + 1).join(fill) +
string : string);
13174 function requote(s) {
13175 return s.replace(requoteRe,
"\\$&");
13178 function formatRe(names) {
13179 return new RegExp(
"^(?:" + names.map(requote).join(
"|") +
")",
"i");
13182 function formatLookup(names) {
13183 var map = {}, i = -1, n = names.length;
13184 while (++i < n) map[names[i].toLowerCase()] = i;
13188 function parseWeekdayNumberSunday(d,
string, i) {
13189 var n = numberRe.exec(
string.slice(i, i + 1));
13190 return n ? (d.w = +n[0], i + n[0].length) : -1;
13193 function parseWeekdayNumberMonday(d,
string, i) {
13194 var n = numberRe.exec(
string.slice(i, i + 1));
13195 return n ? (d.u = +n[0], i + n[0].length) : -1;
13198 function parseWeekNumberSunday(d,
string, i) {
13199 var n = numberRe.exec(
string.slice(i, i + 2));
13200 return n ? (d.U = +n[0], i + n[0].length) : -1;
13203 function parseWeekNumberISO(d,
string, i) {
13204 var n = numberRe.exec(
string.slice(i, i + 2));
13205 return n ? (d.V = +n[0], i + n[0].length) : -1;
13208 function parseWeekNumberMonday(d,
string, i) {
13209 var n = numberRe.exec(
string.slice(i, i + 2));
13210 return n ? (d.W = +n[0], i + n[0].length) : -1;
13213 function parseFullYear(d,
string, i) {
13214 var n = numberRe.exec(
string.slice(i, i + 4));
13215 return n ? (d.y = +n[0], i + n[0].length) : -1;
13218 function parseYear(d,
string, i) {
13219 var n = numberRe.exec(
string.slice(i, i + 2));
13220 return n ? (d.y = +n[0] + (+n[0] > 68 ? 1900 : 2000), i + n[0].length) : -1;
13223 function parseZone(d,
string, i) {
13224 var n = /^(Z)|([+-]\d\d)(?::?(\d\d))?/.exec(
string.slice(i, i + 6));
13225 return n ? (d.Z = n[1] ? 0 : -(n[2] + (n[3] ||
"00")), i + n[0].length) : -1;
13228 function parseMonthNumber(d,
string, i) {
13229 var n = numberRe.exec(
string.slice(i, i + 2));
13230 return n ? (d.m = n[0] - 1, i + n[0].length) : -1;
13233 function parseDayOfMonth(d,
string, i) {
13234 var n = numberRe.exec(
string.slice(i, i + 2));
13235 return n ? (d.d = +n[0], i + n[0].length) : -1;
13238 function parseDayOfYear(d,
string, i) {
13239 var n = numberRe.exec(
string.slice(i, i + 3));
13240 return n ? (d.m = 0, d.d = +n[0], i + n[0].length) : -1;
13243 function parseHour24(d,
string, i) {
13244 var n = numberRe.exec(
string.slice(i, i + 2));
13245 return n ? (d.H = +n[0], i + n[0].length) : -1;
13248 function parseMinutes(d,
string, i) {
13249 var n = numberRe.exec(
string.slice(i, i + 2));
13250 return n ? (d.M = +n[0], i + n[0].length) : -1;
13253 function parseSeconds(d,
string, i) {
13254 var n = numberRe.exec(
string.slice(i, i + 2));
13255 return n ? (d.S = +n[0], i + n[0].length) : -1;
13258 function parseMilliseconds(d,
string, i) {
13259 var n = numberRe.exec(
string.slice(i, i + 3));
13260 return n ? (d.L = +n[0], i + n[0].length) : -1;
13263 function parseMicroseconds(d,
string, i) {
13264 var n = numberRe.exec(
string.slice(i, i + 6));
13265 return n ? (d.L = Math.floor(n[0] / 1000), i + n[0].length) : -1;
13268 function parseLiteralPercent(d,
string, i) {
13269 var n = percentRe.exec(
string.slice(i, i + 1));
13270 return n ? i + n[0].length : -1;
13273 function parseUnixTimestamp(d,
string, i) {
13274 var n = numberRe.exec(
string.slice(i));
13275 return n ? (d.Q = +n[0], i + n[0].length) : -1;
13278 function parseUnixTimestampSeconds(d,
string, i) {
13279 var n = numberRe.exec(
string.slice(i));
13280 return n ? (d.Q = (+n[0]) * 1000, i + n[0].length) : -1;
13283 function formatDayOfMonth(d, p) {
13284 return pad(d.getDate(), p, 2);
13287 function formatHour24(d, p) {
13288 return pad(d.getHours(), p, 2);
13291 function formatHour12(d, p) {
13292 return pad(d.getHours() % 12 || 12, p, 2);
13295 function formatDayOfYear(d, p) {
13296 return pad(1 + day.count(year(d), d), p, 3);
13299 function formatMilliseconds(d, p) {
13300 return pad(d.getMilliseconds(), p, 3);
13303 function formatMicroseconds(d, p) {
13304 return formatMilliseconds(d, p) +
"000";
13307 function formatMonthNumber(d, p) {
13308 return pad(d.getMonth() + 1, p, 2);
13311 function formatMinutes(d, p) {
13312 return pad(d.getMinutes(), p, 2);
13315 function formatSeconds(d, p) {
13316 return pad(d.getSeconds(), p, 2);
13319 function formatWeekdayNumberMonday(d) {
13320 var day$$1 = d.getDay();
13321 return day$$1 === 0 ? 7 : day$$1;
13324 function formatWeekNumberSunday(d, p) {
13325 return pad(sunday.count(year(d), d), p, 2);
13328 function formatWeekNumberISO(d, p) {
13329 var day$$1 = d.getDay();
13330 d = (day$$1 >= 4 || day$$1 === 0) ? thursday(d) : thursday.ceil(d);
13331 return pad(thursday.count(year(d), d) + (year(d).getDay() === 4), p, 2);
13334 function formatWeekdayNumberSunday(d) {
13338 function formatWeekNumberMonday(d, p) {
13339 return pad(monday.count(year(d), d), p, 2);
13342 function formatYear(d, p) {
13343 return pad(d.getFullYear() % 100, p, 2);
13346 function formatFullYear(d, p) {
13347 return pad(d.getFullYear() % 10000, p, 4);
13350 function formatZone(d) {
13351 var z = d.getTimezoneOffset();
13352 return (z > 0 ?
"-" : (z *= -1,
"+"))
13353 + pad(z / 60 | 0,
"0", 2)
13354 + pad(z % 60,
"0", 2);
13357 function formatUTCDayOfMonth(d, p) {
13358 return pad(d.getUTCDate(), p, 2);
13361 function formatUTCHour24(d, p) {
13362 return pad(d.getUTCHours(), p, 2);
13365 function formatUTCHour12(d, p) {
13366 return pad(d.getUTCHours() % 12 || 12, p, 2);
13369 function formatUTCDayOfYear(d, p) {
13370 return pad(1 + utcDay.count(utcYear(d), d), p, 3);
13373 function formatUTCMilliseconds(d, p) {
13374 return pad(d.getUTCMilliseconds(), p, 3);
13377 function formatUTCMicroseconds(d, p) {
13378 return formatUTCMilliseconds(d, p) +
"000";
13381 function formatUTCMonthNumber(d, p) {
13382 return pad(d.getUTCMonth() + 1, p, 2);
13385 function formatUTCMinutes(d, p) {
13386 return pad(d.getUTCMinutes(), p, 2);
13389 function formatUTCSeconds(d, p) {
13390 return pad(d.getUTCSeconds(), p, 2);
13393 function formatUTCWeekdayNumberMonday(d) {
13394 var dow = d.getUTCDay();
13395 return dow === 0 ? 7 : dow;
13398 function formatUTCWeekNumberSunday(d, p) {
13399 return pad(utcSunday.count(utcYear(d), d), p, 2);
13402 function formatUTCWeekNumberISO(d, p) {
13403 var day$$1 = d.getUTCDay();
13404 d = (day$$1 >= 4 || day$$1 === 0) ? utcThursday(d) : utcThursday.ceil(d);
13405 return pad(utcThursday.count(utcYear(d), d) + (utcYear(d).getUTCDay() === 4), p, 2);
13408 function formatUTCWeekdayNumberSunday(d) {
13409 return d.getUTCDay();
13412 function formatUTCWeekNumberMonday(d, p) {
13413 return pad(utcMonday.count(utcYear(d), d), p, 2);
13416 function formatUTCYear(d, p) {
13417 return pad(d.getUTCFullYear() % 100, p, 2);
13420 function formatUTCFullYear(d, p) {
13421 return pad(d.getUTCFullYear() % 10000, p, 4);
13424 function formatUTCZone() {
13428 function formatLiteralPercent() {
13432 function formatUnixTimestamp(d) {
13436 function formatUnixTimestampSeconds(d) {
13437 return Math.floor(+d / 1000);
13443 dateTime:
"%x, %X",
13444 date:
"%-m/%-d/%Y",
13445 time:
"%-I:%M:%S %p",
13446 periods: [
"AM",
"PM"],
13447 days: [
"Sunday",
"Monday",
"Tuesday",
"Wednesday",
"Thursday",
"Friday",
"Saturday"],
13448 shortDays: [
"Sun",
"Mon",
"Tue",
"Wed",
"Thu",
"Fri",
"Sat"],
13449 months: [
"January",
"February",
"March",
"April",
"May",
"June",
"July",
"August",
"September",
"October",
"November",
"December"],
13450 shortMonths: [
"Jan",
"Feb",
"Mar",
"Apr",
"May",
"Jun",
"Jul",
"Aug",
"Sep",
"Oct",
"Nov",
"Dec"]
13453 function defaultLocale$1(definition) {
13454 locale$1 = formatLocale$1(definition);
13455 exports.timeFormat = locale$1.format;
13456 exports.timeParse = locale$1.parse;
13457 exports.utcFormat = locale$1.utcFormat;
13458 exports.utcParse = locale$1.utcParse;
13462 var isoSpecifier =
"%Y-%m-%dT%H:%M:%S.%LZ";
13464 function formatIsoNative(date) {
13465 return date.toISOString();
13468 var formatIso = Date.prototype.toISOString
13470 : exports.utcFormat(isoSpecifier);
13472 function parseIsoNative(
string) {
13473 var date =
new Date(
string);
13474 return isNaN(date) ? null : date;
13477 var parseIso = +
new Date(
"2000-01-01T00:00:00.000Z")
13479 : exports.utcParse(isoSpecifier);
13481 var durationSecond$1 = 1000,
13482 durationMinute$1 = durationSecond$1 * 60,
13483 durationHour$1 = durationMinute$1 * 60,
13484 durationDay$1 = durationHour$1 * 24,
13485 durationWeek$1 = durationDay$1 * 7,
13486 durationMonth = durationDay$1 * 30,
13487 durationYear = durationDay$1 * 365;
13489 function date$1(t) {
13490 return new Date(t);
13493 function number$3(t) {
13494 return t instanceof Date ? +t : +
new Date(+t);
13497 function calendar(year$$1, month$$1, week, day$$1, hour$$1, minute$$1, second$$1, millisecond$$1, format) {
13498 var scale = continuous(deinterpolateLinear, interpolateNumber),
13499 invert = scale.invert,
13500 domain = scale.domain;
13502 var formatMillisecond = format(
".%L"),
13503 formatSecond = format(
":%S"),
13504 formatMinute = format(
"%I:%M"),
13505 formatHour = format(
"%I %p"),
13506 formatDay = format(
"%a %d"),
13507 formatWeek = format(
"%b %d"),
13508 formatMonth = format(
"%B"),
13509 formatYear = format(
"%Y");
13511 var tickIntervals = [
13512 [second$$1, 1, durationSecond$1],
13513 [second$$1, 5, 5 * durationSecond$1],
13514 [second$$1, 15, 15 * durationSecond$1],
13515 [second$$1, 30, 30 * durationSecond$1],
13516 [minute$$1, 1, durationMinute$1],
13517 [minute$$1, 5, 5 * durationMinute$1],
13518 [minute$$1, 15, 15 * durationMinute$1],
13519 [minute$$1, 30, 30 * durationMinute$1],
13520 [ hour$$1, 1, durationHour$1 ],
13521 [ hour$$1, 3, 3 * durationHour$1 ],
13522 [ hour$$1, 6, 6 * durationHour$1 ],
13523 [ hour$$1, 12, 12 * durationHour$1 ],
13524 [ day$$1, 1, durationDay$1 ],
13525 [ day$$1, 2, 2 * durationDay$1 ],
13526 [ week, 1, durationWeek$1 ],
13527 [ month$$1, 1, durationMonth ],
13528 [ month$$1, 3, 3 * durationMonth ],
13529 [ year$$1, 1, durationYear ]
13532 function tickFormat(date$$1) {
13533 return (second$$1(date$$1) < date$$1 ? formatMillisecond
13534 : minute$$1(date$$1) < date$$1 ? formatSecond
13535 : hour$$1(date$$1) < date$$1 ? formatMinute
13536 : day$$1(date$$1) < date$$1 ? formatHour
13537 : month$$1(date$$1) < date$$1 ? (week(date$$1) < date$$1 ? formatDay : formatWeek)
13538 : year$$1(date$$1) < date$$1 ? formatMonth
13539 : formatYear)(date$$1);
13542 function tickInterval(interval, start, stop, step) {
13543 if (interval == null) interval = 10;
13548 if (typeof interval ===
"number") {
13549 var target = Math.abs(stop - start) / interval,
13550 i = bisector(
function(i) {
return i[2]; }).right(tickIntervals, target);
13551 if (i === tickIntervals.length) {
13552 step = tickStep(start / durationYear, stop / durationYear, interval);
13553 interval = year$$1;
13555 i = tickIntervals[target / tickIntervals[i - 1][2] < tickIntervals[i][2] / target ? i - 1 : i];
13559 step = Math.max(tickStep(start, stop, interval), 1);
13560 interval = millisecond$$1;
13564 return step == null ? interval : interval.every(step);
13567 scale.invert =
function(y) {
13568 return new Date(invert(y));
13571 scale.domain =
function(_) {
13572 return arguments.length ? domain(map$2.call(_, number$3)) : domain().map(date$1);
13575 scale.ticks =
function(interval, step) {
13578 t1 = d[d.length - 1],
13581 if (r) t = t0, t0 = t1, t1 = t;
13582 t = tickInterval(interval, t0, t1, step);
13583 t = t ? t.range(t0, t1 + 1) : [];
13584 return r ? t.reverse() : t;
13587 scale.tickFormat =
function(count, specifier) {
13588 return specifier == null ? tickFormat : format(specifier);
13591 scale.nice =
function(interval, step) {
13593 return (interval = tickInterval(interval, d[0], d[d.length - 1], step))
13594 ? domain(nice(d, interval))
13598 scale.copy =
function() {
13599 return copy(scale, calendar(year$$1, month$$1, week, day$$1, hour$$1, minute$$1, second$$1, millisecond$$1, format));
13606 return calendar(year, month, sunday, day, hour, minute, second, millisecond, exports.timeFormat).domain([
new Date(2000, 0, 1),
new Date(2000, 0, 2)]);
13609 function utcTime() {
13610 return calendar(utcYear, utcMonth, utcSunday, utcDay, utcHour, utcMinute, second, millisecond, exports.utcFormat).domain([Date.UTC(2000, 0, 1), Date.UTC(2000, 0, 2)]);
13613 function sequential(interpolator) {
13619 function scale(x) {
13620 var t = (x - x0) * k10;
13621 return interpolator(clamp ? Math.max(0, Math.min(1, t)) : t);
13624 scale.domain =
function(_) {
13625 return arguments.length ? (x0 = +_[0], x1 = +_[1], k10 = x0 === x1 ? 0 : 1 / (x1 - x0), scale) : [x0, x1];
13628 scale.clamp =
function(_) {
13629 return arguments.length ? (clamp = !!_, scale) : clamp;
13632 scale.interpolator =
function(_) {
13633 return arguments.length ? (interpolator = _, scale) : interpolator;
13636 scale.copy =
function() {
13637 return sequential(interpolator).domain([x0, x1]).clamp(clamp);
13640 return linearish(scale);
13643 function diverging(interpolator) {
13651 function scale(x) {
13652 var t = 0.5 + ((x = +x) - x1) * (x < x1 ? k10 : k21);
13653 return interpolator(clamp ? Math.max(0, Math.min(1, t)) : t);
13656 scale.domain =
function(_) {
13657 return arguments.length ? (x0 = +_[0], x1 = +_[1], x2 = +_[2], k10 = x0 === x1 ? 0 : 0.5 / (x1 - x0), k21 = x1 === x2 ? 0 : 0.5 / (x2 - x1), scale) : [x0, x1, x2];
13660 scale.clamp =
function(_) {
13661 return arguments.length ? (clamp = !!_, scale) : clamp;
13664 scale.interpolator =
function(_) {
13665 return arguments.length ? (interpolator = _, scale) : interpolator;
13668 scale.copy =
function() {
13669 return diverging(interpolator).domain([x0, x1, x2]).clamp(clamp);
13672 return linearish(scale);
13675 function colors(specifier) {
13676 var n = specifier.length / 6 | 0, colors =
new Array(n), i = 0;
13677 while (i < n) colors[i] =
"#" + specifier.slice(i * 6, ++i * 6);
13681 var category10 = colors(
"1f77b4ff7f0e2ca02cd627289467bd8c564be377c27f7f7fbcbd2217becf");
13683 var Accent = colors(
"7fc97fbeaed4fdc086ffff99386cb0f0027fbf5b17666666");
13685 var Dark2 = colors(
"1b9e77d95f027570b3e7298a66a61ee6ab02a6761d666666");
13687 var Paired = colors(
"a6cee31f78b4b2df8a33a02cfb9a99e31a1cfdbf6fff7f00cab2d66a3d9affff99b15928");
13689 var Pastel1 = colors(
"fbb4aeb3cde3ccebc5decbe4fed9a6ffffcce5d8bdfddaecf2f2f2");
13691 var Pastel2 = colors(
"b3e2cdfdcdaccbd5e8f4cae4e6f5c9fff2aef1e2cccccccc");
13693 var Set1 = colors(
"e41a1c377eb84daf4a984ea3ff7f00ffff33a65628f781bf999999");
13695 var Set2 = colors(
"66c2a5fc8d628da0cbe78ac3a6d854ffd92fe5c494b3b3b3");
13697 var Set3 = colors(
"8dd3c7ffffb3bebadafb807280b1d3fdb462b3de69fccde5d9d9d9bc80bdccebc5ffed6f");
13699 function ramp(scheme) {
13700 return rgbBasis(scheme[scheme.length - 1]);
13703 var scheme =
new Array(3).concat(
13704 "d8b365f5f5f55ab4ac",
13705 "a6611adfc27d80cdc1018571",
13706 "a6611adfc27df5f5f580cdc1018571",
13707 "8c510ad8b365f6e8c3c7eae55ab4ac01665e",
13708 "8c510ad8b365f6e8c3f5f5f5c7eae55ab4ac01665e",
13709 "8c510abf812ddfc27df6e8c3c7eae580cdc135978f01665e",
13710 "8c510abf812ddfc27df6e8c3f5f5f5c7eae580cdc135978f01665e",
13711 "5430058c510abf812ddfc27df6e8c3c7eae580cdc135978f01665e003c30",
13712 "5430058c510abf812ddfc27df6e8c3f5f5f5c7eae580cdc135978f01665e003c30"
13715 var BrBG = ramp(scheme);
13717 var scheme$1 =
new Array(3).concat(
13718 "af8dc3f7f7f77fbf7b",
13719 "7b3294c2a5cfa6dba0008837",
13720 "7b3294c2a5cff7f7f7a6dba0008837",
13721 "762a83af8dc3e7d4e8d9f0d37fbf7b1b7837",
13722 "762a83af8dc3e7d4e8f7f7f7d9f0d37fbf7b1b7837",
13723 "762a839970abc2a5cfe7d4e8d9f0d3a6dba05aae611b7837",
13724 "762a839970abc2a5cfe7d4e8f7f7f7d9f0d3a6dba05aae611b7837",
13725 "40004b762a839970abc2a5cfe7d4e8d9f0d3a6dba05aae611b783700441b",
13726 "40004b762a839970abc2a5cfe7d4e8f7f7f7d9f0d3a6dba05aae611b783700441b"
13729 var PRGn = ramp(scheme$1);
13731 var scheme$2 =
new Array(3).concat(
13732 "e9a3c9f7f7f7a1d76a",
13733 "d01c8bf1b6dab8e1864dac26",
13734 "d01c8bf1b6daf7f7f7b8e1864dac26",
13735 "c51b7de9a3c9fde0efe6f5d0a1d76a4d9221",
13736 "c51b7de9a3c9fde0eff7f7f7e6f5d0a1d76a4d9221",
13737 "c51b7dde77aef1b6dafde0efe6f5d0b8e1867fbc414d9221",
13738 "c51b7dde77aef1b6dafde0eff7f7f7e6f5d0b8e1867fbc414d9221",
13739 "8e0152c51b7dde77aef1b6dafde0efe6f5d0b8e1867fbc414d9221276419",
13740 "8e0152c51b7dde77aef1b6dafde0eff7f7f7e6f5d0b8e1867fbc414d9221276419"
13743 var PiYG = ramp(scheme$2);
13745 var scheme$3 =
new Array(3).concat(
13746 "998ec3f7f7f7f1a340",
13747 "5e3c99b2abd2fdb863e66101",
13748 "5e3c99b2abd2f7f7f7fdb863e66101",
13749 "542788998ec3d8daebfee0b6f1a340b35806",
13750 "542788998ec3d8daebf7f7f7fee0b6f1a340b35806",
13751 "5427888073acb2abd2d8daebfee0b6fdb863e08214b35806",
13752 "5427888073acb2abd2d8daebf7f7f7fee0b6fdb863e08214b35806",
13753 "2d004b5427888073acb2abd2d8daebfee0b6fdb863e08214b358067f3b08",
13754 "2d004b5427888073acb2abd2d8daebf7f7f7fee0b6fdb863e08214b358067f3b08"
13757 var PuOr = ramp(scheme$3);
13759 var scheme$4 =
new Array(3).concat(
13760 "ef8a62f7f7f767a9cf",
13761 "ca0020f4a58292c5de0571b0",
13762 "ca0020f4a582f7f7f792c5de0571b0",
13763 "b2182bef8a62fddbc7d1e5f067a9cf2166ac",
13764 "b2182bef8a62fddbc7f7f7f7d1e5f067a9cf2166ac",
13765 "b2182bd6604df4a582fddbc7d1e5f092c5de4393c32166ac",
13766 "b2182bd6604df4a582fddbc7f7f7f7d1e5f092c5de4393c32166ac",
13767 "67001fb2182bd6604df4a582fddbc7d1e5f092c5de4393c32166ac053061",
13768 "67001fb2182bd6604df4a582fddbc7f7f7f7d1e5f092c5de4393c32166ac053061"
13771 var RdBu = ramp(scheme$4);
13773 var scheme$5 =
new Array(3).concat(
13774 "ef8a62ffffff999999",
13775 "ca0020f4a582bababa404040",
13776 "ca0020f4a582ffffffbababa404040",
13777 "b2182bef8a62fddbc7e0e0e09999994d4d4d",
13778 "b2182bef8a62fddbc7ffffffe0e0e09999994d4d4d",
13779 "b2182bd6604df4a582fddbc7e0e0e0bababa8787874d4d4d",
13780 "b2182bd6604df4a582fddbc7ffffffe0e0e0bababa8787874d4d4d",
13781 "67001fb2182bd6604df4a582fddbc7e0e0e0bababa8787874d4d4d1a1a1a",
13782 "67001fb2182bd6604df4a582fddbc7ffffffe0e0e0bababa8787874d4d4d1a1a1a"
13785 var RdGy = ramp(scheme$5);
13787 var scheme$6 =
new Array(3).concat(
13788 "fc8d59ffffbf91bfdb",
13789 "d7191cfdae61abd9e92c7bb6",
13790 "d7191cfdae61ffffbfabd9e92c7bb6",
13791 "d73027fc8d59fee090e0f3f891bfdb4575b4",
13792 "d73027fc8d59fee090ffffbfe0f3f891bfdb4575b4",
13793 "d73027f46d43fdae61fee090e0f3f8abd9e974add14575b4",
13794 "d73027f46d43fdae61fee090ffffbfe0f3f8abd9e974add14575b4",
13795 "a50026d73027f46d43fdae61fee090e0f3f8abd9e974add14575b4313695",
13796 "a50026d73027f46d43fdae61fee090ffffbfe0f3f8abd9e974add14575b4313695"
13799 var RdYlBu = ramp(scheme$6);
13801 var scheme$7 =
new Array(3).concat(
13802 "fc8d59ffffbf91cf60",
13803 "d7191cfdae61a6d96a1a9641",
13804 "d7191cfdae61ffffbfa6d96a1a9641",
13805 "d73027fc8d59fee08bd9ef8b91cf601a9850",
13806 "d73027fc8d59fee08bffffbfd9ef8b91cf601a9850",
13807 "d73027f46d43fdae61fee08bd9ef8ba6d96a66bd631a9850",
13808 "d73027f46d43fdae61fee08bffffbfd9ef8ba6d96a66bd631a9850",
13809 "a50026d73027f46d43fdae61fee08bd9ef8ba6d96a66bd631a9850006837",
13810 "a50026d73027f46d43fdae61fee08bffffbfd9ef8ba6d96a66bd631a9850006837"
13813 var RdYlGn = ramp(scheme$7);
13815 var scheme$8 =
new Array(3).concat(
13816 "fc8d59ffffbf99d594",
13817 "d7191cfdae61abdda42b83ba",
13818 "d7191cfdae61ffffbfabdda42b83ba",
13819 "d53e4ffc8d59fee08be6f59899d5943288bd",
13820 "d53e4ffc8d59fee08bffffbfe6f59899d5943288bd",
13821 "d53e4ff46d43fdae61fee08be6f598abdda466c2a53288bd",
13822 "d53e4ff46d43fdae61fee08bffffbfe6f598abdda466c2a53288bd",
13823 "9e0142d53e4ff46d43fdae61fee08be6f598abdda466c2a53288bd5e4fa2",
13824 "9e0142d53e4ff46d43fdae61fee08bffffbfe6f598abdda466c2a53288bd5e4fa2"
13827 var Spectral = ramp(scheme$8);
13829 var scheme$9 =
new Array(3).concat(
13830 "e5f5f999d8c92ca25f",
13831 "edf8fbb2e2e266c2a4238b45",
13832 "edf8fbb2e2e266c2a42ca25f006d2c",
13833 "edf8fbccece699d8c966c2a42ca25f006d2c",
13834 "edf8fbccece699d8c966c2a441ae76238b45005824",
13835 "f7fcfde5f5f9ccece699d8c966c2a441ae76238b45005824",
13836 "f7fcfde5f5f9ccece699d8c966c2a441ae76238b45006d2c00441b"
13839 var BuGn = ramp(scheme$9);
13841 var scheme$a =
new Array(3).concat(
13842 "e0ecf49ebcda8856a7",
13843 "edf8fbb3cde38c96c688419d",
13844 "edf8fbb3cde38c96c68856a7810f7c",
13845 "edf8fbbfd3e69ebcda8c96c68856a7810f7c",
13846 "edf8fbbfd3e69ebcda8c96c68c6bb188419d6e016b",
13847 "f7fcfde0ecf4bfd3e69ebcda8c96c68c6bb188419d6e016b",
13848 "f7fcfde0ecf4bfd3e69ebcda8c96c68c6bb188419d810f7c4d004b"
13851 var BuPu = ramp(scheme$a);
13853 var scheme$b =
new Array(3).concat(
13854 "e0f3dba8ddb543a2ca",
13855 "f0f9e8bae4bc7bccc42b8cbe",
13856 "f0f9e8bae4bc7bccc443a2ca0868ac",
13857 "f0f9e8ccebc5a8ddb57bccc443a2ca0868ac",
13858 "f0f9e8ccebc5a8ddb57bccc44eb3d32b8cbe08589e",
13859 "f7fcf0e0f3dbccebc5a8ddb57bccc44eb3d32b8cbe08589e",
13860 "f7fcf0e0f3dbccebc5a8ddb57bccc44eb3d32b8cbe0868ac084081"
13863 var GnBu = ramp(scheme$b);
13865 var scheme$c =
new Array(3).concat(
13866 "fee8c8fdbb84e34a33",
13867 "fef0d9fdcc8afc8d59d7301f",
13868 "fef0d9fdcc8afc8d59e34a33b30000",
13869 "fef0d9fdd49efdbb84fc8d59e34a33b30000",
13870 "fef0d9fdd49efdbb84fc8d59ef6548d7301f990000",
13871 "fff7ecfee8c8fdd49efdbb84fc8d59ef6548d7301f990000",
13872 "fff7ecfee8c8fdd49efdbb84fc8d59ef6548d7301fb300007f0000"
13875 var OrRd = ramp(scheme$c);
13877 var scheme$d =
new Array(3).concat(
13878 "ece2f0a6bddb1c9099",
13879 "f6eff7bdc9e167a9cf02818a",
13880 "f6eff7bdc9e167a9cf1c9099016c59",
13881 "f6eff7d0d1e6a6bddb67a9cf1c9099016c59",
13882 "f6eff7d0d1e6a6bddb67a9cf3690c002818a016450",
13883 "fff7fbece2f0d0d1e6a6bddb67a9cf3690c002818a016450",
13884 "fff7fbece2f0d0d1e6a6bddb67a9cf3690c002818a016c59014636"
13887 var PuBuGn = ramp(scheme$d);
13889 var scheme$e =
new Array(3).concat(
13890 "ece7f2a6bddb2b8cbe",
13891 "f1eef6bdc9e174a9cf0570b0",
13892 "f1eef6bdc9e174a9cf2b8cbe045a8d",
13893 "f1eef6d0d1e6a6bddb74a9cf2b8cbe045a8d",
13894 "f1eef6d0d1e6a6bddb74a9cf3690c00570b0034e7b",
13895 "fff7fbece7f2d0d1e6a6bddb74a9cf3690c00570b0034e7b",
13896 "fff7fbece7f2d0d1e6a6bddb74a9cf3690c00570b0045a8d023858"
13899 var PuBu = ramp(scheme$e);
13901 var scheme$f =
new Array(3).concat(
13902 "e7e1efc994c7dd1c77",
13903 "f1eef6d7b5d8df65b0ce1256",
13904 "f1eef6d7b5d8df65b0dd1c77980043",
13905 "f1eef6d4b9dac994c7df65b0dd1c77980043",
13906 "f1eef6d4b9dac994c7df65b0e7298ace125691003f",
13907 "f7f4f9e7e1efd4b9dac994c7df65b0e7298ace125691003f",
13908 "f7f4f9e7e1efd4b9dac994c7df65b0e7298ace125698004367001f"
13911 var PuRd = ramp(scheme$f);
13913 var scheme$g =
new Array(3).concat(
13914 "fde0ddfa9fb5c51b8a",
13915 "feebe2fbb4b9f768a1ae017e",
13916 "feebe2fbb4b9f768a1c51b8a7a0177",
13917 "feebe2fcc5c0fa9fb5f768a1c51b8a7a0177",
13918 "feebe2fcc5c0fa9fb5f768a1dd3497ae017e7a0177",
13919 "fff7f3fde0ddfcc5c0fa9fb5f768a1dd3497ae017e7a0177",
13920 "fff7f3fde0ddfcc5c0fa9fb5f768a1dd3497ae017e7a017749006a"
13923 var RdPu = ramp(scheme$g);
13925 var scheme$h =
new Array(3).concat(
13926 "edf8b17fcdbb2c7fb8",
13927 "ffffcca1dab441b6c4225ea8",
13928 "ffffcca1dab441b6c42c7fb8253494",
13929 "ffffccc7e9b47fcdbb41b6c42c7fb8253494",
13930 "ffffccc7e9b47fcdbb41b6c41d91c0225ea80c2c84",
13931 "ffffd9edf8b1c7e9b47fcdbb41b6c41d91c0225ea80c2c84",
13932 "ffffd9edf8b1c7e9b47fcdbb41b6c41d91c0225ea8253494081d58"
13935 var YlGnBu = ramp(scheme$h);
13937 var scheme$i =
new Array(3).concat(
13938 "f7fcb9addd8e31a354",
13939 "ffffccc2e69978c679238443",
13940 "ffffccc2e69978c67931a354006837",
13941 "ffffccd9f0a3addd8e78c67931a354006837",
13942 "ffffccd9f0a3addd8e78c67941ab5d238443005a32",
13943 "ffffe5f7fcb9d9f0a3addd8e78c67941ab5d238443005a32",
13944 "ffffe5f7fcb9d9f0a3addd8e78c67941ab5d238443006837004529"
13947 var YlGn = ramp(scheme$i);
13949 var scheme$j =
new Array(3).concat(
13950 "fff7bcfec44fd95f0e",
13951 "ffffd4fed98efe9929cc4c02",
13952 "ffffd4fed98efe9929d95f0e993404",
13953 "ffffd4fee391fec44ffe9929d95f0e993404",
13954 "ffffd4fee391fec44ffe9929ec7014cc4c028c2d04",
13955 "ffffe5fff7bcfee391fec44ffe9929ec7014cc4c028c2d04",
13956 "ffffe5fff7bcfee391fec44ffe9929ec7014cc4c02993404662506"
13959 var YlOrBr = ramp(scheme$j);
13961 var scheme$k =
new Array(3).concat(
13962 "ffeda0feb24cf03b20",
13963 "ffffb2fecc5cfd8d3ce31a1c",
13964 "ffffb2fecc5cfd8d3cf03b20bd0026",
13965 "ffffb2fed976feb24cfd8d3cf03b20bd0026",
13966 "ffffb2fed976feb24cfd8d3cfc4e2ae31a1cb10026",
13967 "ffffccffeda0fed976feb24cfd8d3cfc4e2ae31a1cb10026",
13968 "ffffccffeda0fed976feb24cfd8d3cfc4e2ae31a1cbd0026800026"
13971 var YlOrRd = ramp(scheme$k);
13973 var scheme$l =
new Array(3).concat(
13974 "deebf79ecae13182bd",
13975 "eff3ffbdd7e76baed62171b5",
13976 "eff3ffbdd7e76baed63182bd08519c",
13977 "eff3ffc6dbef9ecae16baed63182bd08519c",
13978 "eff3ffc6dbef9ecae16baed64292c62171b5084594",
13979 "f7fbffdeebf7c6dbef9ecae16baed64292c62171b5084594",
13980 "f7fbffdeebf7c6dbef9ecae16baed64292c62171b508519c08306b"
13983 var Blues = ramp(scheme$l);
13985 var scheme$m =
new Array(3).concat(
13986 "e5f5e0a1d99b31a354",
13987 "edf8e9bae4b374c476238b45",
13988 "edf8e9bae4b374c47631a354006d2c",
13989 "edf8e9c7e9c0a1d99b74c47631a354006d2c",
13990 "edf8e9c7e9c0a1d99b74c47641ab5d238b45005a32",
13991 "f7fcf5e5f5e0c7e9c0a1d99b74c47641ab5d238b45005a32",
13992 "f7fcf5e5f5e0c7e9c0a1d99b74c47641ab5d238b45006d2c00441b"
13995 var Greens = ramp(scheme$m);
13997 var scheme$n =
new Array(3).concat(
13998 "f0f0f0bdbdbd636363",
13999 "f7f7f7cccccc969696525252",
14000 "f7f7f7cccccc969696636363252525",
14001 "f7f7f7d9d9d9bdbdbd969696636363252525",
14002 "f7f7f7d9d9d9bdbdbd969696737373525252252525",
14003 "fffffff0f0f0d9d9d9bdbdbd969696737373525252252525",
14004 "fffffff0f0f0d9d9d9bdbdbd969696737373525252252525000000"
14007 var Greys = ramp(scheme$n);
14009 var scheme$o =
new Array(3).concat(
14010 "efedf5bcbddc756bb1",
14011 "f2f0f7cbc9e29e9ac86a51a3",
14012 "f2f0f7cbc9e29e9ac8756bb154278f",
14013 "f2f0f7dadaebbcbddc9e9ac8756bb154278f",
14014 "f2f0f7dadaebbcbddc9e9ac8807dba6a51a34a1486",
14015 "fcfbfdefedf5dadaebbcbddc9e9ac8807dba6a51a34a1486",
14016 "fcfbfdefedf5dadaebbcbddc9e9ac8807dba6a51a354278f3f007d"
14019 var Purples = ramp(scheme$o);
14021 var scheme$p =
new Array(3).concat(
14022 "fee0d2fc9272de2d26",
14023 "fee5d9fcae91fb6a4acb181d",
14024 "fee5d9fcae91fb6a4ade2d26a50f15",
14025 "fee5d9fcbba1fc9272fb6a4ade2d26a50f15",
14026 "fee5d9fcbba1fc9272fb6a4aef3b2ccb181d99000d",
14027 "fff5f0fee0d2fcbba1fc9272fb6a4aef3b2ccb181d99000d",
14028 "fff5f0fee0d2fcbba1fc9272fb6a4aef3b2ccb181da50f1567000d"
14031 var Reds = ramp(scheme$p);
14033 var scheme$q =
new Array(3).concat(
14034 "fee6cefdae6be6550d",
14035 "feeddefdbe85fd8d3cd94701",
14036 "feeddefdbe85fd8d3ce6550da63603",
14037 "feeddefdd0a2fdae6bfd8d3ce6550da63603",
14038 "feeddefdd0a2fdae6bfd8d3cf16913d948018c2d04",
14039 "fff5ebfee6cefdd0a2fdae6bfd8d3cf16913d948018c2d04",
14040 "fff5ebfee6cefdd0a2fdae6bfd8d3cf16913d94801a636037f2704"
14043 var Oranges = ramp(scheme$q);
14045 var cubehelix$3 = cubehelixLong(cubehelix(300, 0.5, 0.0), cubehelix(-240, 0.5, 1.0));
14047 var warm = cubehelixLong(cubehelix(-100, 0.75, 0.35), cubehelix(80, 1.50, 0.8));
14049 var cool = cubehelixLong(cubehelix(260, 0.75, 0.35), cubehelix(80, 1.50, 0.8));
14051 var c = cubehelix();
14053 function rainbow(t) {
14054 if (t < 0 || t > 1) t -= Math.floor(t);
14055 var ts = Math.abs(t - 0.5);
14056 c.h = 360 * t - 100;
14057 c.s = 1.5 - 1.5 * ts;
14058 c.l = 0.8 - 0.9 * ts;
14063 pi_1_3 = Math.PI / 3,
14064 pi_2_3 = Math.PI * 2 / 3;
14066 function sinebow(t) {
14068 t = (0.5 - t) * Math.PI;
14069 c$1.r = 255 * (x = Math.sin(t)) * x;
14070 c$1.g = 255 * (x = Math.sin(t + pi_1_3)) * x;
14071 c$1.b = 255 * (x = Math.sin(t + pi_2_3)) * x;
14075 function ramp$1(range) {
14076 var n = range.length;
14077 return function(t) {
14078 return range[Math.max(0, Math.min(n - 1, Math.floor(t * n)))];
14082 var viridis = ramp$1(colors(
"44015444025645045745055946075a46085c460a5d460b5e470d60470e6147106347116447136548146748166848176948186a481a6c481b6d481c6e481d6f481f70482071482173482374482475482576482677482878482979472a7a472c7a472d7b472e7c472f7d46307e46327e46337f463480453581453781453882443983443a83443b84433d84433e85423f854240864241864142874144874045884046883f47883f48893e49893e4a893e4c8a3d4d8a3d4e8a3c4f8a3c508b3b518b3b528b3a538b3a548c39558c39568c38588c38598c375a8c375b8d365c8d365d8d355e8d355f8d34608d34618d33628d33638d32648e32658e31668e31678e31688e30698e306a8e2f6b8e2f6c8e2e6d8e2e6e8e2e6f8e2d708e2d718e2c718e2c728e2c738e2b748e2b758e2a768e2a778e2a788e29798e297a8e297b8e287c8e287d8e277e8e277f8e27808e26818e26828e26828e25838e25848e25858e24868e24878e23888e23898e238a8d228b8d228c8d228d8d218e8d218f8d21908d21918c20928c20928c20938c1f948c1f958b1f968b1f978b1f988b1f998a1f9a8a1e9b8a1e9c891e9d891f9e891f9f881fa0881fa1881fa1871fa28720a38620a48621a58521a68522a78522a88423a98324aa8325ab8225ac8226ad8127ad8128ae8029af7f2ab07f2cb17e2db27d2eb37c2fb47c31b57b32b67a34b67935b77937b87838b9773aba763bbb753dbc743fbc7340bd7242be7144bf7046c06f48c16e4ac16d4cc26c4ec36b50c46a52c56954c56856c66758c7655ac8645cc8635ec96260ca6063cb5f65cb5e67cc5c69cd5b6ccd5a6ece5870cf5773d05675d05477d1537ad1517cd2507fd34e81d34d84d44b86d54989d5488bd6468ed64590d74393d74195d84098d83e9bd93c9dd93ba0da39a2da37a5db36a8db34aadc32addc30b0dd2fb2dd2db5de2bb8de29bade28bddf26c0df25c2df23c5e021c8e020cae11fcde11dd0e11cd2e21bd5e21ad8e219dae319dde318dfe318e2e418e5e419e7e419eae51aece51befe51cf1e51df4e61ef6e620f8e621fbe723fde725"));
14084 var magma = ramp$1(colors(
"00000401000501010601010802010902020b02020d03030f03031204041405041606051806051a07061c08071e0907200a08220b09240c09260d0a290e0b2b100b2d110c2f120d31130d34140e36150e38160f3b180f3d19103f1a10421c10441d11471e114920114b21114e22115024125325125527125829115a2a115c2c115f2d11612f116331116533106734106936106b38106c390f6e3b0f703d0f713f0f72400f74420f75440f764510774710784910784a10794c117a4e117b4f127b51127c52137c54137d56147d57157e59157e5a167e5c167f5d177f5f187f601880621980641a80651a80671b80681c816a1c816b1d816d1d816e1e81701f81721f817320817521817621817822817922827b23827c23827e24828025828125818326818426818627818827818928818b29818c29818e2a81902a81912b81932b80942c80962c80982d80992d809b2e7f9c2e7f9e2f7fa02f7fa1307ea3307ea5317ea6317da8327daa337dab337cad347cae347bb0357bb2357bb3367ab5367ab73779b83779ba3878bc3978bd3977bf3a77c03a76c23b75c43c75c53c74c73d73c83e73ca3e72cc3f71cd4071cf4070d0416fd2426fd3436ed5446dd6456cd8456cd9466bdb476adc4869de4968df4a68e04c67e24d66e34e65e44f64e55064e75263e85362e95462ea5661eb5760ec5860ed5a5fee5b5eef5d5ef05f5ef1605df2625df2645cf3655cf4675cf4695cf56b5cf66c5cf66e5cf7705cf7725cf8745cf8765cf9785df9795df97b5dfa7d5efa7f5efa815ffb835ffb8560fb8761fc8961fc8a62fc8c63fc8e64fc9065fd9266fd9467fd9668fd9869fd9a6afd9b6bfe9d6cfe9f6dfea16efea36ffea571fea772fea973feaa74feac76feae77feb078feb27afeb47bfeb67cfeb77efeb97ffebb81febd82febf84fec185fec287fec488fec68afec88cfeca8dfecc8ffecd90fecf92fed194fed395fed597fed799fed89afdda9cfddc9efddea0fde0a1fde2a3fde3a5fde5a7fde7a9fde9aafdebacfcecaefceeb0fcf0b2fcf2b4fcf4b6fcf6b8fcf7b9fcf9bbfcfbbdfcfdbf"));
14086 var inferno = ramp$1(colors(
"00000401000501010601010802010a02020c02020e03021004031204031405041706041907051b08051d09061f0a07220b07240c08260d08290e092b10092d110a30120a32140b34150b37160b39180c3c190c3e1b0c411c0c431e0c451f0c48210c4a230c4c240c4f260c51280b53290b552b0b572d0b592f0a5b310a5c320a5e340a5f3609613809623909633b09643d09653e0966400a67420a68440a68450a69470b6a490b6a4a0c6b4c0c6b4d0d6c4f0d6c510e6c520e6d540f6d550f6d57106e59106e5a116e5c126e5d126e5f136e61136e62146e64156e65156e67166e69166e6a176e6c186e6d186e6f196e71196e721a6e741a6e751b6e771c6d781c6d7a1d6d7c1d6d7d1e6d7f1e6c801f6c82206c84206b85216b87216b88226a8a226a8c23698d23698f24699025689225689326679526679727669827669a28659b29649d29649f2a63a02a63a22b62a32c61a52c60a62d60a82e5fa92e5eab2f5ead305dae305cb0315bb1325ab3325ab43359b63458b73557b93556ba3655bc3754bd3853bf3952c03a51c13a50c33b4fc43c4ec63d4dc73e4cc83f4bca404acb4149cc4248ce4347cf4446d04545d24644d34743d44842d54a41d74b3fd84c3ed94d3dda4e3cdb503bdd513ade5238df5337e05536e15635e25734e35933e45a31e55c30e65d2fe75e2ee8602de9612bea632aeb6429eb6628ec6726ed6925ee6a24ef6c23ef6e21f06f20f1711ff1731df2741cf3761bf37819f47918f57b17f57d15f67e14f68013f78212f78410f8850ff8870ef8890cf98b0bf98c0af98e09fa9008fa9207fa9407fb9606fb9706fb9906fb9b06fb9d07fc9f07fca108fca309fca50afca60cfca80dfcaa0ffcac11fcae12fcb014fcb216fcb418fbb61afbb81dfbba1ffbbc21fbbe23fac026fac228fac42afac62df9c72ff9c932f9cb35f8cd37f8cf3af7d13df7d340f6d543f6d746f5d949f5db4cf4dd4ff4df53f4e156f3e35af3e55df2e661f2e865f2ea69f1ec6df1ed71f1ef75f1f179f2f27df2f482f3f586f3f68af4f88ef5f992f6fa96f8fb9af9fc9dfafda1fcffa4"));
14088 var plasma = ramp$1(colors(
"0d088710078813078916078a19068c1b068d1d068e20068f2206902406912605912805922a05932c05942e05952f059631059733059735049837049938049a3a049a3c049b3e049c3f049c41049d43039e44039e46039f48039f4903a04b03a14c02a14e02a25002a25102a35302a35502a45601a45801a45901a55b01a55c01a65e01a66001a66100a76300a76400a76600a76700a86900a86a00a86c00a86e00a86f00a87100a87201a87401a87501a87701a87801a87a02a87b02a87d03a87e03a88004a88104a78305a78405a78606a68707a68808a68a09a58b0aa58d0ba58e0ca48f0da4910ea3920fa39410a29511a19613a19814a099159f9a169f9c179e9d189d9e199da01a9ca11b9ba21d9aa31e9aa51f99a62098a72197a82296aa2395ab2494ac2694ad2793ae2892b02991b12a90b22b8fb32c8eb42e8db52f8cb6308bb7318ab83289ba3388bb3488bc3587bd3786be3885bf3984c03a83c13b82c23c81c33d80c43e7fc5407ec6417dc7427cc8437bc9447aca457acb4679cc4778cc4977cd4a76ce4b75cf4c74d04d73d14e72d24f71d35171d45270d5536fd5546ed6556dd7566cd8576bd9586ada5a6ada5b69db5c68dc5d67dd5e66de5f65de6164df6263e06363e16462e26561e26660e3685fe4695ee56a5de56b5de66c5ce76e5be76f5ae87059e97158e97257ea7457eb7556eb7655ec7754ed7953ed7a52ee7b51ef7c51ef7e50f07f4ff0804ef1814df1834cf2844bf3854bf3874af48849f48948f58b47f58c46f68d45f68f44f79044f79143f79342f89441f89540f9973ff9983ef99a3efa9b3dfa9c3cfa9e3bfb9f3afba139fba238fca338fca537fca636fca835fca934fdab33fdac33fdae32fdaf31fdb130fdb22ffdb42ffdb52efeb72dfeb82cfeba2cfebb2bfebd2afebe2afec029fdc229fdc328fdc527fdc627fdc827fdca26fdcb26fccd25fcce25fcd025fcd225fbd324fbd524fbd724fad824fada24f9dc24f9dd25f8df25f8e125f7e225f7e425f6e626f6e826f5e926f5eb27f4ed27f3ee27f3f027f2f227f1f426f1f525f0f724f0f921"));
14090 function constant$b(x) {
14091 return function constant() {
14096 var abs$1 = Math.abs;
14097 var atan2$1 = Math.atan2;
14098 var cos$2 = Math.cos;
14099 var max$2 = Math.max;
14100 var min$1 = Math.min;
14101 var sin$2 = Math.sin;
14102 var sqrt$2 = Math.sqrt;
14104 var epsilon$3 = 1e-12;
14105 var pi$4 = Math.PI;
14106 var halfPi$3 = pi$4 / 2;
14107 var tau$4 = 2 * pi$4;
14109 function acos$1(x) {
14110 return x > 1 ? 0 : x < -1 ? pi$4 : Math.acos(x);
14113 function asin$1(x) {
14114 return x >= 1 ? halfPi$3 : x <= -1 ? -halfPi$3 : Math.asin(x);
14117 function arcInnerRadius(d) {
14118 return d.innerRadius;
14121 function arcOuterRadius(d) {
14122 return d.outerRadius;
14125 function arcStartAngle(d) {
14126 return d.startAngle;
14129 function arcEndAngle(d) {
14133 function arcPadAngle(d) {
14134 return d && d.padAngle;
14137 function intersect(x0, y0, x1, y1, x2, y2, x3, y3) {
14138 var x10 = x1 - x0, y10 = y1 - y0,
14139 x32 = x3 - x2, y32 = y3 - y2,
14140 t = (x32 * (y0 - y2) - y32 * (x0 - x2)) / (y32 * x10 - x32 * y10);
14141 return [x0 + t * x10, y0 + t * y10];
14146 function cornerTangents(x0, y0, x1, y1, r1, rc, cw) {
14149 lo = (cw ? rc : -rc) / sqrt$2(x01 * x01 + y01 * y01),
14156 x00 = (x11 + x10) / 2,
14157 y00 = (y11 + y10) / 2,
14160 d2 = dx * dx + dy * dy,
14162 D = x11 * y10 - x10 * y11,
14163 d = (dy < 0 ? -1 : 1) * sqrt$2(max$2(0, r * r * d2 - D * D)),
14164 cx0 = (D * dy - dx * d) / d2,
14165 cy0 = (-D * dx - dy * d) / d2,
14166 cx1 = (D * dy + dx * d) / d2,
14167 cy1 = (-D * dx + dy * d) / d2,
14175 if (dx0 * dx0 + dy0 * dy0 > dx1 * dx1 + dy1 * dy1) cx0 = cx1, cy0 = cy1;
14182 x11: cx0 * (r1 / r - 1),
14183 y11: cy0 * (r1 / r - 1)
14188 var innerRadius = arcInnerRadius,
14189 outerRadius = arcOuterRadius,
14190 cornerRadius = constant$b(0),
14192 startAngle = arcStartAngle,
14193 endAngle = arcEndAngle,
14194 padAngle = arcPadAngle,
14200 r0 = +innerRadius.apply(
this, arguments),
14201 r1 = +outerRadius.apply(
this, arguments),
14202 a0 = startAngle.apply(
this, arguments) - halfPi$3,
14203 a1 = endAngle.apply(
this, arguments) - halfPi$3,
14204 da = abs$1(a1 - a0),
14207 if (!context) context = buffer = path();
14210 if (r1 < r0) r = r1, r1 = r0, r0 = r;
14213 if (!(r1 > epsilon$3)) context.moveTo(0, 0);
14216 else if (da > tau$4 - epsilon$3) {
14217 context.moveTo(r1 * cos$2(a0), r1 * sin$2(a0));
14218 context.arc(0, 0, r1, a0, a1, !cw);
14219 if (r0 > epsilon$3) {
14220 context.moveTo(r0 * cos$2(a1), r0 * sin$2(a1));
14221 context.arc(0, 0, r0, a1, a0, cw);
14233 ap = padAngle.apply(
this, arguments) / 2,
14234 rp = (ap > epsilon$3) && (padRadius ? +padRadius.apply(
this, arguments) : sqrt$2(r0 * r0 + r1 * r1)),
14235 rc = min$1(abs$1(r1 - r0) / 2, +cornerRadius.apply(
this, arguments)),
14242 if (rp > epsilon$3) {
14243 var p0 = asin$1(rp / r0 * sin$2(ap)),
14244 p1 = asin$1(rp / r1 * sin$2(ap));
14245 if ((da0 -= p0 * 2) > epsilon$3) p0 *= (cw ? 1 : -1), a00 += p0, a10 -= p0;
14246 else da0 = 0, a00 = a10 = (a0 + a1) / 2;
14247 if ((da1 -= p1 * 2) > epsilon$3) p1 *= (cw ? 1 : -1), a01 += p1, a11 -= p1;
14248 else da1 = 0, a01 = a11 = (a0 + a1) / 2;
14251 var x01 = r1 * cos$2(a01),
14252 y01 = r1 * sin$2(a01),
14253 x10 = r0 * cos$2(a10),
14254 y10 = r0 * sin$2(a10);
14257 if (rc > epsilon$3) {
14258 var x11 = r1 * cos$2(a11),
14259 y11 = r1 * sin$2(a11),
14260 x00 = r0 * cos$2(a00),
14261 y00 = r0 * sin$2(a00);
14265 var oc = da0 > epsilon$3 ? intersect(x01, y01, x00, y00, x11, y11, x10, y10) : [x10, y10],
14270 kc = 1 / sin$2(acos$1((ax * bx + ay * by) / (sqrt$2(ax * ax + ay * ay) * sqrt$2(bx * bx + by * by))) / 2),
14271 lc = sqrt$2(oc[0] * oc[0] + oc[1] * oc[1]);
14272 rc0 = min$1(rc, (r0 - lc) / (kc - 1));
14273 rc1 = min$1(rc, (r1 - lc) / (kc + 1));
14278 if (!(da1 > epsilon$3)) context.moveTo(x01, y01);
14281 else if (rc1 > epsilon$3) {
14282 t0 = cornerTangents(x00, y00, x01, y01, r1, rc1, cw);
14283 t1 = cornerTangents(x11, y11, x10, y10, r1, rc1, cw);
14285 context.moveTo(t0.cx + t0.x01, t0.cy + t0.y01);
14288 if (rc1 < rc) context.arc(t0.cx, t0.cy, rc1, atan2$1(t0.y01, t0.x01), atan2$1(t1.y01, t1.x01), !cw);
14292 context.arc(t0.cx, t0.cy, rc1, atan2$1(t0.y01, t0.x01), atan2$1(t0.y11, t0.x11), !cw);
14293 context.arc(0, 0, r1, atan2$1(t0.cy + t0.y11, t0.cx + t0.x11), atan2$1(t1.cy + t1.y11, t1.cx + t1.x11), !cw);
14294 context.arc(t1.cx, t1.cy, rc1, atan2$1(t1.y11, t1.x11), atan2$1(t1.y01, t1.x01), !cw);
14299 else context.moveTo(x01, y01), context.arc(0, 0, r1, a01, a11, !cw);
14303 if (!(r0 > epsilon$3) || !(da0 > epsilon$3)) context.lineTo(x10, y10);
14306 else if (rc0 > epsilon$3) {
14307 t0 = cornerTangents(x10, y10, x11, y11, r0, -rc0, cw);
14308 t1 = cornerTangents(x01, y01, x00, y00, r0, -rc0, cw);
14310 context.lineTo(t0.cx + t0.x01, t0.cy + t0.y01);
14313 if (rc0 < rc) context.arc(t0.cx, t0.cy, rc0, atan2$1(t0.y01, t0.x01), atan2$1(t1.y01, t1.x01), !cw);
14317 context.arc(t0.cx, t0.cy, rc0, atan2$1(t0.y01, t0.x01), atan2$1(t0.y11, t0.x11), !cw);
14318 context.arc(0, 0, r0, atan2$1(t0.cy + t0.y11, t0.cx + t0.x11), atan2$1(t1.cy + t1.y11, t1.cx + t1.x11), cw);
14319 context.arc(t1.cx, t1.cy, rc0, atan2$1(t1.y11, t1.x11), atan2$1(t1.y01, t1.x01), !cw);
14324 else context.arc(0, 0, r0, a10, a00, cw);
14327 context.closePath();
14329 if (buffer)
return context = null, buffer +
"" || null;
14332 arc.centroid =
function() {
14333 var r = (+innerRadius.apply(
this, arguments) + +outerRadius.apply(
this, arguments)) / 2,
14334 a = (+startAngle.apply(
this, arguments) + +endAngle.apply(
this, arguments)) / 2 - pi$4 / 2;
14335 return [cos$2(a) * r, sin$2(a) * r];
14338 arc.innerRadius =
function(_) {
14339 return arguments.length ? (innerRadius = typeof _ ===
"function" ? _ : constant$b(+_), arc) : innerRadius;
14342 arc.outerRadius =
function(_) {
14343 return arguments.length ? (outerRadius = typeof _ ===
"function" ? _ : constant$b(+_), arc) : outerRadius;
14346 arc.cornerRadius =
function(_) {
14347 return arguments.length ? (cornerRadius = typeof _ ===
"function" ? _ : constant$b(+_), arc) : cornerRadius;
14350 arc.padRadius =
function(_) {
14351 return arguments.length ? (padRadius = _ == null ? null : typeof _ ===
"function" ? _ : constant$b(+_), arc) : padRadius;
14354 arc.startAngle =
function(_) {
14355 return arguments.length ? (startAngle = typeof _ ===
"function" ? _ : constant$b(+_), arc) : startAngle;
14358 arc.endAngle =
function(_) {
14359 return arguments.length ? (endAngle = typeof _ ===
"function" ? _ : constant$b(+_), arc) : endAngle;
14362 arc.padAngle =
function(_) {
14363 return arguments.length ? (padAngle = typeof _ ===
"function" ? _ : constant$b(+_), arc) : padAngle;
14366 arc.context =
function(_) {
14367 return arguments.length ? ((context = _ == null ? null : _), arc) : context;
14373 function Linear(context) {
14374 this._context = context;
14377 Linear.prototype = {
14378 areaStart:
function() {
14381 areaEnd:
function() {
14384 lineStart:
function() {
14387 lineEnd:
function() {
14388 if (this._line || (this._line !== 0 && this._point === 1)) this._context.closePath();
14389 this._line = 1 - this._line;
14391 point:
function(x, y) {
14393 switch (this._point) {
14394 case 0: this._point = 1; this._line ? this._context.lineTo(x, y) : this._context.moveTo(x, y);
break;
14395 case 1: this._point = 2;
14396 default: this._context.lineTo(x, y);
break;
14401 function curveLinear(context) {
14402 return new Linear(context);
14416 defined = constant$b(
true),
14418 curve = curveLinear,
14421 function line(data) {
14428 if (context == null) output = curve(buffer = path());
14430 for (i = 0; i <= n; ++i) {
14431 if (!(i < n && defined(d = data[i], i, data)) === defined0) {
14432 if (defined0 = !defined0) output.lineStart();
14433 else output.lineEnd();
14435 if (defined0) output.point(+x$$1(d, i, data), +y$$1(d, i, data));
14438 if (buffer)
return output = null, buffer +
"" || null;
14441 line.x =
function(_) {
14442 return arguments.length ? (x$$1 = typeof _ ===
"function" ? _ : constant$b(+_), line) : x$$1;
14445 line.y =
function(_) {
14446 return arguments.length ? (y$$1 = typeof _ ===
"function" ? _ : constant$b(+_), line) : y$$1;
14449 line.defined =
function(_) {
14450 return arguments.length ? (defined = typeof _ ===
"function" ? _ : constant$b(!!_), line) : defined;
14453 line.curve =
function(_) {
14454 return arguments.length ? (curve = _, context != null && (output = curve(context)), line) : curve;
14457 line.context =
function(_) {
14458 return arguments.length ? (_ == null ? context = output = null : output = curve(context = _), line) : context;
14464 function area$3() {
14467 y0 = constant$b(0),
14469 defined = constant$b(
true),
14471 curve = curveLinear,
14474 function area(data) {
14482 x0z =
new Array(n),
14483 y0z =
new Array(n);
14485 if (context == null) output = curve(buffer = path());
14487 for (i = 0; i <= n; ++i) {
14488 if (!(i < n && defined(d = data[i], i, data)) === defined0) {
14489 if (defined0 = !defined0) {
14491 output.areaStart();
14492 output.lineStart();
14495 output.lineStart();
14496 for (k = i - 1; k >= j; --k) {
14497 output.point(x0z[k], y0z[k]);
14504 x0z[i] = +x0(d, i, data), y0z[i] = +y0(d, i, data);
14505 output.point(x1 ? +x1(d, i, data) : x0z[i], y1 ? +y1(d, i, data) : y0z[i]);
14509 if (buffer)
return output = null, buffer +
"" || null;
14512 function arealine() {
14513 return line().defined(defined).curve(curve).context(context);
14516 area.x =
function(_) {
14517 return arguments.length ? (x0 = typeof _ ===
"function" ? _ : constant$b(+_), x1 = null, area) : x0;
14520 area.x0 =
function(_) {
14521 return arguments.length ? (x0 = typeof _ ===
"function" ? _ : constant$b(+_), area) : x0;
14524 area.x1 =
function(_) {
14525 return arguments.length ? (x1 = _ == null ? null : typeof _ ===
"function" ? _ : constant$b(+_), area) : x1;
14528 area.y =
function(_) {
14529 return arguments.length ? (y0 = typeof _ ===
"function" ? _ : constant$b(+_), y1 = null, area) : y0;
14532 area.y0 =
function(_) {
14533 return arguments.length ? (y0 = typeof _ ===
"function" ? _ : constant$b(+_), area) : y0;
14536 area.y1 =
function(_) {
14537 return arguments.length ? (y1 = _ == null ? null : typeof _ ===
"function" ? _ : constant$b(+_), area) : y1;
14541 area.lineY0 =
function() {
14542 return arealine().x(x0).y(y0);
14545 area.lineY1 =
function() {
14546 return arealine().x(x0).y(y1);
14549 area.lineX1 =
function() {
14550 return arealine().x(x1).y(y0);
14553 area.defined =
function(_) {
14554 return arguments.length ? (defined = typeof _ ===
"function" ? _ : constant$b(!!_), area) : defined;
14557 area.curve =
function(_) {
14558 return arguments.length ? (curve = _, context != null && (output = curve(context)), area) : curve;
14561 area.context =
function(_) {
14562 return arguments.length ? (_ == null ? context = output = null : output = curve(context = _), area) : context;
14568 function descending$1(a, b) {
14569 return b < a ? -1 : b > a ? 1 : b >= a ? 0 : NaN;
14572 function identity$7(d) {
14577 var value = identity$7,
14578 sortValues = descending$1,
14580 startAngle = constant$b(0),
14581 endAngle = constant$b(tau$4),
14582 padAngle = constant$b(0);
14584 function pie(data) {
14590 index =
new Array(n),
14591 arcs =
new Array(n),
14592 a0 = +startAngle.apply(
this, arguments),
14593 da = Math.min(tau$4, Math.max(-tau$4, endAngle.apply(
this, arguments) - a0)),
14595 p = Math.min(Math.abs(da) / n, padAngle.apply(
this, arguments)),
14596 pa = p * (da < 0 ? -1 : 1),
14599 for (i = 0; i < n; ++i) {
14600 if ((v = arcs[index[i] = i] = +value(data[i], i, data)) > 0) {
14606 if (sortValues != null) index.sort(
function(i, j) {
return sortValues(arcs[i], arcs[j]); });
14607 else if (sort != null) index.sort(
function(i, j) {
return sort(data[i], data[j]); });
14610 for (i = 0, k = sum ? (da - n * pa) / sum : 0; i < n; ++i, a0 = a1) {
14611 j = index[i], v = arcs[j], a1 = a0 + (v > 0 ? v * k : 0) + pa, arcs[j] = {
14624 pie.value =
function(_) {
14625 return arguments.length ? (value = typeof _ ===
"function" ? _ : constant$b(+_), pie) : value;
14628 pie.sortValues =
function(_) {
14629 return arguments.length ? (sortValues = _, sort = null, pie) : sortValues;
14632 pie.sort =
function(_) {
14633 return arguments.length ? (sort = _, sortValues = null, pie) : sort;
14636 pie.startAngle =
function(_) {
14637 return arguments.length ? (startAngle = typeof _ ===
"function" ? _ : constant$b(+_), pie) : startAngle;
14640 pie.endAngle =
function(_) {
14641 return arguments.length ? (endAngle = typeof _ ===
"function" ? _ : constant$b(+_), pie) : endAngle;
14644 pie.padAngle =
function(_) {
14645 return arguments.length ? (padAngle = typeof _ ===
"function" ? _ : constant$b(+_), pie) : padAngle;
14651 var curveRadialLinear = curveRadial(curveLinear);
14653 function Radial(curve) {
14654 this._curve = curve;
14657 Radial.prototype = {
14658 areaStart:
function() {
14659 this._curve.areaStart();
14661 areaEnd:
function() {
14662 this._curve.areaEnd();
14664 lineStart:
function() {
14665 this._curve.lineStart();
14667 lineEnd:
function() {
14668 this._curve.lineEnd();
14670 point:
function(a, r) {
14671 this._curve.point(r * Math.sin(a), r * -Math.cos(a));
14675 function curveRadial(curve) {
14677 function radial(context) {
14678 return new Radial(curve(context));
14681 radial._curve = curve;
14686 function lineRadial(l) {
14689 l.angle = l.x,
delete l.x;
14690 l.radius = l.y,
delete l.y;
14692 l.curve =
function(_) {
14693 return arguments.length ? c(curveRadial(_)) : c()._curve;
14699 function lineRadial$1() {
14700 return lineRadial(line().curve(curveRadialLinear));
14703 function areaRadial() {
14704 var a = area$3().curve(curveRadialLinear),
14711 a.angle = a.x,
delete a.x;
14712 a.startAngle = a.x0,
delete a.x0;
14713 a.endAngle = a.x1,
delete a.x1;
14714 a.radius = a.y,
delete a.y;
14715 a.innerRadius = a.y0,
delete a.y0;
14716 a.outerRadius = a.y1,
delete a.y1;
14717 a.lineStartAngle =
function() {
return lineRadial(x0()); },
delete a.lineX0;
14718 a.lineEndAngle =
function() {
return lineRadial(x1()); },
delete a.lineX1;
14719 a.lineInnerRadius =
function() {
return lineRadial(y0()); },
delete a.lineY0;
14720 a.lineOuterRadius =
function() {
return lineRadial(y1()); },
delete a.lineY1;
14722 a.curve =
function(_) {
14723 return arguments.length ? c(curveRadial(_)) : c()._curve;
14729 function pointRadial(x, y) {
14730 return [(y = +y) * Math.cos(x -= Math.PI / 2), y * Math.sin(x)];
14733 var slice$6 = Array.prototype.slice;
14735 function linkSource(d) {
14739 function linkTarget(d) {
14743 function link$2(curve) {
14744 var source = linkSource,
14745 target = linkTarget,
14751 var buffer, argv = slice$6.call(arguments), s = source.apply(
this, argv), t = target.apply(
this, argv);
14752 if (!context) context = buffer = path();
14753 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));
14754 if (buffer)
return context = null, buffer +
"" || null;
14757 link.source =
function(_) {
14758 return arguments.length ? (source = _, link) : source;
14761 link.target =
function(_) {
14762 return arguments.length ? (target = _, link) : target;
14765 link.x =
function(_) {
14766 return arguments.length ? (x$$1 = typeof _ ===
"function" ? _ : constant$b(+_), link) : x$$1;
14769 link.y =
function(_) {
14770 return arguments.length ? (y$$1 = typeof _ ===
"function" ? _ : constant$b(+_), link) : y$$1;
14773 link.context =
function(_) {
14774 return arguments.length ? ((context = _ == null ? null : _), link) : context;
14780 function curveHorizontal(context, x0, y0, x1, y1) {
14781 context.moveTo(x0, y0);
14782 context.bezierCurveTo(x0 = (x0 + x1) / 2, y0, x0, y1, x1, y1);
14785 function curveVertical(context, x0, y0, x1, y1) {
14786 context.moveTo(x0, y0);
14787 context.bezierCurveTo(x0, y0 = (y0 + y1) / 2, x1, y0, x1, y1);
14790 function curveRadial$1(context, x0, y0, x1, y1) {
14791 var p0 = pointRadial(x0, y0),
14792 p1 = pointRadial(x0, y0 = (y0 + y1) / 2),
14793 p2 = pointRadial(x1, y0),
14794 p3 = pointRadial(x1, y1);
14795 context.moveTo(p0[0], p0[1]);
14796 context.bezierCurveTo(p1[0], p1[1], p2[0], p2[1], p3[0], p3[1]);
14799 function linkHorizontal() {
14800 return link$2(curveHorizontal);
14803 function linkVertical() {
14804 return link$2(curveVertical);
14807 function linkRadial() {
14808 var l = link$2(curveRadial$1);
14809 l.angle = l.x,
delete l.x;
14810 l.radius = l.y,
delete l.y;
14815 draw:
function(context, size) {
14816 var r = Math.sqrt(size / pi$4);
14817 context.moveTo(r, 0);
14818 context.arc(0, 0, r, 0, tau$4);
14823 draw:
function(context, size) {
14824 var r = Math.sqrt(size / 5) / 2;
14825 context.moveTo(-3 * r, -r);
14826 context.lineTo(-r, -r);
14827 context.lineTo(-r, -3 * r);
14828 context.lineTo(r, -3 * r);
14829 context.lineTo(r, -r);
14830 context.lineTo(3 * r, -r);
14831 context.lineTo(3 * r, r);
14832 context.lineTo(r, r);
14833 context.lineTo(r, 3 * r);
14834 context.lineTo(-r, 3 * r);
14835 context.lineTo(-r, r);
14836 context.lineTo(-3 * r, r);
14837 context.closePath();
14841 var tan30 = Math.sqrt(1 / 3),
14842 tan30_2 = tan30 * 2;
14845 draw:
function(context, size) {
14846 var y = Math.sqrt(size / tan30_2),
14848 context.moveTo(0, -y);
14849 context.lineTo(x, 0);
14850 context.lineTo(0, y);
14851 context.lineTo(-x, 0);
14852 context.closePath();
14856 var ka = 0.89081309152928522810,
14857 kr = Math.sin(pi$4 / 10) / Math.sin(7 * pi$4 / 10),
14858 kx = Math.sin(tau$4 / 10) * kr,
14859 ky = -Math.cos(tau$4 / 10) * kr;
14862 draw:
function(context, size) {
14863 var r = Math.sqrt(size * ka),
14866 context.moveTo(0, -r);
14867 context.lineTo(x, y);
14868 for (var i = 1; i < 5; ++i) {
14869 var a = tau$4 * i / 5,
14872 context.lineTo(s * r, -c * r);
14873 context.lineTo(c * x - s * y, s * x + c * y);
14875 context.closePath();
14880 draw:
function(context, size) {
14881 var w = Math.sqrt(size),
14883 context.rect(x, x, w, w);
14887 var sqrt3 = Math.sqrt(3);
14890 draw:
function(context, size) {
14891 var y = -Math.sqrt(size / (sqrt3 * 3));
14892 context.moveTo(0, y * 2);
14893 context.lineTo(-sqrt3 * y, -y);
14894 context.lineTo(sqrt3 * y, -y);
14895 context.closePath();
14900 s = Math.sqrt(3) / 2,
14901 k = 1 / Math.sqrt(12),
14902 a = (k / 2 + 1) * 3;
14905 draw:
function(context, size) {
14906 var r = Math.sqrt(size / a),
14913 context.moveTo(x0, y0);
14914 context.lineTo(x1, y1);
14915 context.lineTo(x2, y2);
14916 context.lineTo(c$2 * x0 - s * y0, s * x0 + c$2 * y0);
14917 context.lineTo(c$2 * x1 - s * y1, s * x1 + c$2 * y1);
14918 context.lineTo(c$2 * x2 - s * y2, s * x2 + c$2 * y2);
14919 context.lineTo(c$2 * x0 + s * y0, c$2 * y0 - s * x0);
14920 context.lineTo(c$2 * x1 + s * y1, c$2 * y1 - s * x1);
14921 context.lineTo(c$2 * x2 + s * y2, c$2 * y2 - s * x2);
14922 context.closePath();
14936 function symbol() {
14937 var type = constant$b(circle$2),
14938 size = constant$b(64),
14941 function symbol() {
14943 if (!context) context = buffer = path();
14944 type.apply(
this, arguments).draw(context, +size.apply(
this, arguments));
14945 if (buffer)
return context = null, buffer +
"" || null;
14948 symbol.type =
function(_) {
14949 return arguments.length ? (type = typeof _ ===
"function" ? _ : constant$b(_), symbol) : type;
14952 symbol.size =
function(_) {
14953 return arguments.length ? (size = typeof _ ===
"function" ? _ : constant$b(+_), symbol) : size;
14956 symbol.context =
function(_) {
14957 return arguments.length ? (context = _ == null ? null : _, symbol) : context;
14963 function noop$3() {}
14965 function point$2(that, x, y) {
14966 that._context.bezierCurveTo(
14967 (2 * that._x0 + that._x1) / 3,
14968 (2 * that._y0 + that._y1) / 3,
14969 (that._x0 + 2 * that._x1) / 3,
14970 (that._y0 + 2 * that._y1) / 3,
14971 (that._x0 + 4 * that._x1 + x) / 6,
14972 (that._y0 + 4 * that._y1 + y) / 6
14976 function Basis(context) {
14977 this._context = context;
14980 Basis.prototype = {
14981 areaStart:
function() {
14984 areaEnd:
function() {
14987 lineStart:
function() {
14988 this._x0 = this._x1 =
14989 this._y0 = this._y1 = NaN;
14992 lineEnd:
function() {
14993 switch (this._point) {
14994 case 3: point$2(
this, this._x1, this._y1);
14995 case 2: this._context.lineTo(this._x1, this._y1);
break;
14997 if (this._line || (this._line !== 0 && this._point === 1)) this._context.closePath();
14998 this._line = 1 - this._line;
15000 point:
function(x, y) {
15002 switch (this._point) {
15003 case 0: this._point = 1; this._line ? this._context.lineTo(x, y) : this._context.moveTo(x, y);
break;
15004 case 1: this._point = 2;
break;
15005 case 2: this._point = 3; this._context.lineTo((5 * this._x0 + this._x1) / 6, (5 * this._y0 + this._y1) / 6);
15006 default: point$2(
this, x, y);
break;
15008 this._x0 = this._x1, this._x1 = x;
15009 this._y0 = this._y1, this._y1 = y;
15013 function basis$2(context) {
15014 return new Basis(context);
15017 function BasisClosed(context) {
15018 this._context = context;
15021 BasisClosed.prototype = {
15024 lineStart:
function() {
15025 this._x0 = this._x1 = this._x2 = this._x3 = this._x4 =
15026 this._y0 = this._y1 = this._y2 = this._y3 = this._y4 = NaN;
15029 lineEnd:
function() {
15030 switch (this._point) {
15032 this._context.moveTo(this._x2, this._y2);
15033 this._context.closePath();
15037 this._context.moveTo((this._x2 + 2 * this._x3) / 3, (this._y2 + 2 * this._y3) / 3);
15038 this._context.lineTo((this._x3 + 2 * this._x2) / 3, (this._y3 + 2 * this._y2) / 3);
15039 this._context.closePath();
15043 this.point(this._x2, this._y2);
15044 this.point(this._x3, this._y3);
15045 this.point(this._x4, this._y4);
15050 point:
function(x, y) {
15052 switch (this._point) {
15053 case 0: this._point = 1; this._x2 = x, this._y2 = y;
break;
15054 case 1: this._point = 2; this._x3 = x, this._y3 = y;
break;
15055 case 2: this._point = 3; this._x4 = x, this._y4 = y; this._context.moveTo((this._x0 + 4 * this._x1 + x) / 6, (this._y0 + 4 * this._y1 + y) / 6);
break;
15056 default: point$2(
this, x, y);
break;
15058 this._x0 = this._x1, this._x1 = x;
15059 this._y0 = this._y1, this._y1 = y;
15063 function basisClosed$1(context) {
15064 return new BasisClosed(context);
15067 function BasisOpen(context) {
15068 this._context = context;
15071 BasisOpen.prototype = {
15072 areaStart:
function() {
15075 areaEnd:
function() {
15078 lineStart:
function() {
15079 this._x0 = this._x1 =
15080 this._y0 = this._y1 = NaN;
15083 lineEnd:
function() {
15084 if (this._line || (this._line !== 0 && this._point === 3)) this._context.closePath();
15085 this._line = 1 - this._line;
15087 point:
function(x, y) {
15089 switch (this._point) {
15090 case 0: this._point = 1;
break;
15091 case 1: this._point = 2;
break;
15092 case 2: this._point = 3; var x0 = (this._x0 + 4 * this._x1 + x) / 6, y0 = (this._y0 + 4 * this._y1 + y) / 6; this._line ? this._context.lineTo(x0, y0) : this._context.moveTo(x0, y0);
break;
15093 case 3: this._point = 4;
15094 default: point$2(
this, x, y);
break;
15096 this._x0 = this._x1, this._x1 = x;
15097 this._y0 = this._y1, this._y1 = y;
15101 function basisOpen(context) {
15102 return new BasisOpen(context);
15105 function Bundle(context, beta) {
15106 this._basis =
new Basis(context);
15110 Bundle.prototype = {
15111 lineStart:
function() {
15114 this._basis.lineStart();
15116 lineEnd:
function() {
15132 this._beta * x[i] + (1 - this._beta) * (x0 + t * dx),
15133 this._beta * y[i] + (1 - this._beta) * (y0 + t * dy)
15138 this._x = this._y = null;
15139 this._basis.lineEnd();
15141 point:
function(x, y) {
15147 var bundle = (
function custom(beta) {
15149 function bundle(context) {
15150 return beta === 1 ?
new Basis(context) : new Bundle(context, beta);
15153 bundle.beta =
function(beta) {
15154 return custom(+beta);
15160 function point$3(that, x, y) {
15161 that._context.bezierCurveTo(
15162 that._x1 + that._k * (that._x2 - that._x0),
15163 that._y1 + that._k * (that._y2 - that._y0),
15164 that._x2 + that._k * (that._x1 - x),
15165 that._y2 + that._k * (that._y1 - y),
15171 function Cardinal(context, tension) {
15172 this._context = context;
15173 this._k = (1 - tension) / 6;
15176 Cardinal.prototype = {
15177 areaStart:
function() {
15180 areaEnd:
function() {
15183 lineStart:
function() {
15184 this._x0 = this._x1 = this._x2 =
15185 this._y0 = this._y1 = this._y2 = NaN;
15188 lineEnd:
function() {
15189 switch (this._point) {
15190 case 2: this._context.lineTo(this._x2, this._y2);
break;
15191 case 3: point$3(
this, this._x1, this._y1);
break;
15193 if (this._line || (this._line !== 0 && this._point === 1)) this._context.closePath();
15194 this._line = 1 - this._line;
15196 point:
function(x, y) {
15198 switch (this._point) {
15199 case 0: this._point = 1; this._line ? this._context.lineTo(x, y) : this._context.moveTo(x, y);
break;
15200 case 1: this._point = 2; this._x1 = x, this._y1 = y;
break;
15201 case 2: this._point = 3;
15202 default: point$3(
this, x, y);
break;
15204 this._x0 = this._x1, this._x1 = this._x2, this._x2 = x;
15205 this._y0 = this._y1, this._y1 = this._y2, this._y2 = y;
15209 var cardinal = (
function custom(tension) {
15211 function cardinal(context) {
15212 return new Cardinal(context, tension);
15215 cardinal.tension =
function(tension) {
15216 return custom(+tension);
15222 function CardinalClosed(context, tension) {
15223 this._context = context;
15224 this._k = (1 - tension) / 6;
15227 CardinalClosed.prototype = {
15230 lineStart:
function() {
15231 this._x0 = this._x1 = this._x2 = this._x3 = this._x4 = this._x5 =
15232 this._y0 = this._y1 = this._y2 = this._y3 = this._y4 = this._y5 = NaN;
15235 lineEnd:
function() {
15236 switch (this._point) {
15238 this._context.moveTo(this._x3, this._y3);
15239 this._context.closePath();
15243 this._context.lineTo(this._x3, this._y3);
15244 this._context.closePath();
15248 this.point(this._x3, this._y3);
15249 this.point(this._x4, this._y4);
15250 this.point(this._x5, this._y5);
15255 point:
function(x, y) {
15257 switch (this._point) {
15258 case 0: this._point = 1; this._x3 = x, this._y3 = y;
break;
15259 case 1: this._point = 2; this._context.moveTo(this._x4 = x, this._y4 = y);
break;
15260 case 2: this._point = 3; this._x5 = x, this._y5 = y;
break;
15261 default: point$3(
this, x, y);
break;
15263 this._x0 = this._x1, this._x1 = this._x2, this._x2 = x;
15264 this._y0 = this._y1, this._y1 = this._y2, this._y2 = y;
15268 var cardinalClosed = (
function custom(tension) {
15270 function cardinal$$1(context) {
15271 return new CardinalClosed(context, tension);
15274 cardinal$$1.tension =
function(tension) {
15275 return custom(+tension);
15278 return cardinal$$1;
15281 function CardinalOpen(context, tension) {
15282 this._context = context;
15283 this._k = (1 - tension) / 6;
15286 CardinalOpen.prototype = {
15287 areaStart:
function() {
15290 areaEnd:
function() {
15293 lineStart:
function() {
15294 this._x0 = this._x1 = this._x2 =
15295 this._y0 = this._y1 = this._y2 = NaN;
15298 lineEnd:
function() {
15299 if (this._line || (this._line !== 0 && this._point === 3)) this._context.closePath();
15300 this._line = 1 - this._line;
15302 point:
function(x, y) {
15304 switch (this._point) {
15305 case 0: this._point = 1;
break;
15306 case 1: this._point = 2;
break;
15307 case 2: this._point = 3; this._line ? this._context.lineTo(this._x2, this._y2) : this._context.moveTo(this._x2, this._y2);
break;
15308 case 3: this._point = 4;
15309 default: point$3(
this, x, y);
break;
15311 this._x0 = this._x1, this._x1 = this._x2, this._x2 = x;
15312 this._y0 = this._y1, this._y1 = this._y2, this._y2 = y;
15316 var cardinalOpen = (
function custom(tension) {
15318 function cardinal$$1(context) {
15319 return new CardinalOpen(context, tension);
15322 cardinal$$1.tension =
function(tension) {
15323 return custom(+tension);
15326 return cardinal$$1;
15329 function point$4(that, x, y) {
15335 if (that._l01_a > epsilon$3) {
15336 var a = 2 * that._l01_2a + 3 * that._l01_a * that._l12_a + that._l12_2a,
15337 n = 3 * that._l01_a * (that._l01_a + that._l12_a);
15338 x1 = (x1 * a - that._x0 * that._l12_2a + that._x2 * that._l01_2a) / n;
15339 y1 = (y1 * a - that._y0 * that._l12_2a + that._y2 * that._l01_2a) / n;
15342 if (that._l23_a > epsilon$3) {
15343 var b = 2 * that._l23_2a + 3 * that._l23_a * that._l12_a + that._l12_2a,
15344 m = 3 * that._l23_a * (that._l23_a + that._l12_a);
15345 x2 = (x2 * b + that._x1 * that._l23_2a - x * that._l12_2a) / m;
15346 y2 = (y2 * b + that._y1 * that._l23_2a - y * that._l12_2a) / m;
15349 that._context.bezierCurveTo(x1, y1, x2, y2, that._x2, that._y2);
15352 function CatmullRom(context, alpha) {
15353 this._context = context;
15354 this._alpha = alpha;
15357 CatmullRom.prototype = {
15358 areaStart:
function() {
15361 areaEnd:
function() {
15364 lineStart:
function() {
15365 this._x0 = this._x1 = this._x2 =
15366 this._y0 = this._y1 = this._y2 = NaN;
15367 this._l01_a = this._l12_a = this._l23_a =
15368 this._l01_2a = this._l12_2a = this._l23_2a =
15371 lineEnd:
function() {
15372 switch (this._point) {
15373 case 2: this._context.lineTo(this._x2, this._y2);
break;
15374 case 3: this.point(this._x2, this._y2);
break;
15376 if (this._line || (this._line !== 0 && this._point === 1)) this._context.closePath();
15377 this._line = 1 - this._line;
15379 point:
function(x, y) {
15383 var x23 = this._x2 - x,
15384 y23 = this._y2 - y;
15385 this._l23_a = Math.sqrt(this._l23_2a = Math.pow(x23 * x23 + y23 * y23,
this._alpha));
15388 switch (this._point) {
15389 case 0: this._point = 1; this._line ? this._context.lineTo(x, y) : this._context.moveTo(x, y);
break;
15390 case 1: this._point = 2;
break;
15391 case 2: this._point = 3;
15392 default: point$4(
this, x, y);
break;
15395 this._l01_a = this._l12_a, this._l12_a = this._l23_a;
15396 this._l01_2a = this._l12_2a, this._l12_2a = this._l23_2a;
15397 this._x0 = this._x1, this._x1 = this._x2, this._x2 = x;
15398 this._y0 = this._y1, this._y1 = this._y2, this._y2 = y;
15402 var catmullRom = (
function custom(alpha) {
15404 function catmullRom(context) {
15405 return alpha ?
new CatmullRom(context, alpha) : new Cardinal(context, 0);
15408 catmullRom.alpha =
function(alpha) {
15409 return custom(+alpha);
15415 function CatmullRomClosed(context, alpha) {
15416 this._context = context;
15417 this._alpha = alpha;
15420 CatmullRomClosed.prototype = {
15423 lineStart:
function() {
15424 this._x0 = this._x1 = this._x2 = this._x3 = this._x4 = this._x5 =
15425 this._y0 = this._y1 = this._y2 = this._y3 = this._y4 = this._y5 = NaN;
15426 this._l01_a = this._l12_a = this._l23_a =
15427 this._l01_2a = this._l12_2a = this._l23_2a =
15430 lineEnd:
function() {
15431 switch (this._point) {
15433 this._context.moveTo(this._x3, this._y3);
15434 this._context.closePath();
15438 this._context.lineTo(this._x3, this._y3);
15439 this._context.closePath();
15443 this.point(this._x3, this._y3);
15444 this.point(this._x4, this._y4);
15445 this.point(this._x5, this._y5);
15450 point:
function(x, y) {
15454 var x23 = this._x2 - x,
15455 y23 = this._y2 - y;
15456 this._l23_a = Math.sqrt(this._l23_2a = Math.pow(x23 * x23 + y23 * y23,
this._alpha));
15459 switch (this._point) {
15460 case 0: this._point = 1; this._x3 = x, this._y3 = y;
break;
15461 case 1: this._point = 2; this._context.moveTo(this._x4 = x, this._y4 = y);
break;
15462 case 2: this._point = 3; this._x5 = x, this._y5 = y;
break;
15463 default: point$4(
this, x, y);
break;
15466 this._l01_a = this._l12_a, this._l12_a = this._l23_a;
15467 this._l01_2a = this._l12_2a, this._l12_2a = this._l23_2a;
15468 this._x0 = this._x1, this._x1 = this._x2, this._x2 = x;
15469 this._y0 = this._y1, this._y1 = this._y2, this._y2 = y;
15473 var catmullRomClosed = (
function custom(alpha) {
15475 function catmullRom$$1(context) {
15476 return alpha ?
new CatmullRomClosed(context, alpha) : new CardinalClosed(context, 0);
15479 catmullRom$$1.alpha =
function(alpha) {
15480 return custom(+alpha);
15483 return catmullRom$$1;
15486 function CatmullRomOpen(context, alpha) {
15487 this._context = context;
15488 this._alpha = alpha;
15491 CatmullRomOpen.prototype = {
15492 areaStart:
function() {
15495 areaEnd:
function() {
15498 lineStart:
function() {
15499 this._x0 = this._x1 = this._x2 =
15500 this._y0 = this._y1 = this._y2 = NaN;
15501 this._l01_a = this._l12_a = this._l23_a =
15502 this._l01_2a = this._l12_2a = this._l23_2a =
15505 lineEnd:
function() {
15506 if (this._line || (this._line !== 0 && this._point === 3)) this._context.closePath();
15507 this._line = 1 - this._line;
15509 point:
function(x, y) {
15513 var x23 = this._x2 - x,
15514 y23 = this._y2 - y;
15515 this._l23_a = Math.sqrt(this._l23_2a = Math.pow(x23 * x23 + y23 * y23,
this._alpha));
15518 switch (this._point) {
15519 case 0: this._point = 1;
break;
15520 case 1: this._point = 2;
break;
15521 case 2: this._point = 3; this._line ? this._context.lineTo(this._x2, this._y2) : this._context.moveTo(this._x2, this._y2);
break;
15522 case 3: this._point = 4;
15523 default: point$4(
this, x, y);
break;
15526 this._l01_a = this._l12_a, this._l12_a = this._l23_a;
15527 this._l01_2a = this._l12_2a, this._l12_2a = this._l23_2a;
15528 this._x0 = this._x1, this._x1 = this._x2, this._x2 = x;
15529 this._y0 = this._y1, this._y1 = this._y2, this._y2 = y;
15533 var catmullRomOpen = (
function custom(alpha) {
15535 function catmullRom$$1(context) {
15536 return alpha ?
new CatmullRomOpen(context, alpha) : new CardinalOpen(context, 0);
15539 catmullRom$$1.alpha =
function(alpha) {
15540 return custom(+alpha);
15543 return catmullRom$$1;
15546 function LinearClosed(context) {
15547 this._context = context;
15550 LinearClosed.prototype = {
15553 lineStart:
function() {
15556 lineEnd:
function() {
15557 if (this._point) this._context.closePath();
15559 point:
function(x, y) {
15561 if (this._point) this._context.lineTo(x, y);
15562 else this._point = 1, this._context.moveTo(x, y);
15566 function linearClosed(context) {
15567 return new LinearClosed(context);
15570 function sign$1(x) {
15571 return x < 0 ? -1 : 1;
15578 function slope3(that, x2, y2) {
15579 var h0 = that._x1 - that._x0,
15580 h1 = x2 - that._x1,
15581 s0 = (that._y1 - that._y0) / (h0 || h1 < 0 && -0),
15582 s1 = (y2 - that._y1) / (h1 || h0 < 0 && -0),
15583 p = (s0 * h1 + s1 * h0) / (h0 + h1);
15584 return (sign$1(s0) + sign$1(s1)) * Math.min(Math.abs(s0), Math.abs(s1), 0.5 * Math.abs(p)) || 0;
15588 function slope2(that, t) {
15589 var h = that._x1 - that._x0;
15590 return h ? (3 * (that._y1 - that._y0) / h - t) / 2 : t;
15596 function point$5(that, t0, t1) {
15601 dx = (x1 - x0) / 3;
15602 that._context.bezierCurveTo(x0 + dx, y0 + dx * t0, x1 - dx, y1 - dx * t1, x1, y1);
15605 function MonotoneX(context) {
15606 this._context = context;
15609 MonotoneX.prototype = {
15610 areaStart:
function() {
15613 areaEnd:
function() {
15616 lineStart:
function() {
15617 this._x0 = this._x1 =
15618 this._y0 = this._y1 =
15622 lineEnd:
function() {
15623 switch (this._point) {
15624 case 2: this._context.lineTo(this._x1, this._y1);
break;
15625 case 3: point$5(
this, this._t0, slope2(
this, this._t0));
break;
15627 if (this._line || (this._line !== 0 && this._point === 1)) this._context.closePath();
15628 this._line = 1 - this._line;
15630 point:
function(x, y) {
15634 if (x === this._x1 && y === this._y1)
return;
15635 switch (this._point) {
15636 case 0: this._point = 1; this._line ? this._context.lineTo(x, y) : this._context.moveTo(x, y);
break;
15637 case 1: this._point = 2;
break;
15638 case 2: this._point = 3; point$5(
this, slope2(
this, t1 = slope3(
this, x, y)), t1);
break;
15639 default: point$5(
this, this._t0, t1 = slope3(
this, x, y));
break;
15642 this._x0 = this._x1, this._x1 = x;
15643 this._y0 = this._y1, this._y1 = y;
15648 function MonotoneY(context) {
15649 this._context =
new ReflectContext(context);
15652 (MonotoneY.prototype = Object.create(MonotoneX.prototype)).point =
function(x, y) {
15653 MonotoneX.prototype.point.call(
this, y, x);
15656 function ReflectContext(context) {
15657 this._context = context;
15660 ReflectContext.prototype = {
15661 moveTo:
function(x, y) { this._context.moveTo(y, x); },
15662 closePath:
function() { this._context.closePath(); },
15663 lineTo:
function(x, y) { this._context.lineTo(y, x); },
15664 bezierCurveTo:
function(x1, y1, x2, y2, x, y) { this._context.bezierCurveTo(y1, x1, y2, x2, y, x); }
15667 function monotoneX(context) {
15668 return new MonotoneX(context);
15671 function monotoneY(context) {
15672 return new MonotoneY(context);
15675 function Natural(context) {
15676 this._context = context;
15679 Natural.prototype = {
15680 areaStart:
function() {
15683 areaEnd:
function() {
15686 lineStart:
function() {
15690 lineEnd:
function() {
15696 this._line ? this._context.lineTo(x[0], y[0]) : this._context.moveTo(x[0], y[0]);
15698 this._context.lineTo(x[1], y[1]);
15700 var px = controlPoints(x),
15701 py = controlPoints(y);
15702 for (var i0 = 0, i1 = 1; i1 < n; ++i0, ++i1) {
15703 this._context.bezierCurveTo(px[0][i0], py[0][i0], px[1][i0], py[1][i0], x[i1], y[i1]);
15708 if (this._line || (this._line !== 0 && n === 1)) this._context.closePath();
15709 this._line = 1 - this._line;
15710 this._x = this._y = null;
15712 point:
function(x, y) {
15719 function controlPoints(x) {
15726 a[0] = 0, b[0] = 2, r[0] = x[0] + 2 * x[1];
15727 for (i = 1; i < n - 1; ++i) a[i] = 1, b[i] = 4, r[i] = 4 * x[i] + 2 * x[i + 1];
15728 a[n - 1] = 2, b[n - 1] = 7, r[n - 1] = 8 * x[n - 1] + x[n];
15729 for (i = 1; i < n; ++i) m = a[i] / b[i - 1], b[i] -= m, r[i] -= m * r[i - 1];
15730 a[n - 1] = r[n - 1] / b[n - 1];
15731 for (i = n - 2; i >= 0; --i) a[i] = (r[i] - a[i + 1]) / b[i];
15732 b[n - 1] = (x[n] + a[n - 1]) / 2;
15733 for (i = 0; i < n - 1; ++i) b[i] = 2 * x[i + 1] - a[i + 1];
15737 function natural(context) {
15738 return new Natural(context);
15741 function Step(context, t) {
15742 this._context = context;
15747 areaStart:
function() {
15750 areaEnd:
function() {
15753 lineStart:
function() {
15754 this._x = this._y = NaN;
15757 lineEnd:
function() {
15758 if (0 < this._t && this._t < 1 && this._point === 2) this._context.lineTo(this._x, this._y);
15759 if (this._line || (this._line !== 0 && this._point === 1)) this._context.closePath();
15760 if (this._line >= 0) this._t = 1 - this._t, this._line = 1 - this._line;
15762 point:
function(x, y) {
15764 switch (this._point) {
15765 case 0: this._point = 1; this._line ? this._context.lineTo(x, y) : this._context.moveTo(x, y);
break;
15766 case 1: this._point = 2;
15768 if (this._t <= 0) {
15769 this._context.lineTo(this._x, y);
15770 this._context.lineTo(x, y);
15772 var x1 = this._x * (1 - this._t) + x * this._t;
15773 this._context.lineTo(x1, this._y);
15774 this._context.lineTo(x1, y);
15779 this._x = x, this._y = y;
15783 function step(context) {
15784 return new Step(context, 0.5);
15787 function stepBefore(context) {
15788 return new Step(context, 0);
15791 function stepAfter(context) {
15792 return new Step(context, 1);
15795 function none$1(series, order) {
15796 if (!((n = series.length) > 1))
return;
15797 for (var i = 1, j, s0, s1 = series[order[0]], n, m = s1.length; i < n; ++i) {
15798 s0 = s1, s1 = series[order[i]];
15799 for (j = 0; j < m; ++j) {
15800 s1[j][1] += s1[j][0] = isNaN(s0[j][1]) ? s0[j][0] : s0[j][1];
15805 function none$2(series) {
15806 var n = series.length, o =
new Array(n);
15807 while (--n >= 0) o[n] = n;
15811 function stackValue(d, key) {
15816 var keys = constant$b([]),
15819 value = stackValue;
15821 function stack(data) {
15822 var kz = keys.apply(
this, arguments),
15829 for (i = 0; i < n; ++i) {
15830 for (var ki = kz[i], si = sz[i] =
new Array(m), j = 0, sij; j < m; ++j) {
15831 si[j] = sij = [0, +value(data[j], ki, j, data)];
15832 sij.data = data[j];
15837 for (i = 0, oz = order(sz); i < n; ++i) {
15838 sz[oz[i]].index = i;
15845 stack.keys =
function(_) {
15846 return arguments.length ? (keys = typeof _ ===
"function" ? _ : constant$b(slice$6.call(_)), stack) : keys;
15849 stack.value =
function(_) {
15850 return arguments.length ? (value = typeof _ ===
"function" ? _ : constant$b(+_), stack) : value;
15853 stack.order =
function(_) {
15854 return arguments.length ? (order = _ == null ? none$2 : typeof _ ===
"function" ? _ : constant$b(slice$6.call(_)), stack) : order;
15857 stack.offset =
function(_) {
15858 return arguments.length ? (offset = _ == null ? none$1 : _, stack) : offset;
15864 function expand(series, order) {
15865 if (!((n = series.length) > 0))
return;
15866 for (var i, n, j = 0, m = series[0].length, y; j < m; ++j) {
15867 for (y = i = 0; i < n; ++i) y += series[i][j][1] || 0;
15868 if (y)
for (i = 0; i < n; ++i) series[i][j][1] /= y;
15870 none$1(series, order);
15873 function diverging$1(series, order) {
15874 if (!((n = series.length) > 1))
return;
15875 for (var i, j = 0, d, dy, yp, yn, n, m = series[order[0]].length; j < m; ++j) {
15876 for (yp = yn = 0, i = 0; i < n; ++i) {
15877 if ((dy = (d = series[order[i]][j])[1] - d[0]) >= 0) {
15878 d[0] = yp, d[1] = yp += dy;
15879 }
else if (dy < 0) {
15880 d[1] = yn, d[0] = yn += dy;
15888 function silhouette(series, order) {
15889 if (!((n = series.length) > 0))
return;
15890 for (var j = 0, s0 = series[order[0]], n, m = s0.length; j < m; ++j) {
15891 for (var i = 0, y = 0; i < n; ++i) y += series[i][j][1] || 0;
15892 s0[j][1] += s0[j][0] = -y / 2;
15894 none$1(series, order);
15897 function wiggle(series, order) {
15898 if (!((n = series.length) > 0) || !((m = (s0 = series[order[0]]).length) > 0))
return;
15899 for (var y = 0, j = 1, s0, m, n; j < m; ++j) {
15900 for (var i = 0, s1 = 0, s2 = 0; i < n; ++i) {
15901 var si = series[order[i]],
15902 sij0 = si[j][1] || 0,
15903 sij1 = si[j - 1][1] || 0,
15904 s3 = (sij0 - sij1) / 2;
15905 for (var k = 0; k < i; ++k) {
15906 var sk = series[order[k]],
15907 skj0 = sk[j][1] || 0,
15908 skj1 = sk[j - 1][1] || 0;
15911 s1 += sij0, s2 += s3 * sij0;
15913 s0[j - 1][1] += s0[j - 1][0] = y;
15914 if (s1) y -= s2 / s1;
15916 s0[j - 1][1] += s0[j - 1][0] = y;
15917 none$1(series, order);
15920 function ascending$3(series) {
15921 var sums = series.map(sum$2);
15922 return none$2(series).sort(
function(a, b) {
return sums[a] - sums[b]; });
15925 function sum$2(series) {
15926 var s = 0, i = -1, n = series.length, v;
15927 while (++i < n)
if (v = +series[i][1]) s += v;
15931 function descending$2(series) {
15932 return ascending$3(series).reverse();
15935 function insideOut(series) {
15936 var n = series.length,
15939 sums = series.map(sum$2),
15940 order = none$2(series).sort(
function(a, b) {
return sums[b] - sums[a]; }),
15946 for (i = 0; i < n; ++i) {
15948 if (top < bottom) {
15957 return bottoms.reverse().concat(tops);
15960 function reverse(series) {
15961 return none$2(series).reverse();
15964 function constant$c(x) {
15965 return function() {
15978 function RedBlackTree() {
15982 function RedBlackNode(node) {
15991 RedBlackTree.prototype = {
15992 constructor: RedBlackTree,
15994 insert:
function(after, node) {
15995 var parent, grandpa, uncle;
16000 if (after.N) after.N.P = node;
16004 while (after.L) after = after.L;
16010 }
else if (this._) {
16011 after = RedBlackFirst(this._);
16014 after.P = after.L = node;
16017 node.P = node.N = null;
16021 node.L = node.R = null;
16026 while (parent && parent.C) {
16027 grandpa = parent.U;
16028 if (parent === grandpa.L) {
16030 if (uncle && uncle.C) {
16031 parent.C = uncle.C =
false;
16035 if (after === parent.R) {
16036 RedBlackRotateLeft(
this, parent);
16042 RedBlackRotateRight(
this, grandpa);
16046 if (uncle && uncle.C) {
16047 parent.C = uncle.C =
false;
16051 if (after === parent.L) {
16052 RedBlackRotateRight(
this, parent);
16058 RedBlackRotateLeft(
this, grandpa);
16066 remove:
function(node) {
16067 if (node.N) node.N.P = node.P;
16068 if (node.P) node.P.N = node.N;
16069 node.N = node.P = null;
16071 var parent = node.U,
16078 if (!left) next = right;
16079 else if (!right) next = left;
16080 else next = RedBlackFirst(right);
16083 if (parent.L === node) parent.L = next;
16084 else parent.R = next;
16089 if (left && right) {
16094 if (next !== right) {
16111 if (node) node.U = parent;
16113 if (node && node.C) { node.C =
false;
return; }
16116 if (node === this._)
break;
16117 if (node === parent.L) {
16118 sibling = parent.R;
16122 RedBlackRotateLeft(
this, parent);
16123 sibling = parent.R;
16125 if ((sibling.L && sibling.L.C)
16126 || (sibling.R && sibling.R.C)) {
16127 if (!sibling.R || !sibling.R.C) {
16128 sibling.L.C =
false;
16130 RedBlackRotateRight(
this, sibling);
16131 sibling = parent.R;
16133 sibling.C = parent.C;
16134 parent.C = sibling.R.C =
false;
16135 RedBlackRotateLeft(
this, parent);
16140 sibling = parent.L;
16144 RedBlackRotateRight(
this, parent);
16145 sibling = parent.L;
16147 if ((sibling.L && sibling.L.C)
16148 || (sibling.R && sibling.R.C)) {
16149 if (!sibling.L || !sibling.L.C) {
16150 sibling.R.C =
false;
16152 RedBlackRotateLeft(
this, sibling);
16153 sibling = parent.L;
16155 sibling.C = parent.C;
16156 parent.C = sibling.L.C =
false;
16157 RedBlackRotateRight(
this, parent);
16167 if (node) node.C =
false;
16171 function RedBlackRotateLeft(tree, node) {
16177 if (parent.L === p) parent.L = q;
16186 if (p.R) p.R.U = p;
16190 function RedBlackRotateRight(tree, node) {
16196 if (parent.L === p) parent.L = q;
16205 if (p.L) p.L.U = p;
16209 function RedBlackFirst(node) {
16210 while (node.L) node = node.L;
16214 function createEdge(left, right, v0, v1) {
16215 var edge = [null, null],
16216 index = edges.push(edge) - 1;
16218 edge.right = right;
16219 if (v0) setEdgeEnd(edge, left, right, v0);
16220 if (v1) setEdgeEnd(edge, right, left, v1);
16221 cells[left.index].halfedges.push(index);
16222 cells[right.index].halfedges.push(index);
16226 function createBorderEdge(left, v0, v1) {
16227 var edge = [v0, v1];
16232 function setEdgeEnd(edge, left, right, vertex) {
16233 if (!edge[0] && !edge[1]) {
16236 edge.right = right;
16237 }
else if (edge.left === right) {
16245 function clipEdge(edge, x0, y0, x1, y1) {
16259 if (!dx && r > 0)
return;
16262 if (r < t0)
return;
16263 if (r < t1) t1 = r;
16264 }
else if (dx > 0) {
16265 if (r > t1)
return;
16266 if (r > t0) t0 = r;
16270 if (!dx && r < 0)
return;
16273 if (r > t1)
return;
16274 if (r > t0) t0 = r;
16275 }
else if (dx > 0) {
16276 if (r < t0)
return;
16277 if (r < t1) t1 = r;
16281 if (!dy && r > 0)
return;
16284 if (r < t0)
return;
16285 if (r < t1) t1 = r;
16286 }
else if (dy > 0) {
16287 if (r > t1)
return;
16288 if (r > t0) t0 = r;
16292 if (!dy && r < 0)
return;
16295 if (r > t1)
return;
16296 if (r > t0) t0 = r;
16297 }
else if (dy > 0) {
16298 if (r < t0)
return;
16299 if (r < t1) t1 = r;
16302 if (!(t0 > 0) && !(t1 < 1))
return true;
16304 if (t0 > 0) edge[0] = [ax + t0 * dx, ay + t0 * dy];
16305 if (t1 < 1) edge[1] = [ax + t1 * dx, ay + t1 * dy];
16309 function connectEdge(edge, x0, y0, x1, y1) {
16311 if (v1)
return true;
16315 right = edge.right,
16320 fx = (lx + rx) / 2,
16321 fy = (ly + ry) / 2,
16326 if (fx < x0 || fx >= x1)
return;
16328 if (!v0) v0 = [fx, y0];
16329 else if (v0[1] >= y1)
return;
16332 if (!v0) v0 = [fx, y1];
16333 else if (v0[1] < y0)
return;
16337 fm = (lx - rx) / (ry - ly);
16339 if (fm < -1 || fm > 1) {
16341 if (!v0) v0 = [(y0 - fb) / fm, y0];
16342 else if (v0[1] >= y1)
return;
16343 v1 = [(y1 - fb) / fm, y1];
16345 if (!v0) v0 = [(y1 - fb) / fm, y1];
16346 else if (v0[1] < y0)
return;
16347 v1 = [(y0 - fb) / fm, y0];
16351 if (!v0) v0 = [x0, fm * x0 + fb];
16352 else if (v0[0] >= x1)
return;
16353 v1 = [x1, fm * x1 + fb];
16355 if (!v0) v0 = [x1, fm * x1 + fb];
16356 else if (v0[0] < x0)
return;
16357 v1 = [x0, fm * x0 + fb];
16367 function clipEdges(x0, y0, x1, y1) {
16368 var i = edges.length,
16372 if (!connectEdge(edge = edges[i], x0, y0, x1, y1)
16373 || !clipEdge(edge, x0, y0, x1, y1)
16374 || !(Math.abs(edge[0][0] - edge[1][0]) > epsilon$4
16375 || Math.abs(edge[0][1] - edge[1][1]) > epsilon$4)) {
16381 function createCell(site) {
16382 return cells[site.index] = {
16388 function cellHalfedgeAngle(cell, edge) {
16389 var site = cell.site,
16392 if (site === vb) vb = va, va = site;
16393 if (vb)
return Math.atan2(vb[1] - va[1], vb[0] - va[0]);
16394 if (site === va) va = edge[1], vb = edge[0];
16395 else va = edge[0], vb = edge[1];
16396 return Math.atan2(va[0] - vb[0], vb[1] - va[1]);
16399 function cellHalfedgeStart(cell, edge) {
16400 return edge[+(edge.left !== cell.site)];
16403 function cellHalfedgeEnd(cell, edge) {
16404 return edge[+(edge.left === cell.site)];
16407 function sortCellHalfedges() {
16408 for (var i = 0, n = cells.length, cell, halfedges, j, m; i < n; ++i) {
16409 if ((cell = cells[i]) && (m = (halfedges = cell.halfedges).length)) {
16410 var index =
new Array(m),
16411 array =
new Array(m);
16412 for (j = 0; j < m; ++j) index[j] = j, array[j] = cellHalfedgeAngle(cell, edges[halfedges[j]]);
16413 index.sort(
function(i, j) {
return array[j] - array[i]; });
16414 for (j = 0; j < m; ++j) array[j] = halfedges[index[j]];
16415 for (j = 0; j < m; ++j) halfedges[j] = array[j];
16420 function clipCells(x0, y0, x1, y1) {
16421 var nCells = cells.length,
16436 for (iCell = 0; iCell < nCells; ++iCell) {
16437 if (cell = cells[iCell]) {
16439 halfedges = cell.halfedges;
16440 iHalfedge = halfedges.length;
16443 while (iHalfedge--) {
16444 if (!edges[halfedges[iHalfedge]]) {
16445 halfedges.splice(iHalfedge, 1);
16450 iHalfedge = 0, nHalfedges = halfedges.length;
16451 while (iHalfedge < nHalfedges) {
16452 end = cellHalfedgeEnd(cell, edges[halfedges[iHalfedge]]), endX = end[0], endY = end[1];
16453 start = cellHalfedgeStart(cell, edges[halfedges[++iHalfedge % nHalfedges]]), startX = start[0], startY = start[1];
16454 if (Math.abs(endX - startX) > epsilon$4 || Math.abs(endY - startY) > epsilon$4) {
16455 halfedges.splice(iHalfedge, 0, edges.push(createBorderEdge(site, end,
16456 Math.abs(endX - x0) < epsilon$4 && y1 - endY > epsilon$4 ? [x0, Math.abs(startX - x0) < epsilon$4 ? startY : y1]
16457 : Math.abs(endY - y1) < epsilon$4 && x1 - endX > epsilon$4 ? [Math.abs(startY - y1) < epsilon$4 ? startX : x1, y1]
16458 : Math.abs(endX - x1) < epsilon$4 && endY - y0 > epsilon$4 ? [x1, Math.abs(startX - x1) < epsilon$4 ? startY : y0]
16459 : Math.abs(endY - y0) < epsilon$4 && endX - x0 > epsilon$4 ? [Math.abs(startY - y0) < epsilon$4 ? startX : x0, y0]
16465 if (nHalfedges) cover =
false;
16472 var dx, dy, d2, dc = Infinity;
16474 for (iCell = 0, cover = null; iCell < nCells; ++iCell) {
16475 if (cell = cells[iCell]) {
16479 d2 = dx * dx + dy * dy;
16480 if (d2 < dc) dc = d2, cover = cell;
16485 var v00 = [x0, y0], v01 = [x0, y1], v11 = [x1, y1], v10 = [x1, y0];
16486 cover.halfedges.push(
16487 edges.push(createBorderEdge(site = cover.site, v00, v01)) - 1,
16488 edges.push(createBorderEdge(site, v01, v11)) - 1,
16489 edges.push(createBorderEdge(site, v11, v10)) - 1,
16490 edges.push(createBorderEdge(site, v10, v00)) - 1
16496 for (iCell = 0; iCell < nCells; ++iCell) {
16497 if (cell = cells[iCell]) {
16498 if (!cell.halfedges.length) {
16499 delete cells[iCell];
16505 var circlePool = [];
16509 function Circle() {
16510 RedBlackNode(
this);
16518 function attachCircle(arc) {
16522 if (!lArc || !rArc)
return;
16524 var lSite = lArc.site,
16528 if (lSite === rSite)
return;
16532 ax = lSite[0] - bx,
16533 ay = lSite[1] - by,
16534 cx = rSite[0] - bx,
16535 cy = rSite[1] - by;
16537 var d = 2 * (ax * cy - ay * cx);
16538 if (d >= -epsilon2$2)
return;
16540 var ha = ax * ax + ay * ay,
16541 hc = cx * cx + cy * cy,
16542 x = (cy * ha - ay * hc) / d,
16543 y = (ax * hc - cx * ha) / d;
16545 var circle = circlePool.pop() ||
new Circle;
16547 circle.site = cSite;
16549 circle.y = (circle.cy = y + by) + Math.sqrt(x * x + y * y);
16551 arc.circle = circle;
16557 if (circle.y < node.y || (circle.y === node.y && circle.x <= node.x)) {
16558 if (node.L) node = node.L;
16559 else { before = node.P;
break; }
16561 if (node.R) node = node.R;
16562 else { before = node;
break; }
16566 circles.insert(before, circle);
16567 if (!before) firstCircle = circle;
16570 function detachCircle(arc) {
16571 var circle = arc.circle;
16573 if (!circle.P) firstCircle = circle.N;
16574 circles.remove(circle);
16575 circlePool.push(circle);
16576 RedBlackNode(circle);
16581 var beachPool = [];
16584 RedBlackNode(
this);
16587 this.circle = null;
16590 function createBeach(site) {
16591 var beach = beachPool.pop() ||
new Beach;
16596 function detachBeach(beach) {
16597 detachCircle(beach);
16598 beaches.remove(beach);
16599 beachPool.push(beach);
16600 RedBlackNode(beach);
16603 function removeBeach(beach) {
16604 var circle = beach.circle,
16608 previous = beach.P,
16610 disappearing = [beach];
16612 detachBeach(beach);
16614 var lArc = previous;
16616 && Math.abs(x - lArc.circle.x) < epsilon$4
16617 && Math.abs(y - lArc.circle.cy) < epsilon$4) {
16619 disappearing.unshift(lArc);
16624 disappearing.unshift(lArc);
16625 detachCircle(lArc);
16629 && Math.abs(x - rArc.circle.x) < epsilon$4
16630 && Math.abs(y - rArc.circle.cy) < epsilon$4) {
16632 disappearing.push(rArc);
16637 disappearing.push(rArc);
16638 detachCircle(rArc);
16640 var nArcs = disappearing.length,
16642 for (iArc = 1; iArc < nArcs; ++iArc) {
16643 rArc = disappearing[iArc];
16644 lArc = disappearing[iArc - 1];
16645 setEdgeEnd(rArc.edge, lArc.site, rArc.site, vertex);
16648 lArc = disappearing[0];
16649 rArc = disappearing[nArcs - 1];
16650 rArc.edge = createEdge(lArc.site, rArc.site, null, vertex);
16652 attachCircle(lArc);
16653 attachCircle(rArc);
16656 function addBeach(site) {
16658 directrix = site[1],
16666 dxl = leftBreakPoint(node, directrix) - x;
16667 if (dxl > epsilon$4) node = node.L;
else {
16668 dxr = x - rightBreakPoint(node, directrix);
16669 if (dxr > epsilon$4) {
16676 if (dxl > -epsilon$4) {
16679 }
else if (dxr > -epsilon$4) {
16683 lArc = rArc = node;
16691 var newArc = createBeach(site);
16692 beaches.insert(lArc, newArc);
16694 if (!lArc && !rArc)
return;
16696 if (lArc === rArc) {
16697 detachCircle(lArc);
16698 rArc = createBeach(lArc.site);
16699 beaches.insert(newArc, rArc);
16700 newArc.edge = rArc.edge = createEdge(lArc.site, newArc.site);
16701 attachCircle(lArc);
16702 attachCircle(rArc);
16707 newArc.edge = createEdge(lArc.site, newArc.site);
16712 detachCircle(lArc);
16713 detachCircle(rArc);
16715 var lSite = lArc.site,
16721 cx = rSite[0] - ax,
16722 cy = rSite[1] - ay,
16723 d = 2 * (bx * cy - by * cx),
16724 hb = bx * bx + by * by,
16725 hc = cx * cx + cy * cy,
16726 vertex = [(cy * hb - by * hc) / d + ax, (bx * hc - cx * hb) / d + ay];
16728 setEdgeEnd(rArc.edge, lSite, rSite, vertex);
16729 newArc.edge = createEdge(lSite, site, null, vertex);
16730 rArc.edge = createEdge(site, rSite, null, vertex);
16731 attachCircle(lArc);
16732 attachCircle(rArc);
16735 function leftBreakPoint(arc, directrix) {
16736 var site = arc.site,
16739 pby2 = rfocy - directrix;
16741 if (!pby2)
return rfocx;
16744 if (!lArc)
return -Infinity;
16747 var lfocx = site[0],
16749 plby2 = lfocy - directrix;
16751 if (!plby2)
return lfocx;
16753 var hl = lfocx - rfocx,
16754 aby2 = 1 / pby2 - 1 / plby2,
16757 if (aby2)
return (-b + Math.sqrt(b * b - 2 * aby2 * (hl * hl / (-2 * plby2) - lfocy + plby2 / 2 + rfocy - pby2 / 2))) / aby2 + rfocx;
16759 return (rfocx + lfocx) / 2;
16762 function rightBreakPoint(arc, directrix) {
16764 if (rArc)
return leftBreakPoint(rArc, directrix);
16765 var site = arc.site;
16766 return site[1] === directrix ? site[0] : Infinity;
16769 var epsilon$4 = 1e-6;
16770 var epsilon2$2 = 1e-12;
16776 function triangleArea(a, b, c) {
16777 return (a[0] - c[0]) * (b[1] - a[1]) - (a[0] - b[0]) * (c[1] - a[1]);
16780 function lexicographic(a, b) {
16785 function Diagram(sites, extent) {
16786 var site = sites.sort(lexicographic).pop(),
16792 cells =
new Array(sites.length);
16793 beaches =
new RedBlackTree;
16794 circles =
new RedBlackTree;
16797 circle = firstCircle;
16798 if (site && (!circle || site[1] < circle.y || (site[1] === circle.y && site[0] < circle.x))) {
16799 if (site[0] !== x || site[1] !== y) {
16801 x = site[0], y = site[1];
16803 site = sites.pop();
16804 }
else if (circle) {
16805 removeBeach(circle.arc);
16811 sortCellHalfedges();
16814 var x0 = +extent[0][0],
16815 y0 = +extent[0][1],
16816 x1 = +extent[1][0],
16817 y1 = +extent[1][1];
16818 clipEdges(x0, y0, x1, y1);
16819 clipCells(x0, y0, x1, y1);
16822 this.edges = edges;
16823 this.cells = cells;
16831 Diagram.prototype = {
16832 constructor: Diagram,
16834 polygons:
function() {
16835 var edges = this.edges;
16837 return this.cells.map(
function(cell) {
16838 var polygon = cell.halfedges.map(
function(i) {
return cellHalfedgeStart(cell, edges[i]); });
16839 polygon.data = cell.site.data;
16844 triangles:
function() {
16845 var triangles = [],
16846 edges = this.edges;
16848 this.cells.forEach(
function(cell, i) {
16849 if (!(m = (halfedges = cell.halfedges).length))
return;
16850 var site = cell.site,
16855 e1 = edges[halfedges[m - 1]],
16856 s1 = e1.left === site ? e1.right : e1.left;
16860 e1 = edges[halfedges[j]];
16861 s1 = e1.left === site ? e1.right : e1.left;
16862 if (s0 && s1 && i < s0.index && i < s1.index && triangleArea(site, s0, s1) < 0) {
16863 triangles.push([site.data, s0.data, s1.data]);
16871 links:
function() {
16872 return this.edges.filter(
function(edge) {
16874 }).map(
function(edge) {
16876 source: edge.left.data,
16877 target: edge.right.data
16882 find:
function(x, y, radius) {
16883 var that =
this, i0, i1 = that._found || 0, n = that.cells.length, cell;
16886 while (!(cell = that.cells[i1]))
if (++i1 >= n)
return null;
16887 var dx = x - cell.site[0], dy = y - cell.site[1], d2 = dx * dx + dy * dy;
16891 cell = that.cells[i0 = i1], i1 = null;
16892 cell.halfedges.forEach(
function(e) {
16893 var edge = that.edges[e], v = edge.left;
16894 if ((v === cell.site || !v) && !(v = edge.right))
return;
16895 var vx = x - v[0], vy = y - v[1], v2 = vx * vx + vy * vy;
16896 if (v2 < d2) d2 = v2, i1 = v.index;
16898 }
while (i1 !== null);
16902 return radius == null || d2 <= radius * radius ? cell.site : null;
16906 function voronoi() {
16911 function voronoi(data) {
16912 return new Diagram(data.map(
function(d, i) {
16913 var s = [Math.round(x$$1(d, i, data) / epsilon$4) * epsilon$4, Math.round(y$$1(d, i, data) / epsilon$4) * epsilon$4];
16920 voronoi.polygons =
function(data) {
16921 return voronoi(data).polygons();
16924 voronoi.links =
function(data) {
16925 return voronoi(data).links();
16928 voronoi.triangles =
function(data) {
16929 return voronoi(data).triangles();
16932 voronoi.x =
function(_) {
16933 return arguments.length ? (x$$1 = typeof _ ===
"function" ? _ : constant$c(+_), voronoi) : x$$1;
16936 voronoi.y =
function(_) {
16937 return arguments.length ? (y$$1 = typeof _ ===
"function" ? _ : constant$c(+_), voronoi) : y$$1;
16940 voronoi.extent =
function(_) {
16941 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]]];
16944 voronoi.size =
function(_) {
16945 return arguments.length ? (extent = _ == null ? null : [[0, 0], [+_[0], +_[1]]], voronoi) : extent && [extent[1][0] - extent[0][0], extent[1][1] - extent[0][1]];
16951 function constant$d(x) {
16952 return function() {
16957 function ZoomEvent(target, type, transform) {
16958 this.target = target;
16960 this.transform = transform;
16963 function Transform(k, x, y) {
16969 Transform.prototype = {
16970 constructor: Transform,
16971 scale:
function(k) {
16972 return k === 1 ?
this :
new Transform(this.k * k, this.x, this.y);
16974 translate:
function(x, y) {
16975 return x === 0 & y === 0 ?
this :
new Transform(this.k, this.x + this.k * x, this.y + this.k * y);
16977 apply:
function(point) {
16978 return [point[0] * this.k + this.x, point[1] * this.k + this.y];
16980 applyX:
function(x) {
16981 return x * this.k + this.x;
16983 applyY:
function(y) {
16984 return y * this.k + this.y;
16986 invert:
function(location) {
16987 return [(location[0] - this.x) / this.k, (location[1] - this.y) / this.k];
16989 invertX:
function(x) {
16990 return (x - this.x) / this.k;
16992 invertY:
function(y) {
16993 return (y - this.y) / this.k;
16995 rescaleX:
function(x) {
16996 return x.copy().domain(x.range().map(this.invertX,
this).map(x.invert, x));
16998 rescaleY:
function(y) {
16999 return y.copy().domain(y.range().map(this.invertY,
this).map(y.invert, y));
17001 toString:
function() {
17002 return "translate(" + this.x +
"," + this.y +
") scale(" + this.k +
")";
17006 var identity$8 =
new Transform(1, 0, 0);
17008 transform$1.prototype = Transform.prototype;
17010 function transform$1(node) {
17011 return node.__zoom || identity$8;
17014 function nopropagation$2() {
17015 exports.event.stopImmediatePropagation();
17018 function noevent$2() {
17019 exports.event.preventDefault();
17020 exports.event.stopImmediatePropagation();
17024 function defaultFilter$2() {
17025 return !exports.event.button;
17028 function defaultExtent$1() {
17029 var e =
this, w, h;
17030 if (e instanceof SVGElement) {
17031 e = e.ownerSVGElement || e;
17032 w = e.width.baseVal.value;
17033 h = e.height.baseVal.value;
17036 h = e.clientHeight;
17038 return [[0, 0], [w, h]];
17041 function defaultTransform() {
17042 return this.__zoom || identity$8;
17045 function defaultWheelDelta() {
17046 return -exports.event.deltaY * (exports.event.deltaMode ? 120 : 1) / 500;
17049 function defaultTouchable$1() {
17050 return "ontouchstart" in
this;
17053 function defaultConstrain(transform, extent, translateExtent) {
17054 var dx0 = transform.invertX(extent[0][0]) - translateExtent[0][0],
17055 dx1 = transform.invertX(extent[1][0]) - translateExtent[1][0],
17056 dy0 = transform.invertY(extent[0][1]) - translateExtent[0][1],
17057 dy1 = transform.invertY(extent[1][1]) - translateExtent[1][1];
17058 return transform.translate(
17059 dx1 > dx0 ? (dx0 + dx1) / 2 : Math.min(0, dx0) || Math.max(0, dx1),
17060 dy1 > dy0 ? (dy0 + dy1) / 2 : Math.min(0, dy0) || Math.max(0, dy1)
17065 var filter = defaultFilter$2,
17066 extent = defaultExtent$1,
17067 constrain = defaultConstrain,
17068 wheelDelta = defaultWheelDelta,
17069 touchable = defaultTouchable$1,
17070 scaleExtent = [0, Infinity],
17071 translateExtent = [[-Infinity, -Infinity], [Infinity, Infinity]],
17073 interpolate = interpolateZoom,
17075 listeners = dispatch(
"start",
"zoom",
"end"),
17080 clickDistance2 = 0;
17082 function zoom(selection$$1) {
17084 .property(
"__zoom", defaultTransform)
17085 .on(
"wheel.zoom", wheeled)
17086 .on(
"mousedown.zoom", mousedowned)
17087 .on(
"dblclick.zoom", dblclicked)
17089 .on(
"touchstart.zoom", touchstarted)
17090 .on(
"touchmove.zoom", touchmoved)
17091 .on(
"touchend.zoom touchcancel.zoom", touchended)
17092 .style(
"touch-action",
"none")
17093 .style(
"-webkit-tap-highlight-color",
"rgba(0,0,0,0)");
17096 zoom.transform =
function(collection, transform) {
17097 var selection$$1 = collection.selection ? collection.selection() : collection;
17098 selection$$1.property(
"__zoom", defaultTransform);
17099 if (collection !== selection$$1) {
17100 schedule(collection, transform);
17102 selection$$1.interrupt().each(
function() {
17103 gesture(
this, arguments)
17105 .zoom(null, typeof transform ===
"function" ? transform.apply(
this, arguments) : transform)
17111 zoom.scaleBy =
function(selection$$1, k) {
17112 zoom.scaleTo(selection$$1,
function() {
17113 var k0 = this.__zoom.k,
17114 k1 = typeof k ===
"function" ? k.apply(
this, arguments) : k;
17119 zoom.scaleTo =
function(selection$$1, k) {
17120 zoom.transform(selection$$1,
function() {
17121 var e = extent.apply(
this, arguments),
17124 p1 = t0.invert(p0),
17125 k1 = typeof k ===
"function" ? k.apply(
this, arguments) : k;
17126 return constrain(translate(scale(t0, k1), p0, p1), e, translateExtent);
17130 zoom.translateBy =
function(selection$$1, x, y) {
17131 zoom.transform(selection$$1,
function() {
17132 return constrain(this.__zoom.translate(
17133 typeof x ===
"function" ? x.apply(
this, arguments) : x,
17134 typeof y ===
"function" ? y.apply(
this, arguments) : y
17135 ), extent.apply(
this, arguments), translateExtent);
17139 zoom.translateTo =
function(selection$$1, x, y) {
17140 zoom.transform(selection$$1,
function() {
17141 var e = extent.apply(
this, arguments),
17144 return constrain(identity$8.translate(p[0], p[1]).scale(t.k).translate(
17145 typeof x ===
"function" ? -x.apply(
this, arguments) : -x,
17146 typeof y ===
"function" ? -y.apply(
this, arguments) : -y
17147 ), e, translateExtent);
17151 function scale(transform, k) {
17152 k = Math.max(scaleExtent[0], Math.min(scaleExtent[1], k));
17153 return k === transform.k ? transform :
new Transform(k, transform.x, transform.y);
17156 function translate(transform, p0, p1) {
17157 var x = p0[0] - p1[0] * transform.k, y = p0[1] - p1[1] * transform.k;
17158 return x === transform.x && y === transform.y ? transform :
new Transform(transform.k, x, y);
17161 function centroid(extent) {
17162 return [(+extent[0][0] + +extent[1][0]) / 2, (+extent[0][1] + +extent[1][1]) / 2];
17165 function schedule(transition$$1, transform, center) {
17167 .on(
"start.zoom",
function() { gesture(
this, arguments).start(); })
17168 .on(
"interrupt.zoom end.zoom",
function() { gesture(
this, arguments).end(); })
17169 .tween(
"zoom",
function() {
17172 g = gesture(that, args),
17173 e = extent.apply(that, args),
17174 p = center || centroid(e),
17175 w = Math.max(e[1][0] - e[0][0], e[1][1] - e[0][1]),
17177 b = typeof transform ===
"function" ? transform.apply(that, args) : transform,
17178 i = interpolate(a.invert(p).concat(w / a.k), b.invert(p).concat(w / b.k));
17179 return function(t) {
17180 if (t === 1) t = b;
17181 else { var l = i(t), k = w / l[2]; t =
new Transform(k, p[0] - l[0] * k, p[1] - l[1] * k); }
17187 function gesture(that, args) {
17188 for (var i = 0, n = gestures.length, g; i < n; ++i) {
17189 if ((g = gestures[i]).that === that) {
17193 return new Gesture(that, args);
17196 function Gesture(that, args) {
17201 this.extent = extent.apply(that, args);
17204 Gesture.prototype = {
17205 start:
function() {
17206 if (++this.active === 1) {
17207 this.index = gestures.push(
this) - 1;
17208 this.emit(
"start");
17212 zoom:
function(key, transform) {
17213 if (this.mouse && key !==
"mouse") this.mouse[1] = transform.invert(this.mouse[0]);
17214 if (this.touch0 && key !==
"touch") this.touch0[1] = transform.invert(this.touch0[0]);
17215 if (this.touch1 && key !==
"touch") this.touch1[1] = transform.invert(this.touch1[0]);
17216 this.that.__zoom = transform;
17221 if (--this.active === 0) {
17222 gestures.splice(this.index, 1);
17228 emit:
function(type) {
17229 customEvent(
new ZoomEvent(zoom, type, this.that.__zoom), listeners.apply, listeners, [type,
this.that,
this.args]);
17233 function wheeled() {
17234 if (!filter.apply(
this, arguments))
return;
17235 var g = gesture(
this, arguments),
17237 k = Math.max(scaleExtent[0], Math.min(scaleExtent[1], t.k * Math.pow(2, wheelDelta.apply(
this, arguments)))),
17243 if (g.mouse[0][0] !== p[0] || g.mouse[0][1] !== p[1]) {
17244 g.mouse[1] = t.invert(g.mouse[0] = p);
17246 clearTimeout(g.wheel);
17250 else if (t.k === k)
return;
17254 g.mouse = [p, t.invert(p)];
17260 g.wheel = setTimeout(wheelidled, wheelDelay);
17261 g.zoom(
"mouse", constrain(translate(scale(t, k), g.mouse[0], g.mouse[1]), g.extent, translateExtent));
17263 function wheelidled() {
17269 function mousedowned() {
17270 if (touchending || !filter.apply(
this, arguments))
return;
17271 var g = gesture(
this, arguments),
17272 v = select(exports.event.view).on(
"mousemove.zoom", mousemoved,
true).on(
"mouseup.zoom", mouseupped,
true),
17274 x0 = exports.event.clientX,
17275 y0 = exports.event.clientY;
17277 dragDisable(exports.event.view);
17279 g.mouse = [p, this.__zoom.invert(p)];
17283 function mousemoved() {
17286 var dx = exports.event.clientX - x0, dy = exports.event.clientY - y0;
17287 g.moved = dx * dx + dy * dy > clickDistance2;
17289 g.zoom(
"mouse", constrain(translate(g.that.__zoom, g.mouse[0] = mouse(g.that), g.mouse[1]), g.extent, translateExtent));
17292 function mouseupped() {
17293 v.on(
"mousemove.zoom mouseup.zoom", null);
17294 yesdrag(exports.event.view, g.moved);
17300 function dblclicked() {
17301 if (!filter.apply(
this, arguments))
return;
17302 var t0 = this.__zoom,
17304 p1 = t0.invert(p0),
17305 k1 = t0.k * (exports.event.shiftKey ? 0.5 : 2),
17306 t1 = constrain(translate(scale(t0, k1), p0, p1), extent.apply(
this, arguments), translateExtent);
17309 if (duration > 0) select(
this).transition().duration(duration).call(schedule, t1, p0);
17310 else select(
this).call(zoom.transform, t1);
17313 function touchstarted() {
17314 if (!filter.apply(
this, arguments))
return;
17315 var g = gesture(
this, arguments),
17316 touches$$1 = exports.event.changedTouches,
17318 n = touches$$1.length, i, t, p;
17321 for (i = 0; i < n; ++i) {
17322 t = touches$$1[i], p = touch(
this, touches$$1, t.identifier);
17323 p = [p, this.__zoom.invert(p), t.identifier];
17324 if (!g.touch0) g.touch0 = p, started =
true;
17325 else if (!g.touch1) g.touch1 = p;
17329 if (touchstarting) {
17330 touchstarting = clearTimeout(touchstarting);
17333 p = select(
this).on(
"dblclick.zoom");
17334 if (p) p.apply(
this, arguments);
17340 touchstarting = setTimeout(
function() { touchstarting = null; }, touchDelay);
17346 function touchmoved() {
17347 var g = gesture(
this, arguments),
17348 touches$$1 = exports.event.changedTouches,
17349 n = touches$$1.length, i, t, p, l;
17352 if (touchstarting) touchstarting = clearTimeout(touchstarting);
17353 for (i = 0; i < n; ++i) {
17354 t = touches$$1[i], p = touch(
this, touches$$1, t.identifier);
17355 if (g.touch0 && g.touch0[2] === t.identifier) g.touch0[0] = p;
17356 else if (g.touch1 && g.touch1[2] === t.identifier) g.touch1[0] = p;
17360 var p0 = g.touch0[0], l0 = g.touch0[1],
17361 p1 = g.touch1[0], l1 = g.touch1[1],
17362 dp = (dp = p1[0] - p0[0]) * dp + (dp = p1[1] - p0[1]) * dp,
17363 dl = (dl = l1[0] - l0[0]) * dl + (dl = l1[1] - l0[1]) * dl;
17364 t = scale(t, Math.sqrt(dp / dl));
17365 p = [(p0[0] + p1[0]) / 2, (p0[1] + p1[1]) / 2];
17366 l = [(l0[0] + l1[0]) / 2, (l0[1] + l1[1]) / 2];
17368 else if (g.touch0) p = g.touch0[0], l = g.touch0[1];
17370 g.zoom(
"touch", constrain(translate(t, p, l), g.extent, translateExtent));
17373 function touchended() {
17374 var g = gesture(
this, arguments),
17375 touches$$1 = exports.event.changedTouches,
17376 n = touches$$1.length, i, t;
17379 if (touchending) clearTimeout(touchending);
17380 touchending = setTimeout(
function() { touchending = null; }, touchDelay);
17381 for (i = 0; i < n; ++i) {
17383 if (g.touch0 && g.touch0[2] === t.identifier)
delete g.touch0;
17384 else if (g.touch1 && g.touch1[2] === t.identifier)
delete g.touch1;
17386 if (g.touch1 && !g.touch0) g.touch0 = g.touch1,
delete g.touch1;
17387 if (g.touch0) g.touch0[1] = this.__zoom.invert(g.touch0[0]);
17391 zoom.wheelDelta =
function(_) {
17392 return arguments.length ? (wheelDelta = typeof _ ===
"function" ? _ : constant$d(+_), zoom) : wheelDelta;
17395 zoom.filter =
function(_) {
17396 return arguments.length ? (filter = typeof _ ===
"function" ? _ : constant$d(!!_), zoom) : filter;
17399 zoom.touchable =
function(_) {
17400 return arguments.length ? (touchable = typeof _ ===
"function" ? _ : constant$d(!!_), zoom) : touchable;
17403 zoom.extent =
function(_) {
17404 return arguments.length ? (extent = typeof _ ===
"function" ? _ : constant$d([[+_[0][0], +_[0][1]], [+_[1][0], +_[1][1]]]), zoom) : extent;
17407 zoom.scaleExtent =
function(_) {
17408 return arguments.length ? (scaleExtent[0] = +_[0], scaleExtent[1] = +_[1], zoom) : [scaleExtent[0], scaleExtent[1]];
17411 zoom.translateExtent =
function(_) {
17412 return arguments.length ? (translateExtent[0][0] = +_[0][0], translateExtent[1][0] = +_[1][0], translateExtent[0][1] = +_[0][1], translateExtent[1][1] = +_[1][1], zoom) : [[translateExtent[0][0], translateExtent[0][1]], [translateExtent[1][0], translateExtent[1][1]]];
17415 zoom.constrain =
function(_) {
17416 return arguments.length ? (constrain = _, zoom) : constrain;
17419 zoom.duration =
function(_) {
17420 return arguments.length ? (duration = +_, zoom) : duration;
17423 zoom.interpolate =
function(_) {
17424 return arguments.length ? (interpolate = _, zoom) : interpolate;
17427 zoom.on =
function() {
17428 var value = listeners.on.apply(listeners, arguments);
17429 return value === listeners ? zoom : value;
17432 zoom.clickDistance =
function(_) {
17433 return arguments.length ? (clickDistance2 = (_ = +_) * _, zoom) : Math.sqrt(clickDistance2);
17439 exports.version = version;
17440 exports.bisect = bisectRight;
17441 exports.bisectRight = bisectRight;
17442 exports.bisectLeft = bisectLeft;
17443 exports.ascending = ascending;
17444 exports.bisector = bisector;
17445 exports.cross = cross;
17446 exports.descending = descending;
17447 exports.deviation = deviation;
17448 exports.extent = extent;
17449 exports.histogram = histogram;
17450 exports.thresholdFreedmanDiaconis = freedmanDiaconis;
17451 exports.thresholdScott = scott;
17452 exports.thresholdSturges = thresholdSturges;
17454 exports.mean = mean;
17455 exports.median = median;
17456 exports.merge = merge;
17458 exports.pairs = pairs;
17459 exports.permute = permute;
17460 exports.quantile = threshold;
17461 exports.range = sequence;
17462 exports.scan = scan;
17463 exports.shuffle = shuffle;
17465 exports.ticks = ticks;
17466 exports.tickIncrement = tickIncrement;
17467 exports.tickStep = tickStep;
17468 exports.transpose = transpose;
17469 exports.variance = variance;
17471 exports.axisTop = axisTop;
17472 exports.axisRight = axisRight;
17473 exports.axisBottom = axisBottom;
17474 exports.axisLeft = axisLeft;
17475 exports.brush = brush;
17476 exports.brushX = brushX;
17477 exports.brushY = brushY;
17478 exports.brushSelection = brushSelection;
17479 exports.chord = chord;
17480 exports.ribbon = ribbon;
17481 exports.nest = nest;
17482 exports.set = set$2;
17483 exports.map = map$1;
17484 exports.keys = keys;
17485 exports.values = values;
17486 exports.entries = entries;
17487 exports.color = color;
17493 exports.gray = gray;
17494 exports.cubehelix = cubehelix;
17495 exports.contours = contours;
17496 exports.contourDensity = density;
17497 exports.dispatch = dispatch;
17498 exports.drag = drag;
17499 exports.dragDisable = dragDisable;
17500 exports.dragEnable = yesdrag;
17501 exports.dsvFormat = dsvFormat;
17502 exports.csvParse = csvParse;
17503 exports.csvParseRows = csvParseRows;
17504 exports.csvFormat = csvFormat;
17505 exports.csvFormatRows = csvFormatRows;
17506 exports.tsvParse = tsvParse;
17507 exports.tsvParseRows = tsvParseRows;
17508 exports.tsvFormat = tsvFormat;
17509 exports.tsvFormatRows = tsvFormatRows;
17510 exports.easeLinear = linear$1;
17511 exports.easeQuad = quadInOut;
17512 exports.easeQuadIn = quadIn;
17513 exports.easeQuadOut = quadOut;
17514 exports.easeQuadInOut = quadInOut;
17515 exports.easeCubic = cubicInOut;
17516 exports.easeCubicIn = cubicIn;
17517 exports.easeCubicOut = cubicOut;
17518 exports.easeCubicInOut = cubicInOut;
17519 exports.easePoly = polyInOut;
17520 exports.easePolyIn = polyIn;
17521 exports.easePolyOut = polyOut;
17522 exports.easePolyInOut = polyInOut;
17523 exports.easeSin = sinInOut;
17524 exports.easeSinIn = sinIn;
17525 exports.easeSinOut = sinOut;
17526 exports.easeSinInOut = sinInOut;
17527 exports.easeExp = expInOut;
17528 exports.easeExpIn = expIn;
17529 exports.easeExpOut = expOut;
17530 exports.easeExpInOut = expInOut;
17531 exports.easeCircle = circleInOut;
17532 exports.easeCircleIn = circleIn;
17533 exports.easeCircleOut = circleOut;
17534 exports.easeCircleInOut = circleInOut;
17535 exports.easeBounce = bounceOut;
17536 exports.easeBounceIn = bounceIn;
17537 exports.easeBounceOut = bounceOut;
17538 exports.easeBounceInOut = bounceInOut;
17539 exports.easeBack = backInOut;
17540 exports.easeBackIn = backIn;
17541 exports.easeBackOut = backOut;
17542 exports.easeBackInOut = backInOut;
17543 exports.easeElastic = elasticOut;
17544 exports.easeElasticIn = elasticIn;
17545 exports.easeElasticOut = elasticOut;
17546 exports.easeElasticInOut = elasticInOut;
17547 exports.blob = blob;
17548 exports.buffer = buffer;
17550 exports.csv = csv$1;
17551 exports.tsv = tsv$1;
17552 exports.image = image;
17553 exports.json = json;
17554 exports.text = text;
17556 exports.html = html;
17558 exports.forceCenter = center$1;
17559 exports.forceCollide = collide;
17560 exports.forceLink = link;
17561 exports.forceManyBody = manyBody;
17562 exports.forceRadial = radial;
17563 exports.forceSimulation = simulation;
17564 exports.forceX = x$2;
17565 exports.forceY = y$2;
17566 exports.formatDefaultLocale = defaultLocale;
17567 exports.formatLocale = formatLocale;
17568 exports.formatSpecifier = formatSpecifier;
17569 exports.precisionFixed = precisionFixed;
17570 exports.precisionPrefix = precisionPrefix;
17571 exports.precisionRound = precisionRound;
17572 exports.geoArea = area$1;
17573 exports.geoBounds = bounds;
17574 exports.geoCentroid = centroid;
17575 exports.geoCircle = circle;
17576 exports.geoClipAntimeridian = clipAntimeridian;
17577 exports.geoClipCircle = clipCircle;
17578 exports.geoClipExtent = extent$1;
17579 exports.geoClipRectangle = clipRectangle;
17580 exports.geoContains = contains$1;
17581 exports.geoDistance = distance;
17582 exports.geoGraticule = graticule;
17583 exports.geoGraticule10 = graticule10;
17584 exports.geoInterpolate = interpolate$1;
17585 exports.geoLength = length$1;
17586 exports.geoPath = index$1;
17587 exports.geoAlbers = albers;
17588 exports.geoAlbersUsa = albersUsa;
17589 exports.geoAzimuthalEqualArea = azimuthalEqualArea;
17590 exports.geoAzimuthalEqualAreaRaw = azimuthalEqualAreaRaw;
17591 exports.geoAzimuthalEquidistant = azimuthalEquidistant;
17592 exports.geoAzimuthalEquidistantRaw = azimuthalEquidistantRaw;
17593 exports.geoConicConformal = conicConformal;
17594 exports.geoConicConformalRaw = conicConformalRaw;
17595 exports.geoConicEqualArea = conicEqualArea;
17596 exports.geoConicEqualAreaRaw = conicEqualAreaRaw;
17597 exports.geoConicEquidistant = conicEquidistant;
17598 exports.geoConicEquidistantRaw = conicEquidistantRaw;
17599 exports.geoEqualEarth = equalEarth;
17600 exports.geoEqualEarthRaw = equalEarthRaw;
17601 exports.geoEquirectangular = equirectangular;
17602 exports.geoEquirectangularRaw = equirectangularRaw;
17603 exports.geoGnomonic = gnomonic;
17604 exports.geoGnomonicRaw = gnomonicRaw;
17605 exports.geoIdentity = identity$5;
17606 exports.geoProjection = projection;
17607 exports.geoProjectionMutator = projectionMutator;
17608 exports.geoMercator = mercator;
17609 exports.geoMercatorRaw = mercatorRaw;
17610 exports.geoNaturalEarth1 = naturalEarth1;
17611 exports.geoNaturalEarth1Raw = naturalEarth1Raw;
17612 exports.geoOrthographic = orthographic;
17613 exports.geoOrthographicRaw = orthographicRaw;
17614 exports.geoStereographic = stereographic;
17615 exports.geoStereographicRaw = stereographicRaw;
17616 exports.geoTransverseMercator = transverseMercator;
17617 exports.geoTransverseMercatorRaw = transverseMercatorRaw;
17618 exports.geoRotation = rotation;
17619 exports.geoStream = geoStream;
17620 exports.geoTransform = transform;
17621 exports.cluster = cluster;
17622 exports.hierarchy = hierarchy;
17623 exports.pack = index$2;
17624 exports.packSiblings = siblings;
17625 exports.packEnclose = enclose;
17626 exports.partition = partition;
17627 exports.stratify = stratify;
17628 exports.tree = tree;
17629 exports.treemap = index$3;
17630 exports.treemapBinary = binary;
17631 exports.treemapDice = treemapDice;
17632 exports.treemapSlice = treemapSlice;
17633 exports.treemapSliceDice = sliceDice;
17634 exports.treemapSquarify = squarify;
17635 exports.treemapResquarify = resquarify;
17636 exports.interpolate = interpolateValue;
17637 exports.interpolateArray = array$1;
17638 exports.interpolateBasis = basis$1;
17639 exports.interpolateBasisClosed = basisClosed;
17640 exports.interpolateDate = date;
17641 exports.interpolateDiscrete = discrete;
17642 exports.interpolateHue = hue$1;
17643 exports.interpolateNumber = interpolateNumber;
17644 exports.interpolateObject = object;
17645 exports.interpolateRound = interpolateRound;
17646 exports.interpolateString = interpolateString;
17647 exports.interpolateTransformCss = interpolateTransformCss;
17648 exports.interpolateTransformSvg = interpolateTransformSvg;
17649 exports.interpolateZoom = interpolateZoom;
17650 exports.interpolateRgb = interpolateRgb;
17651 exports.interpolateRgbBasis = rgbBasis;
17652 exports.interpolateRgbBasisClosed = rgbBasisClosed;
17653 exports.interpolateHsl = hsl$2;
17654 exports.interpolateHslLong = hslLong;
17655 exports.interpolateLab = lab$1;
17656 exports.interpolateHcl = hcl$2;
17657 exports.interpolateHclLong = hclLong;
17658 exports.interpolateCubehelix = cubehelix$2;
17659 exports.interpolateCubehelixLong = cubehelixLong;
17660 exports.piecewise = piecewise;
17661 exports.quantize = quantize;
17662 exports.path = path;
17663 exports.polygonArea = area$2;
17664 exports.polygonCentroid = centroid$1;
17665 exports.polygonHull = hull;
17666 exports.polygonContains = contains$2;
17667 exports.polygonLength = length$2;
17668 exports.quadtree = quadtree;
17669 exports.randomUniform = uniform;
17670 exports.randomNormal = normal;
17671 exports.randomLogNormal = logNormal;
17672 exports.randomBates = bates;
17673 exports.randomIrwinHall = irwinHall;
17674 exports.randomExponential = exponential$1;
17675 exports.scaleBand = band;
17676 exports.scalePoint = point$1;
17677 exports.scaleIdentity = identity$6;
17678 exports.scaleLinear = linear$2;
17679 exports.scaleLog = log$1;
17680 exports.scaleOrdinal = ordinal;
17681 exports.scaleImplicit = implicit;
17682 exports.scalePow = pow$1;
17683 exports.scaleSqrt = sqrt$1;
17684 exports.scaleQuantile = quantile$$1;
17685 exports.scaleQuantize = quantize$1;
17686 exports.scaleThreshold = threshold$1;
17687 exports.scaleTime = time;
17688 exports.scaleUtc = utcTime;
17689 exports.scaleSequential = sequential;
17690 exports.scaleDiverging = diverging;
17691 exports.schemeCategory10 = category10;
17692 exports.schemeAccent = Accent;
17693 exports.schemeDark2 = Dark2;
17694 exports.schemePaired = Paired;
17695 exports.schemePastel1 = Pastel1;
17696 exports.schemePastel2 = Pastel2;
17697 exports.schemeSet1 = Set1;
17698 exports.schemeSet2 = Set2;
17699 exports.schemeSet3 = Set3;
17700 exports.interpolateBrBG = BrBG;
17701 exports.schemeBrBG = scheme;
17702 exports.interpolatePRGn = PRGn;
17703 exports.schemePRGn = scheme$1;
17704 exports.interpolatePiYG = PiYG;
17705 exports.schemePiYG = scheme$2;
17706 exports.interpolatePuOr = PuOr;
17707 exports.schemePuOr = scheme$3;
17708 exports.interpolateRdBu = RdBu;
17709 exports.schemeRdBu = scheme$4;
17710 exports.interpolateRdGy = RdGy;
17711 exports.schemeRdGy = scheme$5;
17712 exports.interpolateRdYlBu = RdYlBu;
17713 exports.schemeRdYlBu = scheme$6;
17714 exports.interpolateRdYlGn = RdYlGn;
17715 exports.schemeRdYlGn = scheme$7;
17716 exports.interpolateSpectral = Spectral;
17717 exports.schemeSpectral = scheme$8;
17718 exports.interpolateBuGn = BuGn;
17719 exports.schemeBuGn = scheme$9;
17720 exports.interpolateBuPu = BuPu;
17721 exports.schemeBuPu = scheme$a;
17722 exports.interpolateGnBu = GnBu;
17723 exports.schemeGnBu = scheme$b;
17724 exports.interpolateOrRd = OrRd;
17725 exports.schemeOrRd = scheme$c;
17726 exports.interpolatePuBuGn = PuBuGn;
17727 exports.schemePuBuGn = scheme$d;
17728 exports.interpolatePuBu = PuBu;
17729 exports.schemePuBu = scheme$e;
17730 exports.interpolatePuRd = PuRd;
17731 exports.schemePuRd = scheme$f;
17732 exports.interpolateRdPu = RdPu;
17733 exports.schemeRdPu = scheme$g;
17734 exports.interpolateYlGnBu = YlGnBu;
17735 exports.schemeYlGnBu = scheme$h;
17736 exports.interpolateYlGn = YlGn;
17737 exports.schemeYlGn = scheme$i;
17738 exports.interpolateYlOrBr = YlOrBr;
17739 exports.schemeYlOrBr = scheme$j;
17740 exports.interpolateYlOrRd = YlOrRd;
17741 exports.schemeYlOrRd = scheme$k;
17742 exports.interpolateBlues = Blues;
17743 exports.schemeBlues = scheme$l;
17744 exports.interpolateGreens = Greens;
17745 exports.schemeGreens = scheme$m;
17746 exports.interpolateGreys = Greys;
17747 exports.schemeGreys = scheme$n;
17748 exports.interpolatePurples = Purples;
17749 exports.schemePurples = scheme$o;
17750 exports.interpolateReds = Reds;
17751 exports.schemeReds = scheme$p;
17752 exports.interpolateOranges = Oranges;
17753 exports.schemeOranges = scheme$q;
17754 exports.interpolateCubehelixDefault = cubehelix$3;
17755 exports.interpolateRainbow = rainbow;
17756 exports.interpolateWarm = warm;
17757 exports.interpolateCool = cool;
17758 exports.interpolateSinebow = sinebow;
17759 exports.interpolateViridis = viridis;
17760 exports.interpolateMagma = magma;
17761 exports.interpolateInferno = inferno;
17762 exports.interpolatePlasma = plasma;
17763 exports.create = create;
17764 exports.creator = creator;
17765 exports.local = local;
17766 exports.matcher = matcher$1;
17767 exports.mouse = mouse;
17768 exports.namespace =
namespace;
17769 exports.namespaces = namespaces;
17770 exports.clientPoint = point;
17771 exports.select = select;
17772 exports.selectAll = selectAll;
17773 exports.selection = selection;
17774 exports.selector = selector;
17775 exports.selectorAll = selectorAll;
17776 exports.style = styleValue;
17777 exports.touch = touch;
17778 exports.touches = touches;
17779 exports.window = defaultView;
17780 exports.customEvent = customEvent;
17782 exports.area = area$3;
17783 exports.line = line;
17785 exports.areaRadial = areaRadial;
17786 exports.radialArea = areaRadial;
17787 exports.lineRadial = lineRadial$1;
17788 exports.radialLine = lineRadial$1;
17789 exports.pointRadial = pointRadial;
17790 exports.linkHorizontal = linkHorizontal;
17791 exports.linkVertical = linkVertical;
17792 exports.linkRadial = linkRadial;
17793 exports.symbol = symbol;
17794 exports.symbols = symbols;
17795 exports.symbolCircle = circle$2;
17796 exports.symbolCross = cross$2;
17797 exports.symbolDiamond = diamond;
17798 exports.symbolSquare = square;
17799 exports.symbolStar = star;
17800 exports.symbolTriangle = triangle;
17801 exports.symbolWye = wye;
17802 exports.curveBasisClosed = basisClosed$1;
17803 exports.curveBasisOpen = basisOpen;
17804 exports.curveBasis = basis$2;
17805 exports.curveBundle = bundle;
17806 exports.curveCardinalClosed = cardinalClosed;
17807 exports.curveCardinalOpen = cardinalOpen;
17808 exports.curveCardinal = cardinal;
17809 exports.curveCatmullRomClosed = catmullRomClosed;
17810 exports.curveCatmullRomOpen = catmullRomOpen;
17811 exports.curveCatmullRom = catmullRom;
17812 exports.curveLinearClosed = linearClosed;
17813 exports.curveLinear = curveLinear;
17814 exports.curveMonotoneX = monotoneX;
17815 exports.curveMonotoneY = monotoneY;
17816 exports.curveNatural = natural;
17817 exports.curveStep = step;
17818 exports.curveStepAfter = stepAfter;
17819 exports.curveStepBefore = stepBefore;
17820 exports.stack = stack;
17821 exports.stackOffsetExpand = expand;
17822 exports.stackOffsetDiverging = diverging$1;
17823 exports.stackOffsetNone = none$1;
17824 exports.stackOffsetSilhouette = silhouette;
17825 exports.stackOffsetWiggle = wiggle;
17826 exports.stackOrderAscending = ascending$3;
17827 exports.stackOrderDescending = descending$2;
17828 exports.stackOrderInsideOut = insideOut;
17829 exports.stackOrderNone = none$2;
17830 exports.stackOrderReverse = reverse;
17831 exports.timeInterval = newInterval;
17832 exports.timeMillisecond = millisecond;
17833 exports.timeMilliseconds = milliseconds;
17834 exports.utcMillisecond = millisecond;
17835 exports.utcMilliseconds = milliseconds;
17836 exports.timeSecond = second;
17837 exports.timeSeconds = seconds;
17838 exports.utcSecond = second;
17839 exports.utcSeconds = seconds;
17840 exports.timeMinute = minute;
17841 exports.timeMinutes = minutes;
17842 exports.timeHour = hour;
17843 exports.timeHours = hours;
17844 exports.timeDay = day;
17845 exports.timeDays = days;
17846 exports.timeWeek = sunday;
17847 exports.timeWeeks = sundays;
17848 exports.timeSunday = sunday;
17849 exports.timeSundays = sundays;
17850 exports.timeMonday = monday;
17851 exports.timeMondays = mondays;
17852 exports.timeTuesday = tuesday;
17853 exports.timeTuesdays = tuesdays;
17854 exports.timeWednesday = wednesday;
17855 exports.timeWednesdays = wednesdays;
17856 exports.timeThursday = thursday;
17857 exports.timeThursdays = thursdays;
17858 exports.timeFriday = friday;
17859 exports.timeFridays = fridays;
17860 exports.timeSaturday = saturday;
17861 exports.timeSaturdays = saturdays;
17862 exports.timeMonth = month;
17863 exports.timeMonths = months;
17864 exports.timeYear = year;
17865 exports.timeYears = years;
17866 exports.utcMinute = utcMinute;
17867 exports.utcMinutes = utcMinutes;
17868 exports.utcHour = utcHour;
17869 exports.utcHours = utcHours;
17870 exports.utcDay = utcDay;
17871 exports.utcDays = utcDays;
17872 exports.utcWeek = utcSunday;
17873 exports.utcWeeks = utcSundays;
17874 exports.utcSunday = utcSunday;
17875 exports.utcSundays = utcSundays;
17876 exports.utcMonday = utcMonday;
17877 exports.utcMondays = utcMondays;
17878 exports.utcTuesday = utcTuesday;
17879 exports.utcTuesdays = utcTuesdays;
17880 exports.utcWednesday = utcWednesday;
17881 exports.utcWednesdays = utcWednesdays;
17882 exports.utcThursday = utcThursday;
17883 exports.utcThursdays = utcThursdays;
17884 exports.utcFriday = utcFriday;
17885 exports.utcFridays = utcFridays;
17886 exports.utcSaturday = utcSaturday;
17887 exports.utcSaturdays = utcSaturdays;
17888 exports.utcMonth = utcMonth;
17889 exports.utcMonths = utcMonths;
17890 exports.utcYear = utcYear;
17891 exports.utcYears = utcYears;
17892 exports.timeFormatDefaultLocale = defaultLocale$1;
17893 exports.timeFormatLocale = formatLocale$1;
17894 exports.isoFormat = formatIso;
17895 exports.isoParse = parseIso;
17897 exports.timer = timer;
17898 exports.timerFlush = timerFlush;
17899 exports.timeout = timeout$1;
17900 exports.interval = interval$1;
17901 exports.transition = transition;
17902 exports.active = active;
17903 exports.interrupt = interrupt;
17904 exports.voronoi = voronoi;
17905 exports.zoom = zoom;
17906 exports.zoomTransform = transform$1;
17907 exports.zoomIdentity = identity$8;
17909 Object.defineProperty(exports,
'__esModule', { value:
true });