Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

d3-selection

Package Overview
Dependencies
Maintainers
1
Versions
58
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

d3-selection - npm Package Compare versions

Comparing version 0.2.0 to 0.3.0

src/arrayify.js

766

d3-selection.js

@@ -1,59 +0,25 @@

(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.d3 = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
(function (global){
var d3 = module.exports = global.d3 || (global.d3 = {}),
Map = global.Map || (Map = function() {}, Map.prototype = {set: function(k, v) { this["$" + k] = v; return this; }, get: function(k) { return this["$" + k]; }, has: function(k) { return "$" + k in this; }}, Map),
valueOf = function(value) { return function() { return value; }; },
selectorOf = function(selector) { return function() { return this.querySelector(selector); }; },
selectorAllOf = function(selector) { return function() { return this.querySelectorAll(selector); }; },
filterOf = function(selector) { return function() { return this.matches(selector); }; },
filterEvents = new Map,
noop = function() {},
ascending = function(a, b) { return a < b ? -1 : a > b ? 1 : a >= b ? 0 : NaN; },
collapse = function(string) { return string.trim().replace(/\s+/g, " "); },
requote = function(string) { return string.replace(requoteRe, "\\$&"); },
requoteRe = /[\\\^\$\*\+\?\|\[\]\(\)\.\{\}]/g,
bug44083 = global.navigator && /WebKit/.test(global.navigator.userAgent) ? -1 : 0; // https://bugs.webkit.org/show_bug.cgi?id=44083
(function(document) {
if (!document) return;
var element = document.documentElement;
if (!("onmouseenter" in element)) {
filterEvents.set("mouseenter", "mouseover").set("mouseleave", "mouseout");
}
if (!element.matches) {
var vendorMatches = element.webkitMatchesSelector || element.msMatchesSelector || element.mozMatchesSelector || element.oMatchesSelector;
filterOf = function(selector) { return function() { return vendorMatches.call(this, selector); }; };
}
})(global.document);
d3.namespaces = (new Map)
.set("svg", "http://www.w3.org/2000/svg")
.set("xhtml", "http://www.w3.org/1999/xhtml")
.set("xlink", "http://www.w3.org/1999/xlink")
.set("xml", "http://www.w3.org/XML/1998/namespace")
.set("xmlns", "http://www.w3.org/2000/xmlns/");
d3.namespace = function(name) {
var i = name.indexOf(":"), prefix = name;
if (i >= 0) prefix = name.slice(0, i), name = name.slice(i + 1);
return d3.namespaces.has(prefix) ? {space: d3.namespaces.get(prefix), local: name} : name;
};
// When depth = 1, root = [Node, …].
// When depth = 2, root = [[Node, …], …].
// When depth = 3, root = [[[Node, …], …], …]. etc.
// Note that [Node, …] and NodeList are used interchangeably; see arrayify.
function Selection(root, depth) {
this._root = root;
this._depth = depth;
this._enter = this._update = this._exit = null;
if (!this.Map) {
Map = function() {};
Map.prototype = {
set: function(k, v) { this["$" + k] = v; return this; },
get: function(k) { return this["$" + k]; },
has: function(k) { return "$" + k in this; }
};
}
d3.selection = Selection;
(function(global) {
"use strict";
var sourceEvent = function() {
var event = global.d3.event, source;
while (source = event.sourceEvent) event = source;
return event;
};
Selection.prototype = {
var selectorOf = function(selector) {
return function() {
return this.querySelector(selector);
};
};
// The selector may either be a selector string (e.g., ".foo")
// or a function that optionally returns the node to select.
select: function(selector) {
var selection_select = function(selector) {
var depth = this._depth,

@@ -104,8 +70,11 @@ stack = new Array(depth * 2);

return new Selection(visit(this._root, this._update && this._update._root, depth), depth);
},
};
// The selector may either be a selector string (e.g., ".foo")
// or a function that optionally returns an array of nodes to select.
// This is the only operation that increases the depth of a selection.
selectAll: function(selector) {
var selectorAllOf = function(selector) {
return function() {
return this.querySelectorAll(selector);
};
};
var selection_selectAll = function(selector) {
var depth = this._depth,

@@ -151,7 +120,5 @@ stack = new Array(depth * 2);

return new Selection(visit(this._root, depth), depth + 1);
},
};
// The filter may either be a selector string (e.g., ".foo")
// or a function that returns a boolean.
filter: function(filter) {
var selection_filter = function(filter) {
var depth = this._depth,

@@ -199,4 +166,18 @@ stack = new Array(depth * 2);

return new Selection(visit(this._root, depth), depth);
},
};
var filterOf = function(selector) {
return function() {
return this.matches(selector);
};
};
if (global.document) {
var selection_filter__element = document.documentElement;
if (!selection_filter__element.matches) {
var vendorMatches = selection_filter__element.webkitMatchesSelector || selection_filter__element.msMatchesSelector || selection_filter__element.mozMatchesSelector || selection_filter__element.oMatchesSelector;
filterOf = function(selector) { return function() { return vendorMatches.call(this, selector); }; };
}
}
// The value may either be an array or a function that returns an array.

@@ -206,3 +187,3 @@ // An optional key function may be specified to control how data is bound;

// Or, if no arguments are specified, this method returns all bound data.
data: function(value, key) {
var selection_data = function(value, key) {
if (!value) {

@@ -365,88 +346,116 @@ var data = new Array(this.size()), i = -1;

return this;
},
};
// Lazily constructs the enter selection for this (update) selection.
// Until this selection is joined to data, the enter selection will be empty.
enter: function() {
if (this._enter) return this._enter;
function EnterNode(parent, datum) {
this.ownerDocument = parent.ownerDocument;
this.namespaceURI = parent.namespaceURI;
this._next = null;
this._parent = parent;
this.__data__ = datum;
}
function visit(nodes, depth) {
var i = -1,
n = nodes.length,
node,
enter = new Array(n);
EnterNode.prototype = {
appendChild: function(child) { return this._parent.insertBefore(child, this._next); },
insertBefore: function(child, next) { return this._parent.insertBefore(child, next || this._next); }
};
if (--depth) {
while (++i < n) {
if (node = nodes[i]) {
enter[i] = visit(node, depth);
}
function valueOf(value) {
return function() {
return value;
};
}
// The leaf groups of the selection hierarchy are initially NodeList,
// and then lazily converted to arrays when mutation is required.
var arrayify = function(selection) {
return selection._root = arrayifyNode(selection._root, selection._depth);
};
function arrayifyNode(nodes, depth) {
var i = -1,
n = nodes.length,
node;
if (--depth) {
while (++i < n) {
if (node = nodes[i]) {
nodes[i] = arrayifyNode(node, depth);
}
}
}
enter._parent = nodes._parent;
return enter;
else if (!Array.isArray(nodes)) {
var array = new Array(n);
while (++i < n) array[i] = nodes[i];
array._parent = nodes._parent;
nodes = array;
}
this._enter = new Selection(visit(arrayify(this), this._depth), this._depth);
this._enter._update = this;
return this._enter;
},
return nodes;
}
// Lazily constructs the exit selection for this (update) selection.
// Until this selection is joined to data, the exit selection will be empty.
exit: function() {
var emptyOf = function(selection) {
return new Selection(emptyNode(arrayify(selection), selection._depth), selection._depth);
};
function visit(nodes, depth) {
var i = -1,
n = nodes.length,
node,
exit = new Array(n);
function emptyNode(nodes, depth) {
var i = -1,
n = nodes.length,
node,
empty = new Array(n);
if (--depth) {
while (++i < n) {
if (node = nodes[i]) {
exit[i] = visit(node, depth);
}
if (--depth) {
while (++i < n) {
if (node = nodes[i]) {
empty[i] = emptyNode(node, depth);
}
}
}
exit._parent = nodes._parent;
return exit;
empty._parent = nodes._parent;
return empty;
}
var selection_enter = function() {
if (!this._enter) {
this._enter = emptyOf(this);
this._enter._update = this;
}
return this._enter;
};
return this._exit || (this._exit = new Selection(visit(arrayify(this), this._depth), this._depth));
},
var selection_exit = function() {
return this._exit || (this._exit = emptyOf(this));
};
order: function() {
var selection_order = function() {
orderNode(this._root, this._depth);
return this;
};
function visit(nodes, depth) {
var i = nodes.length,
node,
next;
function orderNode(nodes, depth) {
var i = nodes.length,
node,
next;
if (--depth) {
while (--i >= 0) {
if (node = nodes[i]) {
visit(node, depth);
}
if (--depth) {
while (--i >= 0) {
if (node = nodes[i]) {
orderNode(node, depth);
}
}
}
else {
next = nodes[--i];
while (--i >= 0) {
if (node = nodes[i]) {
if (next && next !== node.nextSibling) next.parentNode.insertBefore(node, next);
next = node;
}
else {
next = nodes[--i];
while (--i >= 0) {
if (node = nodes[i]) {
if (next && next !== node.nextSibling) next.parentNode.insertBefore(node, next);
next = node;
}
}
}
}
visit(this._root, this._depth);
return this;
},
sort: function(comparator) {
var selection_sort = function(comparator) {
if (!comparator) comparator = ascending;

@@ -477,56 +486,59 @@

return this.order();
},
};
call: function() {
function ascending(a, b) {
return a < b ? -1 : a > b ? 1 : a >= b ? 0 : NaN;
}
var selection_call = function() {
var callback = arguments[0];
callback.apply(arguments[0] = this, arguments);
return this;
},
};
nodes: function() {
var selection_nodes = function() {
var nodes = new Array(this.size()), i = -1;
this.each(function() { nodes[++i] = this; });
return nodes;
},
};
node: function() {
var selection_node = function() {
return firstNode(this._root, this._depth);
};
function visit(nodes, depth) {
var i = -1,
n = nodes.length,
node;
function firstNode(nodes, depth) {
var i = -1,
n = nodes.length,
node;
if (--depth) {
while (++i < n) {
if (node = nodes[i]) {
if (node = visit(node, depth)) {
return node;
}
if (--depth) {
while (++i < n) {
if (node = nodes[i]) {
if (node = firstNode(node, depth)) {
return node;
}
}
}
}
else {
while (++i < n) {
if (node = nodes[i]) {
return node;
}
else {
while (++i < n) {
if (node = nodes[i]) {
return node;
}
}
}
}
return visit(this._root, this._depth);
},
size: function() {
var selection_size = function() {
var size = 0;
this.each(function() { ++size; });
return size;
},
};
empty: function() {
var selection_empty = function() {
return !this.node();
},
};
each: function(callback) {
var selection_each = function(callback) {
var depth = this._depth,

@@ -563,7 +575,20 @@ stack = new Array(depth);

return this;
},
};
attr: function(name, value) {
name = d3.namespace(name);
var namespaces = (new Map)
.set("svg", "http://www.w3.org/2000/svg")
.set("xhtml", "http://www.w3.org/1999/xhtml")
.set("xlink", "http://www.w3.org/1999/xlink")
.set("xml", "http://www.w3.org/XML/1998/namespace")
.set("xmlns", "http://www.w3.org/2000/xmlns/");
var namespace = function(name) {
var i = name.indexOf(":"), prefix = name;
if (i >= 0) prefix = name.slice(0, i), name = name.slice(i + 1);
return namespaces.has(prefix) ? {space: namespaces.get(prefix), local: name} : name;
};
var selection_attr = function(name, value) {
name = namespace(name);
if (arguments.length < 2) {

@@ -609,8 +634,15 @@ var node = this.node();

: (name.local ? setConstantNS : setConstant)));
},
};
style: function(name, value, priority) {
var defaultView = function(node) {
return node
&& ((node.ownerDocument && node.ownerDocument.defaultView) // node is a Node
|| (node.document && node) // node is a Window
|| node.defaultView); // node is a Document
};
var selection_style = function(name, value, priority) {
var n = arguments.length;
if (n < 2) return windowOf(n = this.node()).getComputedStyle(n, null).getPropertyValue(name);
if (n < 2) return defaultView(n = this.node()).getComputedStyle(n, null).getPropertyValue(name);

@@ -634,5 +666,5 @@ if (n < 3) priority = "";

return this.each(value == null ? remove : typeof value === "function" ? setFunction : setConstant);
},
};
property: function(name, value) {
var selection_property = function(name, value) {
if (arguments.length < 2) return this.node()[name];

@@ -655,5 +687,11 @@

return this.each(value == null ? remove : typeof value === "function" ? setFunction : setConstant);
},
};
class: function(name, value) {
var requoteRe = /[\\\^\$\*\+\?\|\[\]\(\)\.\{\}]/g;
var requote = function(string) {
return string.replace(requoteRe, "\\$&");
};
var selection_class = function(name, value) {
name = (name + "").trim().split(/^|\s+/);

@@ -686,5 +724,24 @@ var n = name.length;

return this.each(typeof value === "function" ? setFunction : setConstant);
},
};
text: function(value) {
function classerOf(name) {
var re;
return function(node, value) {
if (c = node.classList) return value ? c.add(name) : c.remove(name);
if (!re) re = new RegExp("(?:^|\\s+)" + requote(name) + "(?:\\s+|$)", "g");
var c = node.getAttribute("class") || "";
if (value) {
re.lastIndex = 0;
if (!re.test(c)) node.setAttribute("class", collapse(c + " " + name));
} else {
node.setAttribute("class", collapse(c.replace(re, " ")));
}
};
}
function collapse(string) {
return string.trim().replace(/\s+/g, " ");
}
var selection_text = function(value) {
if (!arguments.length) return this.node().textContent;

@@ -704,5 +761,5 @@

return this.each(typeof value === "function" ? setFunction : setConstant);
},
};
html: function(value) {
var selection_html = function(value) {
if (!arguments.length) return this.node().innerHTML;

@@ -722,5 +779,5 @@

return this.each(typeof value === "function" ? setFunction : setConstant);
},
};
append: function(creator, selector) {
var selection_append = function(creator, selector) {
if (typeof creator !== "function") creator = creatorOf(creator);

@@ -739,5 +796,23 @@

: (typeof selector !== "function" && (selector = selectorOf(selector)), insert));
},
};
remove: function() {
function creatorOf(name) {
name = namespace(name);
function creator() {
var document = this.ownerDocument,
uri = this.namespaceURI;
return uri
? document.createElementNS(uri, name)
: document.createElement(name);
}
function creatorNS() {
return this.ownerDocument.createElementNS(name.space, name.local);
}
return name.local ? creatorNS : creator;
}
var selection_remove = function() {
return this.each(function() {

@@ -747,9 +822,18 @@ var parent = this.parentNode;

});
},
};
datum: function(value) {
var selection_datum = function(value) {
return arguments.length ? this.property("__data__", value) : this.node().__data__;
},
};
event: function(type, listener, capture) {
var filterEvents = new Map;
if (global.document) {
var selection_event__element = document.documentElement;
if (!("onmouseenter" in selection_event__element)) {
filterEvents.set("mouseenter", "mouseover").set("mouseleave", "mouseout");
}
}
var selection_event = function(type, listener, capture) {
var n = arguments.length,

@@ -798,6 +882,30 @@ key = "__on" + type,

: (n ? remove : removeAll));
},
};
dispatch: function(type, params) {
function listenerOf(listener, ancestors, args) {
return function(event) {
var i = ancestors.length, event0 = global.d3.event; // Events can be reentrant (e.g., focus).
while (--i >= 0) args[i << 1] = ancestors[i].__data__;
global.d3.event = event;
try {
listener.apply(ancestors[0], args);
} finally {
global.d3.event = event0;
}
};
}
function filterListenerOf(listener) {
return function(event) {
var related = event.relatedTarget;
if (!related || (related !== this && !(related.compareDocumentPosition(this) & 8))) {
listener(event);
}
};
}
function noop() {}
var selection_dispatch = function(type, params) {
function dispatchConstant() {

@@ -812,210 +920,146 @@ return dispatchEvent(this, type, params);

return this.each(typeof params === "function" ? dispatchFunction : dispatchConstant);
}
};
};
// Deprecated aliases for backwards-compatibility with 3.x:
Selection.prototype.on = Selection.prototype.event;
Selection.prototype.insert = Selection.prototype.append;
Selection.prototype.classed = Selection.prototype.class;
function dispatchEvent(node, type, params) {
var window = defaultView(node),
event = window.CustomEvent;
d3.select = function(selector) {
var root;
if (typeof selector === "string") {
var document = global.document;
root = [document.querySelector(selector)];
root._parent = document.documentElement;
} else {
root = [selector];
root._parent = null;
if (event) {
event = new event(type, params);
} else {
event = window.document.createEvent("Event");
if (params) event.initEvent(type, params.bubbles, params.cancelable), event.detail = params.detail;
else event.initEvent(type, false, false);
}
node.dispatchEvent(event);
}
return new Selection(root, 1);
};
d3.selectAll = function(selector) {
var root;
if (typeof selector === "string") {
var document = global.document;
root = document.querySelectorAll(selector);
root._parent = document.documentElement;
} else {
root = selector;
root._parent = null;
function Selection(root, depth) {
this._root = root;
this._depth = depth;
this._enter = this._update = this._exit = null;
}
return new Selection(root, 1);
};
function EnterNode(parent, datum) {
this.ownerDocument = parent.ownerDocument;
this.namespaceURI = parent.namespaceURI;
this._next = null;
this._parent = parent;
this.__data__ = datum;
}
Selection.prototype = {
select: selection_select,
selectAll: selection_selectAll,
filter: selection_filter,
data: selection_data,
enter: selection_enter,
exit: selection_exit,
order: selection_order,
sort: selection_sort,
call: selection_call,
nodes: selection_nodes,
node: selection_node,
size: selection_size,
empty: selection_empty,
each: selection_each,
attr: selection_attr,
style: selection_style,
property: selection_property,
class: selection_class,
classed: selection_class, // deprecated alias
text: selection_text,
html: selection_html,
append: selection_append,
insert: selection_append, // deprecated alias
remove: selection_remove,
datum: selection_datum,
event: selection_event,
on: selection_event, // deprecated alias
dispatch: selection_dispatch
};
EnterNode.prototype = {
appendChild: function(child) { return this._parent.insertBefore(child, this._next); },
insertBefore: function(child, next) { return this._parent.insertBefore(child, next || this._next); }
};
var select = function(selector) {
var root;
if (typeof selector === "string") {
root = [document.querySelector(selector)];
root._parent = document.documentElement;
} else {
root = [selector];
root._parent = null;
}
return new Selection(root, 1);
};
// The leaf groups of the selection hierarchy are initially NodeList,
// and then lazily converted to arrays when mutation is required.
function arrayify(selection) {
var bug44083 = global.navigator && /WebKit/.test(global.navigator.userAgent) ? -1 : 0; // https://bugs.webkit.org/show_bug.cgi?id=44083
function visit(nodes, depth) {
var i = -1,
n = nodes.length,
node;
if (--depth) {
while (++i < n) {
if (node = nodes[i]) {
nodes[i] = visit(node, depth);
var src_point = function(node, event) {
var svg = node.ownerSVGElement || node;
if (svg.createSVGPoint) {
var point = svg.createSVGPoint();
if (bug44083 < 0) {
var window = defaultView(node);
if (window.scrollX || window.scrollY) {
svg = select(window.document.body).append("svg").style({position: "absolute", top: 0, left: 0, margin: 0, padding: 0, border: "none"}, "important");
var ctm = svg.node().getScreenCTM();
bug44083 = !(ctm.f || ctm.e);
svg.remove();
}
}
if (bug44083) point.x = event.pageX, point.y = event.pageY;
else point.x = event.clientX, point.y = event.clientY;
point = point.matrixTransform(node.getScreenCTM().inverse());
return [point.x, point.y];
}
var rect = node.getBoundingClientRect();
return [event.clientX - rect.left - node.clientLeft, event.clientY - rect.top - node.clientTop];
};
else if (!Array.isArray(nodes)) {
var array = new Array(n);
while (++i < n) array[i] = nodes[i];
array._parent = nodes._parent;
nodes = array;
}
var mouse = function(node, event) {
if (arguments.length < 2) event = sourceEvent();
if (event.changedTouches) event = event.changedTouches[0];
return src_point(node, event);
};
return nodes;
}
return selection._root = visit(selection._root, selection._depth);
}
function creatorOf(name) {
name = d3.namespace(name);
function creator() {
var document = this.ownerDocument,
uri = this.namespaceURI;
return uri
? document.createElementNS(uri, name)
: document.createElement(name);
}
function creatorNS() {
return this.ownerDocument.createElementNS(name.space, name.local);
}
return name.local ? creatorNS : creator;
}
function windowOf(node) {
return node
&& ((node.ownerDocument && node.ownerDocument.defaultView) // node is a Node
|| (node.document && node) // node is a Window
|| node.defaultView); // node is a Document
}
function dispatchEvent(node, type, params) {
var window = windowOf(node),
event = window.CustomEvent;
if (event) {
event = new event(type, params);
} else {
event = window.document.createEvent("Event");
if (params) event.initEvent(type, params.bubbles, params.cancelable), event.detail = params.detail;
else event.initEvent(type, false, false);
}
node.dispatchEvent(event);
}
function classerOf(name) {
var re;
return function(node, value) {
if (c = node.classList) return value ? c.add(name) : c.remove(name);
if (!re) re = new RegExp("(?:^|\\s+)" + requote(name) + "(?:\\s+|$)", "g");
var c = node.getAttribute("class") || "";
if (value) {
re.lastIndex = 0;
if (!re.test(c)) node.setAttribute("class", collapse(c + " " + name));
var selectAll = function(selector) {
var root;
if (typeof selector === "string") {
root = document.querySelectorAll(selector);
root._parent = document.documentElement;
} else {
node.setAttribute("class", collapse(c.replace(re, " ")));
root = selector;
root._parent = null;
}
return new Selection(root, 1);
};
}
function listenerOf(listener, ancestors, args) {
return function(event) {
var i = ancestors.length, event0 = d3.event; // Events can be reentrant (e.g., focus).
while (--i >= 0) args[i << 1] = ancestors[i].__data__;
d3.event = event;
try {
listener.apply(ancestors[0], args);
} finally {
d3.event = event0;
var src_touch = function(node, touches, identifier) {
if (arguments.length < 3) identifier = touches, touches = sourceEvent().changedTouches;
for (var i = 0, n = touches ? touches.length : 0, touch; i < n; ++i) {
if ((touch = touches[i]).identifier === identifier) {
return src_point(node, touch);
}
}
return null;
};
}
function filterListenerOf(listener) {
return function(event) {
var related = event.relatedTarget;
if (!related || (related !== this && !(related.compareDocumentPosition(this) & 8))) {
listener(event);
var src_touches = function(node, touches) {
if (arguments.length < 2) touches = sourceEvent().touches;
for (var i = 0, n = touches ? touches.length : 0, points = new Array(n); i < n; ++i) {
points[i] = src_point(node, touches[i]);
}
return points;
};
}
function point(node, event) {
var svg = node.ownerSVGElement || node;
if (svg.createSVGPoint) {
var point = svg.createSVGPoint();
if (bug44083 < 0) {
var window = windowOf(node);
if (window.scrollX || window.scrollY) {
svg = d3.select(window.document.body).append("svg").style({position: "absolute", top: 0, left: 0, margin: 0, padding: 0, border: "none"}, "important");
var ctm = svg.node().getScreenCTM();
bug44083 = !(ctm.f || ctm.e);
svg.remove();
}
}
if (bug44083) point.x = event.pageX, point.y = event.pageY;
else point.x = event.clientX, point.y = event.clientY;
point = point.matrixTransform(node.getScreenCTM().inverse());
return [point.x, point.y];
}
var rect = node.getBoundingClientRect();
return [event.clientX - rect.left - node.clientLeft, event.clientY - rect.top - node.clientTop];
}
var index = {
mouse: mouse,
namespace: namespace,
namespaces: namespaces,
requote: requote,
select: select,
selectAll: selectAll,
selection: Selection,
touch: src_touch,
touches: src_touches
};
function source() {
var event = d3.event, source;
while (source = event.sourceEvent) event = source;
return event;
}
var d3 = global.d3;
if (d3) for (var field in index) d3[field] = index[field];
else global.d3 = d3 = index;
if (typeof define === "function" && define.amd) define(d3);
else if (typeof module === "object" && module.exports) module.exports = d3;
d3.mouse = function(node, event) {
if (arguments.length < 2) event = source();
if (event.changedTouches) event = event.changedTouches[0];
return point(node, event);
};
d3.touch = function(node, touches, identifier) {
if (arguments.length < 3) identifier = touches, touches = source().changedTouches;
for (var i = 0, n = touches ? touches.length : 0, touch; i < n; ++i) {
if ((touch = touches[i]).identifier === identifier) {
return point(node, touch);
}
}
return null;
};
d3.touches = function(node, touches) {
if (arguments.length < 2) touches = source().touches;
for (var i = 0, n = touches ? touches.length : 0, points = new Array(n); i < n; ++i) {
points[i] = point(node, touches[i]);
}
return points;
};
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
},{}]},{},[1])(1)
});
})(this);

@@ -1,1 +0,1 @@

!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var e;e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,e.d3=t()}}(function(){return function t(e,n,r){function i(a,u){if(!n[a]){if(!e[a]){var s="function"==typeof require&&require;if(!u&&s)return s(a,!0);if(o)return o(a,!0);var c=new Error("Cannot find module '"+a+"'");throw c.code="MODULE_NOT_FOUND",c}var l=n[a]={exports:{}};e[a][0].call(l.exports,function(t){var n=e[a][1][t];return i(n?n:t)},l,l.exports,t,e,n,r)}return n[a].exports}for(var o="function"==typeof require&&require,a=0;a<r.length;a++)i(r[a]);return i}({1:[function(t,e,n){(function(t){function n(t,e){this._root=t,this._depth=e,this._enter=this._update=this._exit=null}function r(t,e){this.ownerDocument=t.ownerDocument,this.namespaceURI=t.namespaceURI,this._next=null,this._parent=t,this.__data__=e}function i(t){function e(t,n){var r,i=-1,o=t.length;if(--n)for(;++i<o;)(r=t[i])&&(t[i]=e(r,n));else if(!Array.isArray(t)){for(var a=new Array(o);++i<o;)a[i]=t[i];a._parent=t._parent,t=a}return t}return t._root=e(t._root,t._depth)}function o(t){function e(){var e=this.ownerDocument,n=this.namespaceURI;return n?e.createElementNS(n,t):e.createElement(t)}function n(){return this.ownerDocument.createElementNS(t.space,t.local)}return t=p.namespace(t),t.local?n:e}function a(t){return t&&(t.ownerDocument&&t.ownerDocument.defaultView||t.document&&t||t.defaultView)}function u(t,e,n){var r=a(t),i=r.CustomEvent;i?i=new i(e,n):(i=r.document.createEvent("Event"),n?(i.initEvent(e,n.bubbles,n.cancelable),i.detail=n.detail):i.initEvent(e,!1,!1)),t.dispatchEvent(i)}function s(t){var e;return function(n,r){if(i=n.classList)return r?i.add(t):i.remove(t);e||(e=new RegExp("(?:^|\\s+)"+b(t)+"(?:\\s+|$)","g"));var i=n.getAttribute("class")||"";r?(e.lastIndex=0,e.test(i)||n.setAttribute("class",A(i+" "+t))):n.setAttribute("class",A(i.replace(e," ")))}}function c(t,e,n){return function(r){for(var i=e.length,o=p.event;--i>=0;)n[i<<1]=e[i].__data__;p.event=r;try{t.apply(e[0],n)}finally{p.event=o}}}function l(t){return function(e){var n=e.relatedTarget;n&&(n===this||8&n.compareDocumentPosition(this))||t(e)}}function f(t,e){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var r=n.createSVGPoint();if(0>E){var i=a(t);if(i.scrollX||i.scrollY){n=p.select(i.document.body).append("svg").style({position:"absolute",top:0,left:0,margin:0,padding:0,border:"none"},"important");var o=n.node().getScreenCTM();E=!(o.f||o.e),n.remove()}}return E?(r.x=e.pageX,r.y=e.pageY):(r.x=e.clientX,r.y=e.clientY),r=r.matrixTransform(t.getScreenCTM().inverse()),[r.x,r.y]}var u=t.getBoundingClientRect();return[e.clientX-u.left-t.clientLeft,e.clientY-u.top-t.clientTop]}function h(){for(var t,e=p.event;t=e.sourceEvent;)e=t;return e}var p=e.exports=t.d3||(t.d3={}),_=t.Map||(_=function(){},_.prototype={set:function(t,e){return this["$"+t]=e,this},get:function(t){return this["$"+t]},has:function(t){return"$"+t in this}},_),d=function(t){return function(){return t}},g=function(t){return function(){return this.querySelector(t)}},v=function(t){return function(){return this.querySelectorAll(t)}},m=function(t){return function(){return this.matches(t)}},y=new _,w=function(){},x=function(t,e){return e>t?-1:t>e?1:t>=e?0:NaN},A=function(t){return t.trim().replace(/\s+/g," ")},b=function(t){return t.replace(S,"\\$&")},S=/[\\\^\$\*\+\?\|\[\]\(\)\.\{\}]/g,E=t.navigator&&/WebKit/.test(t.navigator.userAgent)?-1:0;!function(t){if(t){var e=t.documentElement;if("onmouseenter"in e||y.set("mouseenter","mouseover").set("mouseleave","mouseout"),!e.matches){var n=e.webkitMatchesSelector||e.msMatchesSelector||e.mozMatchesSelector||e.oMatchesSelector;m=function(t){return function(){return n.call(this,t)}}}}}(t.document),p.namespaces=(new _).set("svg","http://www.w3.org/2000/svg").set("xhtml","http://www.w3.org/1999/xhtml").set("xlink","http://www.w3.org/1999/xlink").set("xml","http://www.w3.org/XML/1998/namespace").set("xmlns","http://www.w3.org/2000/xmlns/"),p.namespace=function(t){var e=t.indexOf(":"),n=t;return e>=0&&(n=t.slice(0,e),t=t.slice(e+1)),p.namespaces.has(n)?{space:p.namespaces.get(n),local:t}:t},p.selection=n,n.prototype={select:function(t){function e(n,r,o){var a,u,s=-1,c=n.length,l=new Array(c);if(--o)for(var f=2*o,h=f+1;++s<c;)(a=n[s])&&(i[f]=a._parent.__data__,i[h]=s,l[s]=e(a,r&&r[s],o));else for(;++s<c;)(a=n[s])&&(i[0]=a.__data__,i[1]=s,(u=t.apply(a,i))&&("__data__"in a&&(u.__data__=a.__data__),r&&(r[s]=u,delete n[s]),l[s]=u));return l._parent=n._parent,l}var r=this._depth,i=new Array(2*r);return"function"!=typeof t&&(t=g(t)),new n(e(this._root,this._update&&this._update._root,r),r)},selectAll:function(t){function e(n,r){var o,a,u=-1,s=n.length,c=new Array(s);if(--r)for(var l=2*r,f=l+1;++u<s;)(o=n[u])&&(i[l]=o._parent.__data__,i[f]=u,c[u]=e(o,r));else for(;++u<s;)(o=n[u])&&(i[0]=o.__data__,i[1]=u,c[u]=a=t.apply(o,i),a._parent=o);return c._parent=n._parent,c}var r=this._depth,i=new Array(2*r);return"function"!=typeof t&&(t=v(t)),new n(e(this._root,r),r+1)},filter:function(t){function e(n,r){var o,a,u=-1,s=n.length;if(--r){var c=2*r,l=c+1;for(a=new Array(s);++u<s;)(o=n[u])&&(i[c]=o._parent.__data__,i[l]=u,a[u]=e(o,r))}else for(a=[];++u<s;)(o=n[u])&&(i[0]=o.__data__,i[1]=u,t.apply(o,i)&&a.push(o));return a._parent=n._parent,a}var r=this._depth,i=new Array(2*r);return"function"!=typeof t&&(t=m(t)),new n(e(this._root,r),r)},data:function(t,e){function n(e,r,i,o){var a,u,s=-1;if(o--){var f=2*o,h=f+1;for(a=e.length;++s<a;)(u=e[s])&&(c[f]=u._parent.__data__,c[h]=s,n(u,r[s],i[s],o))}else{var p,_=0;for(l(e,r,i,t.apply(e._parent,c)),a=e.length;++s<a;)if(p=r[s]){for(s>=_&&(_=s+1);!(u=e[_])&&++_<a;);p._next=u||null}}}function i(t,e,n,i){var o,a=0,u=t.length,s=i.length,c=Math.min(u,s);for(e.length=0,e.length=s,n.length=0,n.length=u;c>a;++a)(o=t[a])?o.__data__=i[a]:e[a]=new r(t._parent,i[a]);for(;s>a;++a)e[a]=new r(t._parent,i[a]);for(;u>a;++a)(o=t[a])&&(n[a]=t[a]);t.length=s}function o(t,n,i,o){var a,u,s,l=o.length,f=t.length,h=new _,p=[null,null].concat(c),d=new Array(f);for(n.length=0,n.length=l,i.length=0,i.length=f,a=0;f>a;++a)(u=t[a])&&(p[0]=u.__data__,p[1]=a,d[a]=s=e.apply(u,p),h.has(s)?i[a]=u:h.set(s,u));for(t.length=0,t.length=l,a=0;l>a;++a)p[0]=o[a],p[1]=a,s=e.apply(t._parent,p),(u=h.get(s))?u!==!0&&(t[a]=u,u.__data__=o[a]):n[a]=new r(t._parent,o[a]),h.set(s,!0);for(a=0;f>a;++a)(u=h.get(d[a]))!==!0&&(i[a]=u)}if(!t){var a=new Array(this.size()),u=-1;return this.each(function(t){a[++u]=t}),a}var s=this._depth-1,c=new Array(2*s),l=e?o:i;return"function"!=typeof t&&(t=d(t)),n(this._root,this.enter()._root,this.exit()._root,s),this},enter:function(){function t(e,n){var r,i=-1,o=e.length,a=new Array(o);if(--n)for(;++i<o;)(r=e[i])&&(a[i]=t(r,n));return a._parent=e._parent,a}return this._enter?this._enter:(this._enter=new n(t(i(this),this._depth),this._depth),this._enter._update=this,this._enter)},exit:function(){function t(e,n){var r,i=-1,o=e.length,a=new Array(o);if(--n)for(;++i<o;)(r=e[i])&&(a[i]=t(r,n));return a._parent=e._parent,a}return this._exit||(this._exit=new n(t(i(this),this._depth),this._depth))},order:function(){function t(e,n){var r,i,o=e.length;if(--n)for(;--o>=0;)(r=e[o])&&t(r,n);else for(i=e[--o];--o>=0;)(r=e[o])&&(i&&i!==r.nextSibling&&i.parentNode.insertBefore(r,i),i=r)}return t(this._root,this._depth),this},sort:function(t){function e(e,n){return e&&n?t(e.__data__,n.__data__):!e-!n}function n(t,r){if(--r)for(var i,o=-1,a=t.length;++o<a;)(i=t[o])&&n(i,r);else t.sort(e)}return t||(t=x),n(i(this),this._depth),this.order()},call:function(){var t=arguments[0];return t.apply(arguments[0]=this,arguments),this},nodes:function(){var t=new Array(this.size()),e=-1;return this.each(function(){t[++e]=this}),t},node:function(){function t(e,n){var r,i=-1,o=e.length;if(--n){for(;++i<o;)if((r=e[i])&&(r=t(r,n)))return r}else for(;++i<o;)if(r=e[i])return r}return t(this._root,this._depth)},size:function(){var t=0;return this.each(function(){++t}),t},empty:function(){return!this.node()},each:function(t){function e(n,i){var o,a=-1,u=n.length;if(--i)for(var s=2*i,c=s+1;++a<u;)(o=n[a])&&(r[s]=o._parent.__data__,r[c]=a,e(o,i));else for(;++a<u;)(o=n[a])&&(r[0]=o.__data__,r[1]=a,t.apply(o,r))}var n=this._depth,r=new Array(n);return e(this._root,n),this},attr:function(t,e){function n(){this.removeAttribute(t)}function r(){this.removeAttributeNS(t.space,t.local)}function i(){this.setAttribute(t,e)}function o(){this.setAttributeNS(t.space,t.local,e)}function a(){var n=e.apply(this,arguments);null==n?this.removeAttribute(t):this.setAttribute(t,n)}function u(){var n=e.apply(this,arguments);null==n?this.removeAttributeNS(t.space,t.local):this.setAttributeNS(t.space,t.local,n)}if(t=p.namespace(t),arguments.length<2){var s=this.node();return t.local?s.getAttributeNS(t.space,t.local):s.getAttribute(t)}return this.each(null==e?t.local?r:n:"function"==typeof e?t.local?u:a:t.local?o:i)},style:function(t,e,n){function r(){this.style.removeProperty(t)}function i(){this.style.setProperty(t,e,n)}function o(){var r=e.apply(this,arguments);null==r?this.style.removeProperty(t):this.style.setProperty(t,r,n)}var u=arguments.length;return 2>u?a(u=this.node()).getComputedStyle(u,null).getPropertyValue(t):(3>u&&(n=""),this.each(null==e?r:"function"==typeof e?o:i))},property:function(t,e){function n(){delete this[t]}function r(){this[t]=e}function i(){var n=e.apply(this,arguments);null==n?delete this[t]:this[t]=n}return arguments.length<2?this.node()[t]:this.each(null==e?n:"function"==typeof e?i:r)},"class":function(t,e){function n(){for(var n=-1;++n<i;)t[n](this,e)}function r(){for(var n=-1,r=e.apply(this,arguments);++n<i;)t[n](this,r)}t=(t+"").trim().split(/^|\s+/);var i=t.length;if(arguments.length<2){var o=this.node(),a=-1;if(e=o.classList){for(;++a<i;)if(!e.contains(t[a]))return!1}else for(e=o.getAttribute("class");++a<i;)if(!classedRe(t[a]).test(e))return!1;return!0}return t=t.map(s),this.each("function"==typeof e?r:n)},text:function(t){function e(){this.textContent=t}function n(){var e=t.apply(this,arguments);this.textContent=null==e?"":e}return arguments.length?(null==t&&(t=""),this.each("function"==typeof t?n:e)):this.node().textContent},html:function(t){function e(){this.innerHTML=t}function n(){var e=t.apply(this,arguments);this.innerHTML=null==e?"":e}return arguments.length?(null==t&&(t=""),this.each("function"==typeof t?n:e)):this.node().innerHTML},append:function(t,e){function n(){return this.appendChild(t.apply(this,arguments))}function r(){return this.insertBefore(t.apply(this,arguments),e.apply(this,arguments)||null)}return"function"!=typeof t&&(t=o(t)),this.select(arguments.length<2?n:("function"!=typeof e&&(e=g(e)),r))},remove:function(){return this.each(function(){var t=this.parentNode;t&&t.removeChild(this)})},datum:function(t){return arguments.length?this.property("__data__",t):this.node().__data__},event:function(t,e,n){function r(){for(var r=f,o=arguments.length>>1,u=new Array(o);--o>=0;)r=r[arguments[(o<<1)+1]],u[o]=o?r._parent:r;var h=c(e,u,arguments);a&&(h=l(h)),i.call(this),this.addEventListener(t,this[s]=h,h._capture=n),h._listener=e}function i(){var e=this[s];e&&(this.removeEventListener(t,e,e._capture),delete this[s])}function o(){var e,n=new RegExp("^__on([^.]+)"+b(t)+"$");for(var r in this)if(e=r.match(n)){var i=this[r];this.removeEventListener(e[1],i,i._capture),delete this[r]}}var a,u=arguments.length,s="__on"+t,f=this._root;return 2>u?(u=this.node()[s])&&u._listener:(3>u&&(n=!1),(u=t.indexOf("."))>0&&(t=t.slice(0,u)),(a=y.has(t))&&(t=y.get(t)),this.each(e?u?r:w:u?i:o))},dispatch:function(t,e){function n(){return u(this,t,e)}function r(){return u(this,t,e.apply(this,arguments))}return this.each("function"==typeof e?r:n)}},n.prototype.on=n.prototype.event,n.prototype.insert=n.prototype.append,n.prototype.classed=n.prototype["class"],p.select=function(e){var r;if("string"==typeof e){var i=t.document;r=[i.querySelector(e)],r._parent=i.documentElement}else r=[e],r._parent=null;return new n(r,1)},p.selectAll=function(e){var r;if("string"==typeof e){var i=t.document;r=i.querySelectorAll(e),r._parent=i.documentElement}else r=e,r._parent=null;return new n(r,1)},r.prototype={appendChild:function(t){return this._parent.insertBefore(t,this._next)},insertBefore:function(t,e){return this._parent.insertBefore(t,e||this._next)}},p.mouse=function(t,e){return arguments.length<2&&(e=h()),e.changedTouches&&(e=e.changedTouches[0]),f(t,e)},p.touch=function(t,e,n){arguments.length<3&&(n=e,e=h().changedTouches);for(var r,i=0,o=e?e.length:0;o>i;++i)if((r=e[i]).identifier===n)return f(t,r);return null},p.touches=function(t,e){arguments.length<2&&(e=h().touches);for(var n=0,r=e?e.length:0,i=new Array(r);r>n;++n)i[n]=f(t,e[n]);return i}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}]},{},[1])(1)});
this.Map||(Map=function(){},Map.prototype={set:function(t,e){return this["$"+t]=e,this},get:function(t){return this["$"+t]},has:function(t){return"$"+t in this}}),function(t){"use strict";function e(t,e){this.ownerDocument=t.ownerDocument,this.namespaceURI=t.namespaceURI,this._next=null,this._parent=t,this.__data__=e}function n(t){return function(){return t}}function r(t,e){var n,i=-1,o=t.length;if(--e)for(;++i<o;)(n=t[i])&&(t[i]=r(n,e));else if(!Array.isArray(t)){for(var a=new Array(o);++i<o;)a[i]=t[i];a._parent=t._parent,t=a}return t}function i(t,e){var n,r=-1,o=t.length,a=new Array(o);if(--e)for(;++r<o;)(n=t[r])&&(a[r]=i(n,e));return a._parent=t._parent,a}function o(t,e){var n,r,i=t.length;if(--e)for(;--i>=0;)(n=t[i])&&o(n,e);else for(r=t[--i];--i>=0;)(n=t[i])&&(r&&r!==n.nextSibling&&r.parentNode.insertBefore(n,r),r=n)}function a(t,e){return e>t?-1:t>e?1:t>=e?0:NaN}function u(t,e){var n,r=-1,i=t.length;if(--e){for(;++r<i;)if((n=t[r])&&(n=u(n,e)))return n}else for(;++r<i;)if(n=t[r])return n}function s(t){var e;return function(n,r){if(i=n.classList)return r?i.add(t):i.remove(t);e||(e=new RegExp("(?:^|\\s+)"+U(t)+"(?:\\s+|$)","g"));var i=n.getAttribute("class")||"";r?(e.lastIndex=0,e.test(i)||n.setAttribute("class",c(i+" "+t))):n.setAttribute("class",c(i.replace(e," ")))}}function c(t){return t.trim().replace(/\s+/g," ")}function l(t){function e(){var e=this.ownerDocument,n=this.namespaceURI;return n?e.createElementNS(n,t):e.createElement(t)}function n(){return this.ownerDocument.createElementNS(t.space,t.local)}return t=z(t),t.local?n:e}function h(e,n,r){return function(i){for(var o=n.length,a=t.d3.event;--o>=0;)r[o<<1]=n[o].__data__;t.d3.event=i;try{e.apply(n[0],r)}finally{t.d3.event=a}}}function f(t){return function(e){var n=e.relatedTarget;n&&(n===this||8&n.compareDocumentPosition(this))||t(e)}}function p(){}function _(t,e,n){var r=Y(t),i=r.CustomEvent;i?i=new i(e,n):(i=r.document.createEvent("Event"),n?(i.initEvent(e,n.bubbles,n.cancelable),i.detail=n.detail):i.initEvent(e,!1,!1)),t.dispatchEvent(i)}function d(t,e){this._root=t,this._depth=e,this._enter=this._update=this._exit=null}var g=function(){for(var e,n=t.d3.event;e=n.sourceEvent;)n=e;return n},m=function(t){return function(){return this.querySelector(t)}},v=function(t){function e(n,i,o){var a,u,s=-1,c=n.length,l=new Array(c);if(--o)for(var h=2*o,f=h+1;++s<c;)(a=n[s])&&(r[h]=a._parent.__data__,r[f]=s,l[s]=e(a,i&&i[s],o));else for(;++s<c;)(a=n[s])&&(r[0]=a.__data__,r[1]=s,(u=t.apply(a,r))&&("__data__"in a&&(u.__data__=a.__data__),i&&(i[s]=u,delete n[s]),l[s]=u));return l._parent=n._parent,l}var n=this._depth,r=new Array(2*n);return"function"!=typeof t&&(t=m(t)),new d(e(this._root,this._update&&this._update._root,n),n)},y=function(t){return function(){return this.querySelectorAll(t)}},w=function(t){function e(n,i){var o,a,u=-1,s=n.length,c=new Array(s);if(--i)for(var l=2*i,h=l+1;++u<s;)(o=n[u])&&(r[l]=o._parent.__data__,r[h]=u,c[u]=e(o,i));else for(;++u<s;)(o=n[u])&&(r[0]=o.__data__,r[1]=u,c[u]=a=t.apply(o,r),a._parent=o);return c._parent=n._parent,c}var n=this._depth,r=new Array(2*n);return"function"!=typeof t&&(t=y(t)),new d(e(this._root,n),n+1)},A=function(t){function e(n,i){var o,a,u=-1,s=n.length;if(--i){var c=2*i,l=c+1;for(a=new Array(s);++u<s;)(o=n[u])&&(r[c]=o._parent.__data__,r[l]=u,a[u]=e(o,i))}else for(a=[];++u<s;)(o=n[u])&&(r[0]=o.__data__,r[1]=u,t.apply(o,r)&&a.push(o));return a._parent=n._parent,a}var n=this._depth,r=new Array(2*n);return"function"!=typeof t&&(t=x(t)),new d(e(this._root,n),n)},x=function(t){return function(){return this.matches(t)}};if(t.document){var b=document.documentElement;if(!b.matches){var S=b.webkitMatchesSelector||b.msMatchesSelector||b.mozMatchesSelector||b.oMatchesSelector;x=function(t){return function(){return S.call(this,t)}}}}var E=function(t,r){function i(e,n,r,o){var a,u,s=-1;if(o--){var c=2*o,f=c+1;for(a=e.length;++s<a;)(u=e[s])&&(l[c]=u._parent.__data__,l[f]=s,i(u,n[s],r[s],o))}else{var p,_=0;for(h(e,n,r,t.apply(e._parent,l)),a=e.length;++s<a;)if(p=n[s]){for(s>=_&&(_=s+1);!(u=e[_])&&++_<a;);p._next=u||null}}}function o(t,n,r,i){var o,a=0,u=t.length,s=i.length,c=Math.min(u,s);for(n.length=0,n.length=s,r.length=0,r.length=u;c>a;++a)(o=t[a])?o.__data__=i[a]:n[a]=new e(t._parent,i[a]);for(;s>a;++a)n[a]=new e(t._parent,i[a]);for(;u>a;++a)(o=t[a])&&(r[a]=t[a]);t.length=s}function a(t,n,i,o){var a,u,s,c=o.length,h=t.length,f=new Map,p=[null,null].concat(l),_=new Array(h);for(n.length=0,n.length=c,i.length=0,i.length=h,a=0;h>a;++a)(u=t[a])&&(p[0]=u.__data__,p[1]=a,_[a]=s=r.apply(u,p),f.has(s)?i[a]=u:f.set(s,u));for(t.length=0,t.length=c,a=0;c>a;++a)p[0]=o[a],p[1]=a,s=r.apply(t._parent,p),(u=f.get(s))?u!==!0&&(t[a]=u,u.__data__=o[a]):n[a]=new e(t._parent,o[a]),f.set(s,!0);for(a=0;h>a;++a)(u=f.get(_[a]))!==!0&&(i[a]=u)}if(!t){var u=new Array(this.size()),s=-1;return this.each(function(t){u[++s]=t}),u}var c=this._depth-1,l=new Array(2*c),h=r?a:o;return"function"!=typeof t&&(t=n(t)),i(this._root,this.enter()._root,this.exit()._root,c),this};e.prototype={appendChild:function(t){return this._parent.insertBefore(t,this._next)},insertBefore:function(t,e){return this._parent.insertBefore(t,e||this._next)}};var M=function(t){return t._root=r(t._root,t._depth)},C=function(t){return new d(i(M(t),t._depth),t._depth)},N=function(){return this._enter||(this._enter=C(this),this._enter._update=this),this._enter},T=function(){return this._exit||(this._exit=C(this))},L=function(){return o(this._root,this._depth),this},P=function(t){function e(e,n){return e&&n?t(e.__data__,n.__data__):!e-!n}function n(t,r){if(--r)for(var i,o=-1,a=t.length;++o<a;)(i=t[o])&&n(i,r);else t.sort(e)}return t||(t=a),n(M(this),this._depth),this.order()},D=function(){var t=arguments[0];return t.apply(arguments[0]=this,arguments),this},R=function(){var t=new Array(this.size()),e=-1;return this.each(function(){t[++e]=this}),t},$=function(){return u(this._root,this._depth)},B=function(){var t=0;return this.each(function(){++t}),t},V=function(){return!this.node()},q=function(t){function e(n,i){var o,a=-1,u=n.length;if(--i)for(var s=2*i,c=s+1;++a<u;)(o=n[a])&&(r[s]=o._parent.__data__,r[c]=a,e(o,i));else for(;++a<u;)(o=n[a])&&(r[0]=o.__data__,r[1]=a,t.apply(o,r))}var n=this._depth,r=new Array(n);return e(this._root,n),this},X=(new Map).set("svg","http://www.w3.org/2000/svg").set("xhtml","http://www.w3.org/1999/xhtml").set("xlink","http://www.w3.org/1999/xlink").set("xml","http://www.w3.org/XML/1998/namespace").set("xmlns","http://www.w3.org/2000/xmlns/"),z=function(t){var e=t.indexOf(":"),n=t;return e>=0&&(n=t.slice(0,e),t=t.slice(e+1)),X.has(n)?{space:X.get(n),local:t}:t},I=function(t,e){function n(){this.removeAttribute(t)}function r(){this.removeAttributeNS(t.space,t.local)}function i(){this.setAttribute(t,e)}function o(){this.setAttributeNS(t.space,t.local,e)}function a(){var n=e.apply(this,arguments);null==n?this.removeAttribute(t):this.setAttribute(t,n)}function u(){var n=e.apply(this,arguments);null==n?this.removeAttributeNS(t.space,t.local):this.setAttributeNS(t.space,t.local,n)}if(t=z(t),arguments.length<2){var s=this.node();return t.local?s.getAttributeNS(t.space,t.local):s.getAttribute(t)}return this.each(null==e?t.local?r:n:"function"==typeof e?t.local?u:a:t.local?o:i)},Y=function(t){return t&&(t.ownerDocument&&t.ownerDocument.defaultView||t.document&&t||t.defaultView)},k=function(t,e,n){function r(){this.style.removeProperty(t)}function i(){this.style.setProperty(t,e,n)}function o(){var r=e.apply(this,arguments);null==r?this.style.removeProperty(t):this.style.setProperty(t,r,n)}var a=arguments.length;return 2>a?Y(a=this.node()).getComputedStyle(a,null).getPropertyValue(t):(3>a&&(n=""),this.each(null==e?r:"function"==typeof e?o:i))},G=function(t,e){function n(){delete this[t]}function r(){this[t]=e}function i(){var n=e.apply(this,arguments);null==n?delete this[t]:this[t]=n}return arguments.length<2?this.node()[t]:this.each(null==e?n:"function"==typeof e?i:r)},H=/[\\\^\$\*\+\?\|\[\]\(\)\.\{\}]/g,U=function(t){return t.replace(H,"\\$&")},O=function(t,e){function n(){for(var n=-1;++n<i;)t[n](this,e)}function r(){for(var n=-1,r=e.apply(this,arguments);++n<i;)t[n](this,r)}t=(t+"").trim().split(/^|\s+/);var i=t.length;if(arguments.length<2){var o=this.node(),a=-1;if(e=o.classList){for(;++a<i;)if(!e.contains(t[a]))return!1}else for(e=o.getAttribute("class");++a<i;)if(!classedRe(t[a]).test(e))return!1;return!0}return t=t.map(s),this.each("function"==typeof e?r:n)},j=function(t){function e(){this.textContent=t}function n(){var e=t.apply(this,arguments);this.textContent=null==e?"":e}return arguments.length?(null==t&&(t=""),this.each("function"==typeof t?n:e)):this.node().textContent},K=function(t){function e(){this.innerHTML=t}function n(){var e=t.apply(this,arguments);this.innerHTML=null==e?"":e}return arguments.length?(null==t&&(t=""),this.each("function"==typeof t?n:e)):this.node().innerHTML},W=function(t,e){function n(){return this.appendChild(t.apply(this,arguments))}function r(){return this.insertBefore(t.apply(this,arguments),e.apply(this,arguments)||null)}return"function"!=typeof t&&(t=l(t)),this.select(arguments.length<2?n:("function"!=typeof e&&(e=m(e)),r))},F=function(){return this.each(function(){var t=this.parentNode;t&&t.removeChild(this)})},J=function(t){return arguments.length?this.property("__data__",t):this.node().__data__},Q=new Map;if(t.document){var Z=document.documentElement;"onmouseenter"in Z||Q.set("mouseenter","mouseover").set("mouseleave","mouseout")}var tt=function(t,e,n){function r(){for(var r=c,o=arguments.length>>1,u=new Array(o);--o>=0;)r=r[arguments[(o<<1)+1]],u[o]=o?r._parent:r;var l=h(e,u,arguments);a&&(l=f(l)),i.call(this),this.addEventListener(t,this[s]=l,l._capture=n),l._listener=e}function i(){var e=this[s];e&&(this.removeEventListener(t,e,e._capture),delete this[s])}function o(){var e,n=new RegExp("^__on([^.]+)"+U(t)+"$");for(var r in this)if(e=r.match(n)){var i=this[r];this.removeEventListener(e[1],i,i._capture),delete this[r]}}var a,u=arguments.length,s="__on"+t,c=this._root;return 2>u?(u=this.node()[s])&&u._listener:(3>u&&(n=!1),(u=t.indexOf("."))>0&&(t=t.slice(0,u)),(a=Q.has(t))&&(t=Q.get(t)),this.each(e?u?r:p:u?i:o))},et=function(t,e){function n(){return _(this,t,e)}function r(){return _(this,t,e.apply(this,arguments))}return this.each("function"==typeof e?r:n)};d.prototype={select:v,selectAll:w,filter:A,data:E,enter:N,exit:T,order:L,sort:P,call:D,nodes:R,node:$,size:B,empty:V,each:q,attr:I,style:k,property:G,"class":O,classed:O,text:j,html:K,append:W,insert:W,remove:F,datum:J,event:tt,on:tt,dispatch:et};var nt=function(t){var e;return"string"==typeof t?(e=[document.querySelector(t)],e._parent=document.documentElement):(e=[t],e._parent=null),new d(e,1)},rt=t.navigator&&/WebKit/.test(t.navigator.userAgent)?-1:0,it=function(t,e){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var r=n.createSVGPoint();if(0>rt){var i=Y(t);if(i.scrollX||i.scrollY){n=nt(i.document.body).append("svg").style({position:"absolute",top:0,left:0,margin:0,padding:0,border:"none"},"important");var o=n.node().getScreenCTM();rt=!(o.f||o.e),n.remove()}}return rt?(r.x=e.pageX,r.y=e.pageY):(r.x=e.clientX,r.y=e.clientY),r=r.matrixTransform(t.getScreenCTM().inverse()),[r.x,r.y]}var a=t.getBoundingClientRect();return[e.clientX-a.left-t.clientLeft,e.clientY-a.top-t.clientTop]},ot=function(t,e){return arguments.length<2&&(e=g()),e.changedTouches&&(e=e.changedTouches[0]),it(t,e)},at=function(t){var e;return"string"==typeof t?(e=document.querySelectorAll(t),e._parent=document.documentElement):(e=t,e._parent=null),new d(e,1)},ut=function(t,e,n){arguments.length<3&&(n=e,e=g().changedTouches);for(var r,i=0,o=e?e.length:0;o>i;++i)if((r=e[i]).identifier===n)return it(t,r);return null},st=function(t,e){arguments.length<2&&(e=g().touches);for(var n=0,r=e?e.length:0,i=new Array(r);r>n;++n)i[n]=it(t,e[n]);return i},ct={mouse:ot,namespace:z,namespaces:X,requote:U,select:nt,selectAll:at,selection:d,touch:ut,touches:st},lt=t.d3;if(lt)for(var ht in ct)lt[ht]=ct[ht];else t.d3=lt=ct;"function"==typeof define&&define.amd?define(lt):"object"==typeof module&&module.exports&&(module.exports=lt)}(this);

@@ -1,998 +0,21 @@

var d3 = module.exports = global.d3 || (global.d3 = {}),
Map = global.Map || (Map = function() {}, Map.prototype = {set: function(k, v) { this["$" + k] = v; return this; }, get: function(k) { return this["$" + k]; }, has: function(k) { return "$" + k in this; }}, Map),
valueOf = function(value) { return function() { return value; }; },
selectorOf = function(selector) { return function() { return this.querySelector(selector); }; },
selectorAllOf = function(selector) { return function() { return this.querySelectorAll(selector); }; },
filterOf = function(selector) { return function() { return this.matches(selector); }; },
filterEvents = new Map,
noop = function() {},
ascending = function(a, b) { return a < b ? -1 : a > b ? 1 : a >= b ? 0 : NaN; },
collapse = function(string) { return string.trim().replace(/\s+/g, " "); },
requote = function(string) { return string.replace(requoteRe, "\\$&"); },
requoteRe = /[\\\^\$\*\+\?\|\[\]\(\)\.\{\}]/g,
bug44083 = global.navigator && /WebKit/.test(global.navigator.userAgent) ? -1 : 0; // https://bugs.webkit.org/show_bug.cgi?id=44083
import mouse from "./src/mouse";
import namespace from "./src/namespace";
import namespaces from "./src/namespaces";
import requote from "./src/requote";
import select from "./src/select";
import selectAll from "./src/selectAll";
import Selection from "./src/selection";
import touch from "./src/touch";
import touches from "./src/touches";
(function(document) {
if (!document) return;
var element = document.documentElement;
if (!("onmouseenter" in element)) {
filterEvents.set("mouseenter", "mouseover").set("mouseleave", "mouseout");
}
if (!element.matches) {
var vendorMatches = element.webkitMatchesSelector || element.msMatchesSelector || element.mozMatchesSelector || element.oMatchesSelector;
filterOf = function(selector) { return function() { return vendorMatches.call(this, selector); }; };
}
})(global.document);
d3.namespaces = (new Map)
.set("svg", "http://www.w3.org/2000/svg")
.set("xhtml", "http://www.w3.org/1999/xhtml")
.set("xlink", "http://www.w3.org/1999/xlink")
.set("xml", "http://www.w3.org/XML/1998/namespace")
.set("xmlns", "http://www.w3.org/2000/xmlns/");
d3.namespace = function(name) {
var i = name.indexOf(":"), prefix = name;
if (i >= 0) prefix = name.slice(0, i), name = name.slice(i + 1);
return d3.namespaces.has(prefix) ? {space: d3.namespaces.get(prefix), local: name} : name;
export default {
mouse: mouse,
namespace: namespace,
namespaces: namespaces,
requote: requote,
select: select,
selectAll: selectAll,
selection: Selection,
touch: touch,
touches: touches
};
// When depth = 1, root = [Node, …].
// When depth = 2, root = [[Node, …], …].
// When depth = 3, root = [[[Node, …], …], …]. etc.
// Note that [Node, …] and NodeList are used interchangeably; see arrayify.
function Selection(root, depth) {
this._root = root;
this._depth = depth;
this._enter = this._update = this._exit = null;
}
d3.selection = Selection;
Selection.prototype = {
// The selector may either be a selector string (e.g., ".foo")
// or a function that optionally returns the node to select.
select: function(selector) {
var depth = this._depth,
stack = new Array(depth * 2);
if (typeof selector !== "function") selector = selectorOf(selector);
function visit(nodes, update, depth) {
var i = -1,
n = nodes.length,
node,
subnode,
subnodes = new Array(n);
if (--depth) {
var stack0 = depth * 2,
stack1 = stack0 + 1;
while (++i < n) {
if (node = nodes[i]) {
stack[stack0] = node._parent.__data__, stack[stack1] = i;
subnodes[i] = visit(node, update && update[i], depth);
}
}
}
// The leaf group may be sparse if the selector returns a falsey value;
// this preserves the index of nodes (unlike selection.filter).
// Propagate data to the new node only if it is defined on the old.
// If this is an enter selection, materialized nodes are moved to update.
else {
while (++i < n) {
if (node = nodes[i]) {
stack[0] = node.__data__, stack[1] = i;
if (subnode = selector.apply(node, stack)) {
if ("__data__" in node) subnode.__data__ = node.__data__;
if (update) update[i] = subnode, delete nodes[i];
subnodes[i] = subnode;
}
}
}
}
subnodes._parent = nodes._parent;
return subnodes;
}
return new Selection(visit(this._root, this._update && this._update._root, depth), depth);
},
// The selector may either be a selector string (e.g., ".foo")
// or a function that optionally returns an array of nodes to select.
// This is the only operation that increases the depth of a selection.
selectAll: function(selector) {
var depth = this._depth,
stack = new Array(depth * 2);
if (typeof selector !== "function") selector = selectorAllOf(selector);
function visit(nodes, depth) {
var i = -1,
n = nodes.length,
node,
subnode,
subnodes = new Array(n);
if (--depth) {
var stack0 = depth * 2,
stack1 = stack0 + 1;
while (++i < n) {
if (node = nodes[i]) {
stack[stack0] = node._parent.__data__, stack[stack1] = i;
subnodes[i] = visit(node, depth);
}
}
}
// Data is not propagated since there is a one-to-many mapping.
// The parent of the new leaf group is the old node.
else {
while (++i < n) {
if (node = nodes[i]) {
stack[0] = node.__data__, stack[1] = i;
subnodes[i] = subnode = selector.apply(node, stack);
subnode._parent = node;
}
}
}
subnodes._parent = nodes._parent;
return subnodes;
}
return new Selection(visit(this._root, depth), depth + 1);
},
// The filter may either be a selector string (e.g., ".foo")
// or a function that returns a boolean.
filter: function(filter) {
var depth = this._depth,
stack = new Array(depth * 2);
if (typeof filter !== "function") filter = filterOf(filter);
function visit(nodes, depth) {
var i = -1,
n = nodes.length,
node,
subnodes;
if (--depth) {
var stack0 = depth * 2,
stack1 = stack0 + 1;
subnodes = new Array(n);
while (++i < n) {
if (node = nodes[i]) {
stack[stack0] = node._parent.__data__, stack[stack1] = i;
subnodes[i] = visit(node, depth);
}
}
}
// The filter operation does not preserve the original index,
// so the resulting leaf groups are dense (not sparse).
else {
subnodes = [];
while (++i < n) {
if (node = nodes[i]) {
stack[0] = node.__data__, stack[1] = i;
if (filter.apply(node, stack)) {
subnodes.push(node);
}
}
}
}
subnodes._parent = nodes._parent;
return subnodes;
}
return new Selection(visit(this._root, depth), depth);
},
// The value may either be an array or a function that returns an array.
// An optional key function may be specified to control how data is bound;
// if no key function is specified, data is bound to nodes by index.
// Or, if no arguments are specified, this method returns all bound data.
data: function(value, key) {
if (!value) {
var data = new Array(this.size()), i = -1;
this.each(function(d) { data[++i] = d; });
return data;
}
var depth = this._depth - 1,
stack = new Array(depth * 2),
bind = key ? bindKey : bindIndex;
if (typeof value !== "function") value = valueOf(value);
visit(this._root, this.enter()._root, this.exit()._root, depth);
function visit(update, enter, exit, depth) {
var i = -1,
n,
node;
if (depth--) {
var stack0 = depth * 2,
stack1 = stack0 + 1;
n = update.length;
while (++i < n) {
if (node = update[i]) {
stack[stack0] = node._parent.__data__, stack[stack1] = i;
visit(node, enter[i], exit[i], depth);
}
}
}
else {
var j = 0,
before;
bind(update, enter, exit, value.apply(update._parent, stack));
n = update.length;
// Now connect the enter nodes to their following update node, such that
// appendChild can insert the materialized enter node before this node,
// rather than at the end of the parent node.
while (++i < n) {
if (before = enter[i]) {
if (i >= j) j = i + 1;
while (!(node = update[j]) && ++j < n);
before._next = node || null;
}
}
}
}
function bindIndex(update, enter, exit, data) {
var i = 0,
node,
nodeLength = update.length,
dataLength = data.length,
minLength = Math.min(nodeLength, dataLength);
// Clear the enter and exit arrays, and then initialize to the new length.
enter.length = 0, enter.length = dataLength;
exit.length = 0, exit.length = nodeLength;
for (; i < minLength; ++i) {
if (node = update[i]) {
node.__data__ = data[i];
} else {
enter[i] = new EnterNode(update._parent, data[i]);
}
}
// Note: we don’t need to delete update[i] here because this loop only
// runs when the data length is greater than the node length.
for (; i < dataLength; ++i) {
enter[i] = new EnterNode(update._parent, data[i]);
}
// Note: and, we don’t need to delete update[i] here because immediately
// following this loop we set the update length to data length.
for (; i < nodeLength; ++i) {
if (node = update[i]) {
exit[i] = update[i];
}
}
update.length = dataLength;
}
function bindKey(update, enter, exit, data) {
var i,
node,
dataLength = data.length,
nodeLength = update.length,
nodeByKeyValue = new Map,
keyStack = [null, null].concat(stack),
keyValues = new Array(nodeLength),
keyValue;
// Clear the enter and exit arrays, and then initialize to the new length.
enter.length = 0, enter.length = dataLength;
exit.length = 0, exit.length = nodeLength;
// Compute the keys for each node.
for (i = 0; i < nodeLength; ++i) {
if (node = update[i]) {
keyStack[0] = node.__data__, keyStack[1] = i;
keyValues[i] = keyValue = key.apply(node, keyStack);
// Is this a duplicate of a key we’ve previously seen?
// If so, this node is moved to the exit selection.
if (nodeByKeyValue.has(keyValue)) {
exit[i] = node;
}
// Otherwise, record the mapping from key to node.
else {
nodeByKeyValue.set(keyValue, node);
}
}
}
// Now clear the update array and initialize to the new length.
update.length = 0, update.length = dataLength;
// Compute the keys for each datum.
for (i = 0; i < dataLength; ++i) {
keyStack[0] = data[i], keyStack[1] = i;
keyValue = key.apply(update._parent, keyStack);
// Is there a node associated with this key?
// If not, this datum is added to the enter selection.
if (!(node = nodeByKeyValue.get(keyValue))) {
enter[i] = new EnterNode(update._parent, data[i]);
}
// Did we already bind a node using this key? (Or is a duplicate?)
// If unique, the node and datum are joined in the update selection.
// Otherwise, the datum is ignored, neither entering nor exiting.
else if (node !== true) {
update[i] = node;
node.__data__ = data[i];
}
// Record that we consumed this key, either to enter or update.
nodeByKeyValue.set(keyValue, true);
}
// Take any remaining nodes that were not bound to data,
// and place them in the exit selection.
for (i = 0; i < nodeLength; ++i) {
if ((node = nodeByKeyValue.get(keyValues[i])) !== true) {
exit[i] = node;
}
}
}
return this;
},
// Lazily constructs the enter selection for this (update) selection.
// Until this selection is joined to data, the enter selection will be empty.
enter: function() {
if (this._enter) return this._enter;
function visit(nodes, depth) {
var i = -1,
n = nodes.length,
node,
enter = new Array(n);
if (--depth) {
while (++i < n) {
if (node = nodes[i]) {
enter[i] = visit(node, depth);
}
}
}
enter._parent = nodes._parent;
return enter;
}
this._enter = new Selection(visit(arrayify(this), this._depth), this._depth);
this._enter._update = this;
return this._enter;
},
// Lazily constructs the exit selection for this (update) selection.
// Until this selection is joined to data, the exit selection will be empty.
exit: function() {
function visit(nodes, depth) {
var i = -1,
n = nodes.length,
node,
exit = new Array(n);
if (--depth) {
while (++i < n) {
if (node = nodes[i]) {
exit[i] = visit(node, depth);
}
}
}
exit._parent = nodes._parent;
return exit;
}
return this._exit || (this._exit = new Selection(visit(arrayify(this), this._depth), this._depth));
},
order: function() {
function visit(nodes, depth) {
var i = nodes.length,
node,
next;
if (--depth) {
while (--i >= 0) {
if (node = nodes[i]) {
visit(node, depth);
}
}
}
else {
next = nodes[--i];
while (--i >= 0) {
if (node = nodes[i]) {
if (next && next !== node.nextSibling) next.parentNode.insertBefore(node, next);
next = node;
}
}
}
}
visit(this._root, this._depth);
return this;
},
sort: function(comparator) {
if (!comparator) comparator = ascending;
function compare(a, b) {
return a && b ? comparator(a.__data__, b.__data__) : !a - !b;
}
function visit(nodes, depth) {
if (--depth) {
var i = -1,
n = nodes.length,
node;
while (++i < n) {
if (node = nodes[i]) {
visit(node, depth);
}
}
}
else {
nodes.sort(compare);
}
}
visit(arrayify(this), this._depth);
return this.order();
},
call: function() {
var callback = arguments[0];
callback.apply(arguments[0] = this, arguments);
return this;
},
nodes: function() {
var nodes = new Array(this.size()), i = -1;
this.each(function() { nodes[++i] = this; });
return nodes;
},
node: function() {
function visit(nodes, depth) {
var i = -1,
n = nodes.length,
node;
if (--depth) {
while (++i < n) {
if (node = nodes[i]) {
if (node = visit(node, depth)) {
return node;
}
}
}
}
else {
while (++i < n) {
if (node = nodes[i]) {
return node;
}
}
}
}
return visit(this._root, this._depth);
},
size: function() {
var size = 0;
this.each(function() { ++size; });
return size;
},
empty: function() {
return !this.node();
},
each: function(callback) {
var depth = this._depth,
stack = new Array(depth);
function visit(nodes, depth) {
var i = -1,
n = nodes.length,
node;
if (--depth) {
var stack0 = depth * 2,
stack1 = stack0 + 1;
while (++i < n) {
if (node = nodes[i]) {
stack[stack0] = node._parent.__data__, stack[stack1] = i;
visit(node, depth);
}
}
}
else {
while (++i < n) {
if (node = nodes[i]) {
stack[0] = node.__data__, stack[1] = i;
callback.apply(node, stack);
}
}
}
}
visit(this._root, depth);
return this;
},
attr: function(name, value) {
name = d3.namespace(name);
if (arguments.length < 2) {
var node = this.node();
return name.local
? node.getAttributeNS(name.space, name.local)
: node.getAttribute(name);
}
function remove() {
this.removeAttribute(name);
}
function removeNS() {
this.removeAttributeNS(name.space, name.local);
}
function setConstant() {
this.setAttribute(name, value);
}
function setConstantNS() {
this.setAttributeNS(name.space, name.local, value);
}
function setFunction() {
var x = value.apply(this, arguments);
if (x == null) this.removeAttribute(name);
else this.setAttribute(name, x);
}
function setFunctionNS() {
var x = value.apply(this, arguments);
if (x == null) this.removeAttributeNS(name.space, name.local);
else this.setAttributeNS(name.space, name.local, x);
}
return this.each(value == null
? (name.local ? removeNS : remove)
: (typeof value === "function"
? (name.local ? setFunctionNS : setFunction)
: (name.local ? setConstantNS : setConstant)));
},
style: function(name, value, priority) {
var n = arguments.length;
if (n < 2) return windowOf(n = this.node()).getComputedStyle(n, null).getPropertyValue(name);
if (n < 3) priority = "";
function remove() {
this.style.removeProperty(name);
}
function setConstant() {
this.style.setProperty(name, value, priority);
}
function setFunction() {
var x = value.apply(this, arguments);
if (x == null) this.style.removeProperty(name);
else this.style.setProperty(name, x, priority);
}
return this.each(value == null ? remove : typeof value === "function" ? setFunction : setConstant);
},
property: function(name, value) {
if (arguments.length < 2) return this.node()[name];
function remove() {
delete this[name];
}
function setConstant() {
this[name] = value;
}
function setFunction() {
var x = value.apply(this, arguments);
if (x == null) delete this[name];
else this[name] = x;
}
return this.each(value == null ? remove : typeof value === "function" ? setFunction : setConstant);
},
class: function(name, value) {
name = (name + "").trim().split(/^|\s+/);
var n = name.length;
if (arguments.length < 2) {
var node = this.node(), i = -1;
if (value = node.classList) { // SVG elements may not support DOMTokenList!
while (++i < n) if (!value.contains(name[i])) return false;
} else {
value = node.getAttribute("class");
while (++i < n) if (!classedRe(name[i]).test(value)) return false;
}
return true;
}
name = name.map(classerOf);
function setConstant() {
var i = -1;
while (++i < n) name[i](this, value);
}
function setFunction() {
var i = -1, x = value.apply(this, arguments);
while (++i < n) name[i](this, x);
}
return this.each(typeof value === "function" ? setFunction : setConstant);
},
text: function(value) {
if (!arguments.length) return this.node().textContent;
function setConstant() {
this.textContent = value;
}
function setFunction() {
var v = value.apply(this, arguments);
this.textContent = v == null ? "" : v;
}
if (value == null) value = "";
return this.each(typeof value === "function" ? setFunction : setConstant);
},
html: function(value) {
if (!arguments.length) return this.node().innerHTML;
function setConstant() {
this.innerHTML = value;
}
function setFunction() {
var v = value.apply(this, arguments);
this.innerHTML = v == null ? "" : v;
}
if (value == null) value = "";
return this.each(typeof value === "function" ? setFunction : setConstant);
},
append: function(creator, selector) {
if (typeof creator !== "function") creator = creatorOf(creator);
function append() {
return this.appendChild(creator.apply(this, arguments));
}
function insert() {
return this.insertBefore(creator.apply(this, arguments), selector.apply(this, arguments) || null);
}
return this.select(arguments.length < 2
? append
: (typeof selector !== "function" && (selector = selectorOf(selector)), insert));
},
remove: function() {
return this.each(function() {
var parent = this.parentNode;
if (parent) parent.removeChild(this);
});
},
datum: function(value) {
return arguments.length ? this.property("__data__", value) : this.node().__data__;
},
event: function(type, listener, capture) {
var n = arguments.length,
key = "__on" + type,
filter,
root = this._root;
if (n < 2) return (n = this.node()[key]) && n._listener;
if (n < 3) capture = false;
if ((n = type.indexOf(".")) > 0) type = type.slice(0, n);
if (filter = filterEvents.has(type)) type = filterEvents.get(type);
function add() {
var ancestor = root, i = arguments.length >> 1, ancestors = new Array(i);
while (--i >= 0) ancestor = ancestor[arguments[(i << 1) + 1]], ancestors[i] = i ? ancestor._parent : ancestor;
var l = listenerOf(listener, ancestors, arguments);
if (filter) l = filterListenerOf(l);
remove.call(this);
this.addEventListener(type, this[key] = l, l._capture = capture);
l._listener = listener;
}
function remove() {
var l = this[key];
if (l) {
this.removeEventListener(type, l, l._capture);
delete this[key];
}
}
function removeAll() {
var re = new RegExp("^__on([^.]+)" + requote(type) + "$"), match;
for (var name in this) {
if (match = name.match(re)) {
var l = this[name];
this.removeEventListener(match[1], l, l._capture);
delete this[name];
}
}
}
return this.each(listener
? (n ? add : noop) // Attempt to add untyped listener is ignored.
: (n ? remove : removeAll));
},
dispatch: function(type, params) {
function dispatchConstant() {
return dispatchEvent(this, type, params);
}
function dispatchFunction() {
return dispatchEvent(this, type, params.apply(this, arguments));
}
return this.each(typeof params === "function" ? dispatchFunction : dispatchConstant);
}
};
// Deprecated aliases for backwards-compatibility with 3.x:
Selection.prototype.on = Selection.prototype.event;
Selection.prototype.insert = Selection.prototype.append;
Selection.prototype.classed = Selection.prototype.class;
d3.select = function(selector) {
var root;
if (typeof selector === "string") {
var document = global.document;
root = [document.querySelector(selector)];
root._parent = document.documentElement;
} else {
root = [selector];
root._parent = null;
}
return new Selection(root, 1);
};
d3.selectAll = function(selector) {
var root;
if (typeof selector === "string") {
var document = global.document;
root = document.querySelectorAll(selector);
root._parent = document.documentElement;
} else {
root = selector;
root._parent = null;
}
return new Selection(root, 1);
};
function EnterNode(parent, datum) {
this.ownerDocument = parent.ownerDocument;
this.namespaceURI = parent.namespaceURI;
this._next = null;
this._parent = parent;
this.__data__ = datum;
}
EnterNode.prototype = {
appendChild: function(child) { return this._parent.insertBefore(child, this._next); },
insertBefore: function(child, next) { return this._parent.insertBefore(child, next || this._next); }
};
// The leaf groups of the selection hierarchy are initially NodeList,
// and then lazily converted to arrays when mutation is required.
function arrayify(selection) {
function visit(nodes, depth) {
var i = -1,
n = nodes.length,
node;
if (--depth) {
while (++i < n) {
if (node = nodes[i]) {
nodes[i] = visit(node, depth);
}
}
}
else if (!Array.isArray(nodes)) {
var array = new Array(n);
while (++i < n) array[i] = nodes[i];
array._parent = nodes._parent;
nodes = array;
}
return nodes;
}
return selection._root = visit(selection._root, selection._depth);
}
function creatorOf(name) {
name = d3.namespace(name);
function creator() {
var document = this.ownerDocument,
uri = this.namespaceURI;
return uri
? document.createElementNS(uri, name)
: document.createElement(name);
}
function creatorNS() {
return this.ownerDocument.createElementNS(name.space, name.local);
}
return name.local ? creatorNS : creator;
}
function windowOf(node) {
return node
&& ((node.ownerDocument && node.ownerDocument.defaultView) // node is a Node
|| (node.document && node) // node is a Window
|| node.defaultView); // node is a Document
}
function dispatchEvent(node, type, params) {
var window = windowOf(node),
event = window.CustomEvent;
if (event) {
event = new event(type, params);
} else {
event = window.document.createEvent("Event");
if (params) event.initEvent(type, params.bubbles, params.cancelable), event.detail = params.detail;
else event.initEvent(type, false, false);
}
node.dispatchEvent(event);
}
function classerOf(name) {
var re;
return function(node, value) {
if (c = node.classList) return value ? c.add(name) : c.remove(name);
if (!re) re = new RegExp("(?:^|\\s+)" + requote(name) + "(?:\\s+|$)", "g");
var c = node.getAttribute("class") || "";
if (value) {
re.lastIndex = 0;
if (!re.test(c)) node.setAttribute("class", collapse(c + " " + name));
} else {
node.setAttribute("class", collapse(c.replace(re, " ")));
}
};
}
function listenerOf(listener, ancestors, args) {
return function(event) {
var i = ancestors.length, event0 = d3.event; // Events can be reentrant (e.g., focus).
while (--i >= 0) args[i << 1] = ancestors[i].__data__;
d3.event = event;
try {
listener.apply(ancestors[0], args);
} finally {
d3.event = event0;
}
};
}
function filterListenerOf(listener) {
return function(event) {
var related = event.relatedTarget;
if (!related || (related !== this && !(related.compareDocumentPosition(this) & 8))) {
listener(event);
}
};
}
function point(node, event) {
var svg = node.ownerSVGElement || node;
if (svg.createSVGPoint) {
var point = svg.createSVGPoint();
if (bug44083 < 0) {
var window = windowOf(node);
if (window.scrollX || window.scrollY) {
svg = d3.select(window.document.body).append("svg").style({position: "absolute", top: 0, left: 0, margin: 0, padding: 0, border: "none"}, "important");
var ctm = svg.node().getScreenCTM();
bug44083 = !(ctm.f || ctm.e);
svg.remove();
}
}
if (bug44083) point.x = event.pageX, point.y = event.pageY;
else point.x = event.clientX, point.y = event.clientY;
point = point.matrixTransform(node.getScreenCTM().inverse());
return [point.x, point.y];
}
var rect = node.getBoundingClientRect();
return [event.clientX - rect.left - node.clientLeft, event.clientY - rect.top - node.clientTop];
}
function source() {
var event = d3.event, source;
while (source = event.sourceEvent) event = source;
return event;
}
d3.mouse = function(node, event) {
if (arguments.length < 2) event = source();
if (event.changedTouches) event = event.changedTouches[0];
return point(node, event);
};
d3.touch = function(node, touches, identifier) {
if (arguments.length < 3) identifier = touches, touches = source().changedTouches;
for (var i = 0, n = touches ? touches.length : 0, touch; i < n; ++i) {
if ((touch = touches[i]).identifier === identifier) {
return point(node, touch);
}
}
return null;
};
d3.touches = function(node, touches) {
if (arguments.length < 2) touches = source().touches;
for (var i = 0, n = touches ? touches.length : 0, points = new Array(n); i < n; ++i) {
points[i] = point(node, touches[i]);
}
return points;
};
{
"name": "d3-selection",
"version": "0.2.0",
"version": "0.3.0",
"description": "Data-driven DOM manipulation.",

@@ -11,9 +11,9 @@ "main": "index",

"devDependencies": {
"browserify": "10",
"d3-bundler": "0.1",
"faucet": "0.0",
"jsdom": "3",
"requirejs": "2",
"tape": "4",
"uglify-js": "2",
"requirejs": "2"
"uglify-js": "2"
}
}

@@ -7,3 +7,3 @@ # d3-selection

* The implementation is now organized into CommonJS modules, rather than the ad hoc [SMASH](https://github.com/mbostock/smash) concatenation process used previously. A standalone build is provided for your convenience using [Browserify](http://browserify.org/), but you are free to define your own build process (e.g., [Webpack](https://webpack.github.io/)). See [#2220](https://github.com/mbostock/d3/issues/2220).
* The implementation is now organized into ES6 modules, rather than the ad hoc [SMASH](https://github.com/mbostock/smash) bundling used previously. A [UMD](https://github.com/umdjs/umd) build is provided for your convenience using [Esperanto](http://esperantojs.org/), but you are free to define your own build process (e.g., [Browserify](http://browserify.org/) or [Webpack](https://webpack.github.io/)). See [#2220](https://github.com/mbostock/d3/issues/2220).

@@ -10,0 +10,0 @@ * The Selection class now extends Object, not Array, obviating the need for [prototype injection](http://perfectionkills.com/how-ecmascript-5-still-does-not-allow-to-subclass-an-array/#wrappers_prototype_chain_injection) (and [direct property injection](http://perfectionkills.com/how-ecmascript-5-still-does-not-allow-to-subclass-an-array/#wrappers_direct_property_injection) on runtimes that do not support `__proto__`). See [#2191](https://github.com/mbostock/d3/issues/2191).

var tape = require("tape"),
jsdom = require("jsdom"),
d3 = require("../");
d3 = require("../d3-selection");

@@ -5,0 +5,0 @@ tape("d3.selectAll can select by string", function(test) {

var tape = require("tape"),
jsdom = require("jsdom"),
d3 = require("../");
d3 = require("../d3-selection");

@@ -5,0 +5,0 @@ tape("d3.select can select an element", function(test) {

var tape = require("tape"),
jsdom = require("jsdom"),
d3 = require("../");
d3 = require("../d3-selection");

@@ -5,0 +5,0 @@ tape("d3.selectAll can select an array of elements", function(test) {

var tape = require("tape"),
jsdom = require("jsdom"),
d3 = require("../");
d3 = require("../d3-selection");

@@ -5,0 +5,0 @@ tape("selection.enter initially returns an empty selection", function(test) {

var tape = require("tape"),
jsdom = require("jsdom"),
d3 = require("../");
d3 = require("../d3-selection");

@@ -5,0 +5,0 @@ tape("selection.event registers a listener which receives events", function(test) {

var tape = require("tape"),
jsdom = require("jsdom"),
d3 = require("../");
d3 = require("../d3-selection");

@@ -5,0 +5,0 @@ tape("selection.exit initially returns an empty selection", function(test) {

var tape = require("tape"),
jsdom = require("jsdom"),
d3 = require("../");
d3 = require("../d3-selection");

@@ -5,0 +5,0 @@ tape("selection.select can select elements (in the simplest case)", function(test) {

var tape = require("tape"),
jsdom = require("jsdom"),
d3 = require("../");
d3 = require("../d3-selection");

@@ -5,0 +5,0 @@ tape("selection.selectAll can select elements (in the simplest case)", function(test) {

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc