@redsift/d3-rs-tip
Advanced tools
Comparing version 0.2.1 to 0.2.2
(function (global, factory) { | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('d3-selection')) : | ||
typeof define === 'function' && define.amd ? define(['exports', 'd3-selection'], factory) : | ||
(factory((global.d3_rs_tip = global.d3_rs_tip || {}),global.d3)); | ||
}(this, function (exports,d3Selection) { 'use strict'; | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : | ||
typeof define === 'function' && define.amd ? define(['exports'], factory) : | ||
(factory((global.d3_rs_tip = global.d3_rs_tip || {}))); | ||
}(this, function (exports) { 'use strict'; | ||
var version = "0.2.1"; | ||
var version = "0.2.2"; | ||
function tip() { | ||
var d3_tip_functor = function d3_tip_functor(v) { | ||
return typeof v === "function" ? v : function () { | ||
return v; | ||
var xhtml = "http://www.w3.org/1999/xhtml"; | ||
var namespaces = { | ||
svg: "http://www.w3.org/2000/svg", | ||
xhtml: xhtml, | ||
xlink: "http://www.w3.org/1999/xlink", | ||
xml: "http://www.w3.org/XML/1998/namespace", | ||
xmlns: "http://www.w3.org/2000/xmlns/" | ||
}; | ||
function namespace(name) { | ||
var prefix = name += "", i = prefix.indexOf(":"); | ||
if (i >= 0 && (prefix = name.slice(0, i)) !== "xmlns") name = name.slice(i + 1); | ||
return namespaces.hasOwnProperty(prefix) ? {space: namespaces[prefix], local: name} : name; | ||
} | ||
function creatorInherit(name) { | ||
return function() { | ||
var document = this.ownerDocument, | ||
uri = this.namespaceURI; | ||
return uri === xhtml && document.documentElement.namespaceURI === xhtml | ||
? document.createElement(name) | ||
: document.createElementNS(uri, name); | ||
}; | ||
} | ||
function creatorFixed(fullname) { | ||
return function() { | ||
return this.ownerDocument.createElementNS(fullname.space, fullname.local); | ||
}; | ||
} | ||
function creator(name) { | ||
var fullname = namespace(name); | ||
return (fullname.local | ||
? creatorFixed | ||
: creatorInherit)(fullname); | ||
} | ||
var matcher = function(selector) { | ||
return function() { | ||
return this.matches(selector); | ||
}; | ||
}; | ||
if (typeof document !== "undefined") { | ||
var element = document.documentElement; | ||
if (!element.matches) { | ||
var vendorMatches = element.webkitMatchesSelector | ||
|| element.msMatchesSelector | ||
|| element.mozMatchesSelector | ||
|| element.oMatchesSelector; | ||
matcher = function(selector) { | ||
return function() { | ||
return vendorMatches.call(this, selector); | ||
}; | ||
}; | ||
} | ||
} | ||
var matcher$1 = matcher; | ||
var filterEvents = {}; | ||
var event = null; | ||
if (typeof document !== "undefined") { | ||
var element$1 = document.documentElement; | ||
if (!("onmouseenter" in element$1)) { | ||
filterEvents = {mouseenter: "mouseover", mouseleave: "mouseout"}; | ||
} | ||
} | ||
function filterContextListener(listener, index, group) { | ||
listener = contextListener(listener, index, group); | ||
return function(event) { | ||
var related = event.relatedTarget; | ||
if (!related || (related !== this && !(related.compareDocumentPosition(this) & 8))) { | ||
listener.call(this, event); | ||
} | ||
}; | ||
var d3_tip_direction = function d3_tip_direction() { | ||
return 'n'; | ||
} | ||
function contextListener(listener, index, group) { | ||
return function(event1) { | ||
var event0 = event; // Events can be reentrant (e.g., focus). | ||
event = event1; | ||
try { | ||
listener.call(this, this.__data__, index, group); | ||
} finally { | ||
event = event0; | ||
} | ||
}; | ||
var d3_tip_offset = function d3_tip_offset() { | ||
return [0, 0]; | ||
} | ||
function parseTypenames(typenames) { | ||
return typenames.trim().split(/^|\s+/).map(function(t) { | ||
var name = "", i = t.indexOf("."); | ||
if (i >= 0) name = t.slice(i + 1), t = t.slice(0, i); | ||
return {type: t, name: name}; | ||
}); | ||
} | ||
function onRemove(typename) { | ||
return function() { | ||
var this$1 = this; | ||
var on = this.__on; | ||
if (!on) return; | ||
for (var j = 0, i = -1, m = on.length, o; j < m; ++j) { | ||
if (o = on[j], (!typename.type || o.type === typename.type) && o.name === typename.name) { | ||
this$1.removeEventListener(o.type, o.listener, o.capture); | ||
} else { | ||
on[++i] = o; | ||
} | ||
} | ||
if (++i) on.length = i; | ||
else delete this.__on; | ||
}; | ||
var d3_tip_html = function d3_tip_html() { | ||
return ' '; | ||
} | ||
function onAdd(typename, value, capture) { | ||
var wrap = filterEvents.hasOwnProperty(typename.type) ? filterContextListener : contextListener; | ||
return function(d, i, group) { | ||
var this$1 = this; | ||
var on = this.__on, o, listener = wrap(value, i, group); | ||
if (on) for (var j = 0, m = on.length; j < m; ++j) { | ||
if ((o = on[j]).type === typename.type && o.name === typename.name) { | ||
this$1.removeEventListener(o.type, o.listener, o.capture); | ||
this$1.addEventListener(o.type, o.listener = listener, o.capture = capture); | ||
o.value = value; | ||
return; | ||
} | ||
} | ||
this.addEventListener(typename.type, listener, capture); | ||
o = {type: typename.type, name: typename.name, value: value, listener: listener, capture: capture}; | ||
if (!on) this.__on = [o]; | ||
else on.push(o); | ||
}; | ||
var defaultTipStyle = ['.d3-tip {line-height: 1;font-weight: bold;padding: 12px;background: rgba(0, 0, 0, 0.8);color: #fff;border-radius: 2px;pointer-events: none;}', '/* Creates a small triangle extender for the tooltip */', '.d3-tip:after {box-sizing: border-box;display: inline;font-size: 10px;width: 100%;line-height: 1;color: rgba(0, 0, 0, 0.8);position: absolute;pointer-events: none;}', '/* Northward tooltips */', '.d3-tip.n:after {content: "\\25bc";margin: -1px 0 0 0;top: 100%;left: 0;text-align: center;}', '/* Eastward tooltips */', '.d3-tip.e:after {content: "\\25C0";margin: -4px 0 0 0;top: 50%;left: -8px;}', '/* Southward tooltips */', '.d3-tip.s:after {content: "\\25B2";margin: 0 0 1px 0;top: -7px;left: 0;text-align: center;}', '/* Westward tooltips */', '.d3-tip.w:after {content: "\\25B6";margin: -4px 0 0 -1px;top: 50%;left: 100%;}'].join('\n'); | ||
} | ||
function selection_on(typename, value, capture) { | ||
var this$1 = this; | ||
var typenames = parseTypenames(typename + ""), i, n = typenames.length, t; | ||
if (arguments.length < 2) { | ||
var on = this.node().__on; | ||
if (on) for (var j = 0, m = on.length, o; j < m; ++j) { | ||
for (i = 0, o = on[j]; i < n; ++i) { | ||
if ((t = typenames[i]).type === o.type && t.name === o.name) { | ||
return o.value; | ||
} | ||
} | ||
} | ||
return; | ||
} | ||
on = value ? onAdd : onRemove; | ||
if (capture == null) capture = false; | ||
for (i = 0; i < n; ++i) this$1.each(on(typenames[i], value, capture)); | ||
return this; | ||
} | ||
function selector(selector) { | ||
return function() { | ||
return this.querySelector(selector); | ||
}; | ||
} | ||
function selection_select(select) { | ||
if (typeof select !== "function") select = selector(select); | ||
for (var groups = this._groups, m = groups.length, subgroups = new Array(m), j = 0; j < m; ++j) { | ||
for (var group = groups[j], n = group.length, subgroup = subgroups[j] = new Array(n), node, subnode, i = 0; i < n; ++i) { | ||
if ((node = group[i]) && (subnode = select.call(node, node.__data__, i, group))) { | ||
if ("__data__" in node) subnode.__data__ = node.__data__; | ||
subgroup[i] = subnode; | ||
} | ||
} | ||
} | ||
return new Selection(subgroups, this._parents); | ||
} | ||
function selectorAll(selector) { | ||
return function() { | ||
return this.querySelectorAll(selector); | ||
}; | ||
} | ||
function selection_selectAll(select) { | ||
if (typeof select !== "function") select = selectorAll(select); | ||
for (var groups = this._groups, m = groups.length, subgroups = [], parents = [], j = 0; j < m; ++j) { | ||
for (var group = groups[j], n = group.length, node, i = 0; i < n; ++i) { | ||
if (node = group[i]) { | ||
subgroups.push(select.call(node, node.__data__, i, group)); | ||
parents.push(node); | ||
} | ||
} | ||
} | ||
return new Selection(subgroups, parents); | ||
} | ||
function selection_filter(match) { | ||
if (typeof match !== "function") match = matcher$1(match); | ||
for (var groups = this._groups, m = groups.length, subgroups = new Array(m), j = 0; j < m; ++j) { | ||
for (var group = groups[j], n = group.length, subgroup = subgroups[j] = new Array(n), node, i = 0; i < n; ++i) { | ||
if ((node = group[i]) && match.call(node, node.__data__, i, group)) { | ||
subgroup[i] = node; | ||
} | ||
} | ||
} | ||
return new Selection(subgroups, this._parents); | ||
} | ||
function constant(x) { | ||
return function() { | ||
return x; | ||
}; | ||
} | ||
var keyPrefix = "$"; // Protect against keys like “__proto__”. | ||
function bindIndex(parent, group, enter, update, exit, data) { | ||
var i = 0, | ||
node, | ||
groupLength = group.length, | ||
dataLength = data.length; | ||
// Put any non-null nodes that fit into update. | ||
// Put any null nodes into enter. | ||
// Put any remaining data into enter. | ||
for (; i < dataLength; ++i) { | ||
if (node = group[i]) { | ||
node.__data__ = data[i]; | ||
update[i] = node; | ||
} else { | ||
enter[i] = new EnterNode(parent, data[i]); | ||
} | ||
} | ||
// Put any non-null nodes that don’t fit into exit. | ||
for (; i < groupLength; ++i) { | ||
if (node = group[i]) { | ||
exit[i] = node; | ||
} | ||
} | ||
} | ||
function bindKey(parent, group, enter, update, exit, data, key) { | ||
var i, | ||
node, | ||
nodeByKeyValue = {}, | ||
groupLength = group.length, | ||
dataLength = data.length, | ||
keyValues = new Array(groupLength), | ||
keyValue; | ||
// Compute the key for each node. | ||
// If multiple nodes have the same key, the duplicates are added to exit. | ||
for (i = 0; i < groupLength; ++i) { | ||
if (node = group[i]) { | ||
keyValues[i] = keyValue = keyPrefix + key.call(node, node.__data__, i, group); | ||
if (keyValue in nodeByKeyValue) { | ||
exit[i] = node; | ||
} else { | ||
nodeByKeyValue[keyValue] = node; | ||
} | ||
} | ||
} | ||
// Compute the key for each datum. | ||
// If there a node associated with this key, join and add it to update. | ||
// If there is not (or the key is a duplicate), add it to enter. | ||
for (i = 0; i < dataLength; ++i) { | ||
keyValue = keyPrefix + key.call(parent, data[i], i, data); | ||
if (node = nodeByKeyValue[keyValue]) { | ||
update[i] = node; | ||
node.__data__ = data[i]; | ||
nodeByKeyValue[keyValue] = null; | ||
} else { | ||
enter[i] = new EnterNode(parent, data[i]); | ||
} | ||
} | ||
// Add any remaining nodes that were not bound to data to exit. | ||
for (i = 0; i < groupLength; ++i) { | ||
if ((node = group[i]) && (nodeByKeyValue[keyValues[i]] === node)) { | ||
exit[i] = node; | ||
} | ||
} | ||
} | ||
function selection_data(value, key) { | ||
if (!value) { | ||
data = new Array(this.size()), j = -1; | ||
this.each(function(d) { data[++j] = d; }); | ||
return data; | ||
} | ||
var bind = key ? bindKey : bindIndex, | ||
parents = this._parents, | ||
groups = this._groups; | ||
if (typeof value !== "function") value = constant(value); | ||
for (var m = groups.length, update = new Array(m), enter = new Array(m), exit = new Array(m), j = 0; j < m; ++j) { | ||
var parent = parents[j], | ||
group = groups[j], | ||
groupLength = group.length, | ||
data = value.call(parent, parent && parent.__data__, j, parents), | ||
dataLength = data.length, | ||
enterGroup = enter[j] = new Array(dataLength), | ||
updateGroup = update[j] = new Array(dataLength), | ||
exitGroup = exit[j] = new Array(groupLength); | ||
bind(parent, group, enterGroup, updateGroup, exitGroup, data, key); | ||
// 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. | ||
for (var i0 = 0, i1 = 0, previous, next; i0 < dataLength; ++i0) { | ||
if (previous = enterGroup[i0]) { | ||
if (i0 >= i1) i1 = i0 + 1; | ||
while (!(next = updateGroup[i1]) && ++i1 < dataLength); | ||
previous._next = next || null; | ||
} | ||
} | ||
} | ||
update = new Selection(update, parents); | ||
update._enter = enter; | ||
update._exit = exit; | ||
return update; | ||
} | ||
function EnterNode(parent, datum) { | ||
this.ownerDocument = parent.ownerDocument; | ||
this.namespaceURI = parent.namespaceURI; | ||
this._next = null; | ||
this._parent = parent; | ||
this.__data__ = datum; | ||
} | ||
EnterNode.prototype = { | ||
constructor: EnterNode, | ||
appendChild: function(child) { return this._parent.insertBefore(child, this._next); }, | ||
insertBefore: function(child, next) { return this._parent.insertBefore(child, next); }, | ||
querySelector: function(selector) { return this._parent.querySelector(selector); }, | ||
querySelectorAll: function(selector) { return this._parent.querySelectorAll(selector); } | ||
}; | ||
function sparse(update) { | ||
return new Array(update.length); | ||
} | ||
function selection_enter() { | ||
return new Selection(this._enter || this._groups.map(sparse), this._parents); | ||
} | ||
function selection_exit() { | ||
return new Selection(this._exit || this._groups.map(sparse), this._parents); | ||
} | ||
function selection_merge(selection) { | ||
for (var groups0 = this._groups, groups1 = selection._groups, m0 = groups0.length, m1 = groups1.length, m = Math.min(m0, m1), merges = new Array(m0), j = 0; j < m; ++j) { | ||
for (var group0 = groups0[j], group1 = groups1[j], n = group0.length, merge = merges[j] = new Array(n), node, i = 0; i < n; ++i) { | ||
if (node = group0[i] || group1[i]) { | ||
merge[i] = node; | ||
} | ||
} | ||
} | ||
for (; j < m0; ++j) { | ||
merges[j] = groups0[j]; | ||
} | ||
return new Selection(merges, this._parents); | ||
} | ||
function selection_order() { | ||
for (var groups = this._groups, j = -1, m = groups.length; ++j < m;) { | ||
for (var group = groups[j], i = group.length - 1, next = group[i], node; --i >= 0;) { | ||
if (node = group[i]) { | ||
if (next && next !== node.nextSibling) next.parentNode.insertBefore(node, next); | ||
next = node; | ||
} | ||
} | ||
} | ||
return this; | ||
} | ||
function selection_sort(compare) { | ||
if (!compare) compare = ascending; | ||
function compareNode(a, b) { | ||
return a && b ? compare(a.__data__, b.__data__) : !a - !b; | ||
} | ||
for (var groups = this._groups, m = groups.length, sortgroups = new Array(m), j = 0; j < m; ++j) { | ||
for (var group = groups[j], n = group.length, sortgroup = sortgroups[j] = new Array(n), node, i = 0; i < n; ++i) { | ||
if (node = group[i]) { | ||
sortgroup[i] = node; | ||
} | ||
} | ||
sortgroup.sort(compareNode); | ||
} | ||
return new Selection(sortgroups, this._parents).order(); | ||
} | ||
function ascending(a, b) { | ||
return a < b ? -1 : a > b ? 1 : a >= b ? 0 : NaN; | ||
} | ||
function selection_call() { | ||
var callback = arguments[0]; | ||
arguments[0] = this; | ||
callback.apply(null, arguments); | ||
return this; | ||
} | ||
function selection_nodes() { | ||
var nodes = new Array(this.size()), i = -1; | ||
this.each(function() { nodes[++i] = this; }); | ||
return nodes; | ||
} | ||
function selection_node() { | ||
for (var groups = this._groups, j = 0, m = groups.length; j < m; ++j) { | ||
for (var group = groups[j], i = 0, n = group.length; i < n; ++i) { | ||
var node = group[i]; | ||
if (node) return node; | ||
} | ||
} | ||
return null; | ||
} | ||
function selection_size() { | ||
var size = 0; | ||
this.each(function() { ++size; }); | ||
return size; | ||
} | ||
function selection_empty() { | ||
return !this.node(); | ||
} | ||
function selection_each(callback) { | ||
for (var groups = this._groups, j = 0, m = groups.length; j < m; ++j) { | ||
for (var group = groups[j], i = 0, n = group.length, node; i < n; ++i) { | ||
if (node = group[i]) callback.call(node, node.__data__, i, group); | ||
} | ||
} | ||
return this; | ||
} | ||
function attrRemove(name) { | ||
return function() { | ||
this.removeAttribute(name); | ||
}; | ||
} | ||
function attrRemoveNS(fullname) { | ||
return function() { | ||
this.removeAttributeNS(fullname.space, fullname.local); | ||
}; | ||
} | ||
function attrConstant(name, value) { | ||
return function() { | ||
this.setAttribute(name, value); | ||
}; | ||
} | ||
function attrConstantNS(fullname, value) { | ||
return function() { | ||
this.setAttributeNS(fullname.space, fullname.local, value); | ||
}; | ||
} | ||
function attrFunction(name, value) { | ||
return function() { | ||
var v = value.apply(this, arguments); | ||
if (v == null) this.removeAttribute(name); | ||
else this.setAttribute(name, v); | ||
}; | ||
} | ||
function attrFunctionNS(fullname, value) { | ||
return function() { | ||
var v = value.apply(this, arguments); | ||
if (v == null) this.removeAttributeNS(fullname.space, fullname.local); | ||
else this.setAttributeNS(fullname.space, fullname.local, v); | ||
}; | ||
} | ||
function selection_attr(name, value) { | ||
var fullname = namespace(name); | ||
if (arguments.length < 2) { | ||
var node = this.node(); | ||
return fullname.local | ||
? node.getAttributeNS(fullname.space, fullname.local) | ||
: node.getAttribute(fullname); | ||
} | ||
return this.each((value == null | ||
? (fullname.local ? attrRemoveNS : attrRemove) : (typeof value === "function" | ||
? (fullname.local ? attrFunctionNS : attrFunction) | ||
: (fullname.local ? attrConstantNS : attrConstant)))(fullname, value)); | ||
} | ||
function defaultView(node) { | ||
return (node.ownerDocument && node.ownerDocument.defaultView) // node is a Node | ||
|| (node.document && node) // node is a Window | ||
|| node.defaultView; // node is a Document | ||
} | ||
function styleRemove(name) { | ||
return function() { | ||
this.style.removeProperty(name); | ||
}; | ||
} | ||
function styleConstant(name, value, priority) { | ||
return function() { | ||
this.style.setProperty(name, value, priority); | ||
}; | ||
} | ||
function styleFunction(name, value, priority) { | ||
return function() { | ||
var v = value.apply(this, arguments); | ||
if (v == null) this.style.removeProperty(name); | ||
else this.style.setProperty(name, v, priority); | ||
}; | ||
} | ||
function selection_style(name, value, priority) { | ||
var node; | ||
return arguments.length > 1 | ||
? this.each((value == null | ||
? styleRemove : typeof value === "function" | ||
? styleFunction | ||
: styleConstant)(name, value, priority == null ? "" : priority)) | ||
: defaultView(node = this.node()) | ||
.getComputedStyle(node, null) | ||
.getPropertyValue(name); | ||
} | ||
function propertyRemove(name) { | ||
return function() { | ||
delete this[name]; | ||
}; | ||
} | ||
function propertyConstant(name, value) { | ||
return function() { | ||
this[name] = value; | ||
}; | ||
} | ||
function propertyFunction(name, value) { | ||
return function() { | ||
var v = value.apply(this, arguments); | ||
if (v == null) delete this[name]; | ||
else this[name] = v; | ||
}; | ||
} | ||
function selection_property(name, value) { | ||
return arguments.length > 1 | ||
? this.each((value == null | ||
? propertyRemove : typeof value === "function" | ||
? propertyFunction | ||
: propertyConstant)(name, value)) | ||
: this.node()[name]; | ||
} | ||
function classArray(string) { | ||
return string.trim().split(/^|\s+/); | ||
} | ||
function classList(node) { | ||
return node.classList || new ClassList(node); | ||
} | ||
function ClassList(node) { | ||
this._node = node; | ||
this._names = classArray(node.getAttribute("class") || ""); | ||
} | ||
ClassList.prototype = { | ||
add: function(name) { | ||
var i = this._names.indexOf(name); | ||
if (i < 0) { | ||
this._names.push(name); | ||
this._node.setAttribute("class", this._names.join(" ")); | ||
} | ||
}, | ||
remove: function(name) { | ||
var i = this._names.indexOf(name); | ||
if (i >= 0) { | ||
this._names.splice(i, 1); | ||
this._node.setAttribute("class", this._names.join(" ")); | ||
} | ||
}, | ||
contains: function(name) { | ||
return this._names.indexOf(name) >= 0; | ||
} | ||
}; | ||
function classedAdd(node, names) { | ||
var list = classList(node), i = -1, n = names.length; | ||
while (++i < n) list.add(names[i]); | ||
} | ||
function classedRemove(node, names) { | ||
var list = classList(node), i = -1, n = names.length; | ||
while (++i < n) list.remove(names[i]); | ||
} | ||
function classedTrue(names) { | ||
return function() { | ||
classedAdd(this, names); | ||
}; | ||
} | ||
function classedFalse(names) { | ||
return function() { | ||
classedRemove(this, names); | ||
}; | ||
} | ||
function classedFunction(names, value) { | ||
return function() { | ||
(value.apply(this, arguments) ? classedAdd : classedRemove)(this, names); | ||
}; | ||
} | ||
function selection_classed(name, value) { | ||
var names = classArray(name + ""); | ||
if (arguments.length < 2) { | ||
var list = classList(this.node()), i = -1, n = names.length; | ||
while (++i < n) if (!list.contains(names[i])) return false; | ||
return true; | ||
} | ||
return this.each((typeof value === "function" | ||
? classedFunction : value | ||
? classedTrue | ||
: classedFalse)(names, value)); | ||
} | ||
function textRemove() { | ||
this.textContent = ""; | ||
} | ||
function textConstant(value) { | ||
return function() { | ||
this.textContent = value; | ||
}; | ||
} | ||
function textFunction(value) { | ||
return function() { | ||
var v = value.apply(this, arguments); | ||
this.textContent = v == null ? "" : v; | ||
}; | ||
} | ||
function selection_text(value) { | ||
return arguments.length | ||
? this.each(value == null | ||
? textRemove : (typeof value === "function" | ||
? textFunction | ||
: textConstant)(value)) | ||
: this.node().textContent; | ||
} | ||
function htmlRemove() { | ||
this.innerHTML = ""; | ||
} | ||
function htmlConstant(value) { | ||
return function() { | ||
this.innerHTML = value; | ||
}; | ||
} | ||
function htmlFunction(value) { | ||
return function() { | ||
var v = value.apply(this, arguments); | ||
this.innerHTML = v == null ? "" : v; | ||
}; | ||
} | ||
function selection_html(value) { | ||
return arguments.length | ||
? this.each(value == null | ||
? htmlRemove : (typeof value === "function" | ||
? htmlFunction | ||
: htmlConstant)(value)) | ||
: this.node().innerHTML; | ||
} | ||
function raise() { | ||
if (this.nextSibling) this.parentNode.appendChild(this); | ||
} | ||
function selection_raise() { | ||
return this.each(raise); | ||
} | ||
function lower() { | ||
if (this.previousSibling) this.parentNode.insertBefore(this, this.parentNode.firstChild); | ||
} | ||
function selection_lower() { | ||
return this.each(lower); | ||
} | ||
function selection_append(name) { | ||
var create = typeof name === "function" ? name : creator(name); | ||
return this.select(function() { | ||
return this.appendChild(create.apply(this, arguments)); | ||
}); | ||
} | ||
function constantNull() { | ||
return null; | ||
} | ||
function selection_insert(name, before) { | ||
var create = typeof name === "function" ? name : creator(name), | ||
select = before == null ? constantNull : typeof before === "function" ? before : selector(before); | ||
return this.select(function() { | ||
return this.insertBefore(create.apply(this, arguments), select.apply(this, arguments) || null); | ||
}); | ||
} | ||
function remove() { | ||
var parent = this.parentNode; | ||
if (parent) parent.removeChild(this); | ||
} | ||
function selection_remove() { | ||
return this.each(remove); | ||
} | ||
function selection_datum(value) { | ||
return arguments.length | ||
? this.property("__data__", value) | ||
: this.node().__data__; | ||
} | ||
function dispatchEvent(node, type, params) { | ||
var window = defaultView(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 dispatchConstant(type, params) { | ||
return function() { | ||
return dispatchEvent(this, type, params); | ||
}; | ||
} | ||
function dispatchFunction(type, params) { | ||
return function() { | ||
return dispatchEvent(this, type, params.apply(this, arguments)); | ||
}; | ||
} | ||
function selection_dispatch(type, params) { | ||
return this.each((typeof params === "function" | ||
? dispatchFunction | ||
: dispatchConstant)(type, params)); | ||
} | ||
var root = [null]; | ||
function Selection(groups, parents) { | ||
this._groups = groups; | ||
this._parents = parents; | ||
} | ||
function selection() { | ||
return new Selection([[document.documentElement]], root); | ||
} | ||
Selection.prototype = selection.prototype = { | ||
constructor: Selection, | ||
select: selection_select, | ||
selectAll: selection_selectAll, | ||
filter: selection_filter, | ||
data: selection_data, | ||
enter: selection_enter, | ||
exit: selection_exit, | ||
merge: selection_merge, | ||
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, | ||
classed: selection_classed, | ||
text: selection_text, | ||
html: selection_html, | ||
raise: selection_raise, | ||
lower: selection_lower, | ||
append: selection_append, | ||
insert: selection_insert, | ||
remove: selection_remove, | ||
datum: selection_datum, | ||
on: selection_on, | ||
dispatch: selection_dispatch | ||
}; | ||
function select(selector) { | ||
return typeof selector === "string" | ||
? new Selection([[document.querySelector(selector)]], [document.documentElement]) | ||
: new Selection([[selector]], root); | ||
} | ||
function tip(id) { | ||
var d3_tip_functor = function (v) { return (typeof v === "function" ? v : function () { return v; }); }; | ||
var d3_tip_direction = function () { return 'n'; }; | ||
var d3_tip_offset = function () { return [0, 0]; }; | ||
var d3_tip_html = function () { return ' '; }; | ||
var IsDOMElement = function (o) { return o instanceof Node; }; | ||
var defaultTipStyle = [ | ||
'.d3-tip {line-height: 1;font-weight: bold;padding: 12px;background: rgba(0, 0, 0, 0.8);color: #fff;border-radius: 2px;pointer-events: none;}', | ||
'/* Creates a small triangle extender for the tooltip */', | ||
'.d3-tip:after {box-sizing: border-box;display: inline;font-size: 10px;width: 100%;line-height: 1;color: rgba(0, 0, 0, 0.8);position: absolute;pointer-events: none;}', | ||
'/* Northward tooltips */', | ||
'.d3-tip.n:after {content: "\\25bc";margin: -1px 0 0 0;top: 100%;left: 0;text-align: center;}', | ||
'/* Eastward tooltips */', | ||
'.d3-tip.e:after {content: "\\25C0";margin: -4px 0 0 0;top: 50%;left: -8px;}', | ||
'/* Southward tooltips */', | ||
'.d3-tip.s:after {content: "\\25B2";margin: 0 0 1px 0;top: -7px;left: 0;text-align: center;}', | ||
'/* Westward tooltips */', | ||
'.d3-tip.w:after {content: "\\25B6";margin: -4px 0 0 -1px;top: 50%;left: 100%;}' | ||
].join('\n'); | ||
var direction = d3_tip_direction, | ||
offset = d3_tip_offset, | ||
html = d3_tip_html, | ||
node = initNode(), | ||
svg = null, | ||
point = null, | ||
target = null, | ||
parent = null, | ||
style = defaultTipStyle; | ||
offset = d3_tip_offset, | ||
html = d3_tip_html, | ||
classed = 'd3-tip', | ||
node = initNode(), | ||
svg = null, | ||
point = null, | ||
target = null, | ||
parent = null, | ||
style = defaultTipStyle; | ||
function initNode() { | ||
var node = d3Selection.select(document.createElement('div')); | ||
node.style('position', 'absolute').style('top', 0).style('left', 0).style('opacity', 0).style('pointer-events', 'none').style('box-sizing', 'border-box'); | ||
return node.node(); | ||
var node = select(document.createElement('div')) | ||
node | ||
.attr('id', id) | ||
.classed(classed, true) | ||
.style('position','absolute') | ||
.style('top', 0) | ||
.style('left', 0) | ||
.style('opacity', 0) | ||
.style('pointer-events', 'none') | ||
.style('box-sizing', 'border-box'); | ||
return node.node() | ||
} | ||
function getSVGNode(el) { | ||
el = el.node(); | ||
if (!el) return; | ||
el = el.node() | ||
if(!el) return; | ||
return el.tagName.toLowerCase() === 'svg' ? el : el.ownerSVGElement; | ||
@@ -49,3 +915,3 @@ } | ||
function getNodeEl() { | ||
if (node === null) { | ||
if(node === null) { | ||
node = initNode(); | ||
@@ -55,13 +921,13 @@ // re-add node to DOM | ||
} | ||
return d3Selection.select(node); | ||
return select(node); | ||
} | ||
function _impl(vis) { | ||
svg = getSVGNode(vis); | ||
if (!svg) return; | ||
point = svg.createSVGPoint(); | ||
svg = d3Selection.select(svg); | ||
svg.append('defs'); | ||
svg = getSVGNode(vis) | ||
if(!svg) return; | ||
point = svg.createSVGPoint() | ||
svg = select(svg) | ||
svg.append('defs') | ||
var defsEl = svg.select('defs'); | ||
var styleEl = defsEl.selectAll('style').data(style ? [style] : []); | ||
var styleEl = defsEl.selectAll('style').data(style ? [ style ] : []); | ||
styleEl.exit().remove(); | ||
@@ -72,29 +938,42 @@ styleEl = styleEl.enter().append('style').attr('type', 'text/css').merge(styleEl); | ||
_impl.self = function() { return 'g' + (id ? '#' + id : '.' + classed); } | ||
_impl.id = function() { return id; }; | ||
_impl.classed = function(_) { | ||
return arguments.length ? (classed = _, _impl) : classed; | ||
}; | ||
// Public - show the tooltip on the screen | ||
// | ||
// Returns a tip | ||
_impl.show = function () { | ||
if (!parent) _impl.parent(document.body); | ||
_impl.show = function() { | ||
if(!parent) _impl.parent(document.body); | ||
var args = [].slice.call(arguments); | ||
if (args[args.length - 1] instanceof SVGElement) { | ||
target = args.pop(); | ||
target = this; | ||
if(args.length === 1 && IsDOMElement(args[0])){ | ||
target = args[0]; | ||
args[0] = target.__data__; | ||
} | ||
var content = html.apply(this, args), | ||
poffset = offset.apply(this, args), | ||
dir = direction.apply(this, args), | ||
nodel = getNodeEl(), | ||
i = directions.length, | ||
var content = html.apply(target, args), | ||
poffset = offset.apply(target, args), | ||
dir = direction.apply(target, args), | ||
nodel = getNodeEl(), | ||
i = directions.length, | ||
coords, | ||
parentCoords = node.offsetParent.getBoundingClientRect(); | ||
nodel.html(content).style('opacity', 1).style('pointer-events', 'all'); | ||
nodel.html(content) | ||
.style('opacity', 1) | ||
.style('pointer-events', 'all') | ||
while (i--) { | ||
nodel.classed(directions[i], false); | ||
}coords = direction_callbacks[dir].apply(this); | ||
nodel.classed(dir, true).style('top', coords.top + poffset[0] - parentCoords.top + 'px').style('left', coords.left + poffset[1] - parentCoords.left + 'px'); | ||
while(i--) nodel.classed(directions[i], false) | ||
coords = direction_callbacks[dir].apply(target) | ||
nodel.classed(dir, true) | ||
.style('top', (coords.top + poffset[0]) - parentCoords.top + 'px') | ||
.style('left', (coords.left + poffset[1]) - parentCoords.left + 'px') | ||
return _impl; | ||
}; | ||
} | ||
@@ -104,7 +983,8 @@ // Public - hide the tooltip | ||
// Returns a tip | ||
_impl.hide = function () { | ||
var nodel = getNodeEl(); | ||
nodel.style('opacity', 0).style('pointer-events', 'none'); | ||
_impl.hide = function() { | ||
var nodel = getNodeEl() | ||
nodel.style('opacity', 0) | ||
.style('pointer-events', 'none') | ||
return _impl; | ||
}; | ||
} | ||
@@ -117,30 +997,13 @@ // Public: Proxy attr calls to the d3 tip container. Sets or gets attribute value. | ||
// Returns tip or attribute value | ||
_impl.attr = function (n) { | ||
_impl.attr = function(n) { | ||
if (arguments.length < 2 && typeof n === 'string') { | ||
return getNodeEl().attr(n); | ||
return getNodeEl().attr(n) | ||
} else { | ||
var args = [].slice.call(arguments); | ||
d3Selection.selection.prototype.attr.apply(getNodeEl(), args); | ||
var args = [].slice.call(arguments) | ||
selection.prototype.attr.apply(getNodeEl(), args) | ||
} | ||
return _impl; | ||
}; | ||
} | ||
// Public: Proxy style calls to the d3 tip container. Sets or gets a style value. | ||
// | ||
// n - name of the property | ||
// v - value of the property | ||
// | ||
// Returns tip or style property value | ||
_impl.style = function (n) { | ||
if (arguments.length < 2 && typeof n === 'string') { | ||
return getNodeEl().style(n); | ||
} else { | ||
var args = [].slice.call(arguments); | ||
d3Selection.selection.prototype.style.apply(getNodeEl(), args); | ||
} | ||
return _impl; | ||
}; | ||
// Public: Set or get the direction of the tooltip | ||
@@ -152,8 +1015,8 @@ // | ||
// Returns tip or direction | ||
_impl.direction = function (v) { | ||
if (!arguments.length) return direction; | ||
direction = v == null ? v : d3_tip_functor(v); | ||
_impl.direction = function(v) { | ||
if (!arguments.length) return direction | ||
direction = v == null ? v : d3_tip_functor(v) | ||
return _impl; | ||
}; | ||
} | ||
@@ -165,8 +1028,8 @@ // Public: Sets or gets the offset of the tip | ||
// Returns offset or | ||
_impl.offset = function (v) { | ||
if (!arguments.length) return offset; | ||
offset = v == null ? v : d3_tip_functor(v); | ||
_impl.offset = function(v) { | ||
if (!arguments.length) return offset | ||
offset = v == null ? v : d3_tip_functor(v) | ||
return _impl; | ||
}; | ||
} | ||
@@ -178,8 +1041,8 @@ // Public: sets or gets the html value of the tooltip | ||
// Returns html value or tip | ||
_impl.html = function (v) { | ||
if (!arguments.length) return html; | ||
html = v == null ? v : d3_tip_functor(v); | ||
_impl.html = function(v) { | ||
if (!arguments.length) return html | ||
html = v == null ? v : d3_tip_functor(v) | ||
return _impl; | ||
}; | ||
} | ||
@@ -189,4 +1052,4 @@ // Public: destroys the tooltip and removes it from the DOM | ||
// Returns a tip | ||
_impl.destroy = function () { | ||
if (node) { | ||
_impl.destroy = function() { | ||
if(node) { | ||
getNodeEl().remove(); | ||
@@ -196,9 +1059,9 @@ node = null; | ||
return _impl; | ||
}; | ||
} | ||
_impl.style = function (value) { | ||
return arguments.length ? (style = defaultTipStyle + value, _impl) : style; | ||
}; | ||
_impl.style = function(_) { | ||
return arguments.length ? (style = _, _impl) : style; | ||
} | ||
_impl.parent = function (v) { | ||
_impl.parent = function(v) { | ||
if (!arguments.length) return parent; | ||
@@ -210,72 +1073,73 @@ parent = v || document.body; | ||
// based from it. Mainly a concern with <body>. | ||
var offsetParent = d3Selection.select(node.offsetParent); | ||
var offsetParent = select(node.offsetParent) | ||
if (offsetParent.style('position') === 'static') { | ||
offsetParent.style('position', 'relative'); | ||
offsetParent.style('position', 'relative') | ||
} | ||
return _impl; | ||
}; | ||
} | ||
function direction_n() { | ||
var bbox = getScreenBBox(); | ||
var bbox = getScreenBBox() | ||
return { | ||
top: bbox.n.y - node.offsetHeight, | ||
top: bbox.n.y - node.offsetHeight, | ||
left: bbox.n.x - node.offsetWidth / 2 | ||
}; | ||
} | ||
} | ||
function direction_s() { | ||
var bbox = getScreenBBox(); | ||
var bbox = getScreenBBox() | ||
return { | ||
top: bbox.s.y, | ||
top: bbox.s.y, | ||
left: bbox.s.x - node.offsetWidth / 2 | ||
}; | ||
} | ||
} | ||
function direction_e() { | ||
var bbox = getScreenBBox(); | ||
var bbox = getScreenBBox() | ||
return { | ||
top: bbox.e.y - node.offsetHeight / 2, | ||
top: bbox.e.y - node.offsetHeight / 2, | ||
left: bbox.e.x | ||
}; | ||
} | ||
} | ||
function direction_w() { | ||
var bbox = getScreenBBox(); | ||
var bbox = getScreenBBox() | ||
return { | ||
top: bbox.w.y - node.offsetHeight / 2, | ||
top: bbox.w.y - node.offsetHeight / 2, | ||
left: bbox.w.x - node.offsetWidth | ||
}; | ||
} | ||
} | ||
function direction_nw() { | ||
var bbox = getScreenBBox(); | ||
var bbox = getScreenBBox() | ||
return { | ||
top: bbox.nw.y - node.offsetHeight, | ||
top: bbox.nw.y - node.offsetHeight, | ||
left: bbox.nw.x - node.offsetWidth | ||
}; | ||
} | ||
} | ||
function direction_ne() { | ||
var bbox = getScreenBBox(); | ||
var bbox = getScreenBBox() | ||
return { | ||
top: bbox.ne.y - node.offsetHeight, | ||
top: bbox.ne.y - node.offsetHeight, | ||
left: bbox.ne.x | ||
}; | ||
} | ||
} | ||
function direction_sw() { | ||
var bbox = getScreenBBox(); | ||
var bbox = getScreenBBox() | ||
return { | ||
top: bbox.sw.y, | ||
top: bbox.sw.y, | ||
left: bbox.sw.x - node.offsetWidth | ||
}; | ||
} | ||
} | ||
function direction_se() { | ||
var bbox = getScreenBBox(); | ||
var bbox = getScreenBBox() | ||
return { | ||
top: bbox.se.y, | ||
top: bbox.se.y, | ||
left: bbox.se.x | ||
}; | ||
} | ||
} | ||
@@ -297,34 +1161,34 @@ | ||
function getScreenBBox() { | ||
var targetel = target || d3Selection.event.target; | ||
var targetel = target || event.target; | ||
while ('undefined' === typeof targetel.getScreenCTM && 'undefined' === targetel.parentNode) { | ||
targetel = targetel.parentNode; | ||
targetel = targetel.parentNode; | ||
} | ||
var bbox = {}, | ||
matrix = targetel.getScreenCTM(), | ||
tbbox = targetel.getBBox(), | ||
width = tbbox.width, | ||
height = tbbox.height, | ||
x = tbbox.x, | ||
y = tbbox.y; | ||
var bbox = {}, | ||
matrix = targetel.getScreenCTM(), | ||
tbbox = targetel.getBBox(), | ||
width = tbbox.width, | ||
height = tbbox.height, | ||
x = tbbox.x, | ||
y = tbbox.y | ||
point.x = x; | ||
point.y = y; | ||
bbox.nw = point.matrixTransform(matrix); | ||
point.x += width; | ||
bbox.ne = point.matrixTransform(matrix); | ||
point.y += height; | ||
bbox.se = point.matrixTransform(matrix); | ||
point.x -= width; | ||
bbox.sw = point.matrixTransform(matrix); | ||
point.y -= height / 2; | ||
bbox.w = point.matrixTransform(matrix); | ||
point.x += width; | ||
bbox.e = point.matrixTransform(matrix); | ||
point.x -= width / 2; | ||
point.y -= height / 2; | ||
bbox.n = point.matrixTransform(matrix); | ||
point.y += height; | ||
bbox.s = point.matrixTransform(matrix); | ||
point.x = x | ||
point.y = y | ||
bbox.nw = point.matrixTransform(matrix) | ||
point.x += width | ||
bbox.ne = point.matrixTransform(matrix) | ||
point.y += height | ||
bbox.se = point.matrixTransform(matrix) | ||
point.x -= width | ||
bbox.sw = point.matrixTransform(matrix) | ||
point.y -= height / 2 | ||
bbox.w = point.matrixTransform(matrix) | ||
point.x += width | ||
bbox.e = point.matrixTransform(matrix) | ||
point.x -= width / 2 | ||
point.y -= height / 2 | ||
bbox.n = point.matrixTransform(matrix) | ||
point.y += height | ||
bbox.s = point.matrixTransform(matrix) | ||
@@ -335,6 +1199,6 @@ return bbox; | ||
var direction_callbacks = { | ||
n: direction_n, | ||
s: direction_s, | ||
e: direction_e, | ||
w: direction_w, | ||
n: direction_n, | ||
s: direction_s, | ||
e: direction_e, | ||
w: direction_w, | ||
nw: direction_nw, | ||
@@ -345,3 +1209,3 @@ ne: direction_ne, | ||
}, | ||
directions = Object.keys(direction_callbacks); | ||
directions = Object.keys(direction_callbacks); | ||
@@ -348,0 +1212,0 @@ return _impl; |
@@ -1,2 +0,2 @@ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("d3-selection")):"function"==typeof define&&define.amd?define(["exports","d3-selection"],e):e(t.d3_rs_tip=t.d3_rs_tip||{},t.d3)}(this,function(t,e){"use strict";function n(){function t(){var t=e.select(document.createElement("div"));return t.style("position","absolute").style("top",0).style("left",0).style("opacity",0).style("pointer-events","none").style("box-sizing","border-box"),t.node()}function n(t){return(t=t.node())?"svg"===t.tagName.toLowerCase()?t:t.ownerSVGElement:void 0}function r(){return null===T&&(T=t(),_.appendChild(T)),e.select(T)}function o(t){if(C=n(t)){S=C.createSVGPoint(),C=e.select(C),C.append("defs");var r=C.select("defs"),o=r.selectAll("style").data(B?[B]:[]);o.exit().remove(),o=o.enter().append("style").attr("type","text/css").merge(o),o.text(B)}}function i(){var t=d();return{top:t.n.y-T.offsetHeight,left:t.n.x-T.offsetWidth/2}}function l(){var t=d();return{top:t.s.y,left:t.s.x-T.offsetWidth/2}}function s(){var t=d();return{top:t.e.y-T.offsetHeight/2,left:t.e.x}}function f(){var t=d();return{top:t.w.y-T.offsetHeight/2,left:t.w.x-T.offsetWidth}}function a(){var t=d();return{top:t.nw.y-T.offsetHeight,left:t.nw.x-T.offsetWidth}}function p(){var t=d();return{top:t.ne.y-T.offsetHeight,left:t.ne.x}}function u(){var t=d();return{top:t.sw.y,left:t.sw.x-T.offsetWidth}}function c(){var t=d();return{top:t.se.y,left:t.se.x}}function d(){for(var t=W||e.event.target;"undefined"==typeof t.getScreenCTM&&"undefined"===t.parentNode;)t=t.parentNode;var n={},r=t.getScreenCTM(),o=t.getBBox(),i=o.width,l=o.height,s=o.x,f=o.y;return S.x=s,S.y=f,n.nw=S.matrixTransform(r),S.x+=i,n.ne=S.matrixTransform(r),S.y+=l,n.se=S.matrixTransform(r),S.x-=i,n.sw=S.matrixTransform(r),S.y-=l/2,n.w=S.matrixTransform(r),S.x+=i,n.e=S.matrixTransform(r),S.x-=i/2,S.y-=l/2,n.n=S.matrixTransform(r),S.y+=l,n.s=S.matrixTransform(r),n}var y=function(t){return"function"==typeof t?t:function(){return t}},x=function(){return"n"},g=function(){return[0,0]},h=function(){return" "},m=[".d3-tip {line-height: 1;font-weight: bold;padding: 12px;background: rgba(0, 0, 0, 0.8);color: #fff;border-radius: 2px;pointer-events: none;}","/* Creates a small triangle extender for the tooltip */",".d3-tip:after {box-sizing: border-box;display: inline;font-size: 10px;width: 100%;line-height: 1;color: rgba(0, 0, 0, 0.8);position: absolute;pointer-events: none;}","/* Northward tooltips */",'.d3-tip.n:after {content: "\\25bc";margin: -1px 0 0 0;top: 100%;left: 0;text-align: center;}',"/* Eastward tooltips */",'.d3-tip.e:after {content: "\\25C0";margin: -4px 0 0 0;top: 50%;left: -8px;}',"/* Southward tooltips */",'.d3-tip.s:after {content: "\\25B2";margin: 0 0 1px 0;top: -7px;left: 0;text-align: center;}',"/* Westward tooltips */",'.d3-tip.w:after {content: "\\25B6";margin: -4px 0 0 -1px;top: 50%;left: 100%;}'].join("\n"),v=x,w=g,b=h,T=t(),C=null,S=null,W=null,_=null,B=m;o.show=function(){_||o.parent(document.body);var t=[].slice.call(arguments);t[t.length-1]instanceof SVGElement&&(W=t.pop());var e,n=b.apply(this,t),i=w.apply(this,t),l=v.apply(this,t),s=r(),f=j.length,a=T.offsetParent.getBoundingClientRect();for(s.html(n).style("opacity",1).style("pointer-events","all");f--;)s.classed(j[f],!1);return e=H[l].apply(this),s.classed(l,!0).style("top",e.top+i[0]-a.top+"px").style("left",e.left+i[1]-a.left+"px"),o},o.hide=function(){var t=r();return t.style("opacity",0).style("pointer-events","none"),o},o.attr=function(t){if(arguments.length<2&&"string"==typeof t)return r().attr(t);var n=[].slice.call(arguments);return e.selection.prototype.attr.apply(r(),n),o},o.style=function(t){if(arguments.length<2&&"string"==typeof t)return r().style(t);var n=[].slice.call(arguments);return e.selection.prototype.style.apply(r(),n),o},o.direction=function(t){return arguments.length?(v=null==t?t:y(t),o):v},o.offset=function(t){return arguments.length?(w=null==t?t:y(t),o):w},o.html=function(t){return arguments.length?(b=null==t?t:y(t),o):b},o.destroy=function(){return T&&(r().remove(),T=null),o},o.style=function(t){return arguments.length?(B=m+t,o):B},o.parent=function(t){if(!arguments.length)return _;_=t||document.body,_.appendChild(T);var n=e.select(T.offsetParent);return"static"===n.style("position")&&n.style("position","relative"),o};var H={n:i,s:l,e:s,w:f,nw:a,ne:p,sw:u,se:c},j=Object.keys(H);return o}var r="0.2.1";t.version=r,t.tip=n,Object.defineProperty(t,"__esModule",{value:!0})}); | ||
!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n(t.d3_rs_tip=t.d3_rs_tip||{})}(this,function(t){"use strict";function n(t){var n=t+="",e=n.indexOf(":");return e>=0&&"xmlns"!==(n=t.slice(0,e))&&(t=t.slice(e+1)),Ht.hasOwnProperty(n)?{space:Ht[n],local:t}:t}function e(t){return function(){var n=this.ownerDocument,e=this.namespaceURI;return e===Lt&&n.documentElement.namespaceURI===Lt?n.createElement(t):n.createElementNS(e,t)}}function r(t){return function(){return this.ownerDocument.createElementNS(t.space,t.local)}}function i(t){var i=n(t);return(i.local?r:e)(i)}function o(t,n,e){return t=u(t,n,e),function(n){var e=n.relatedTarget;e&&(e===this||8&e.compareDocumentPosition(this))||t.call(this,n)}}function u(t,n,e){return function(r){var i=Wt;Wt=r;try{t.call(this,this.__data__,n,e)}finally{Wt=i}}}function s(t){return t.trim().split(/^|\s+/).map(function(t){var n="",e=t.indexOf(".");return e>=0&&(n=t.slice(e+1),t=t.slice(0,e)),{type:t,name:n}})}function a(t){return function(){var n=this,e=this.__on;if(e){for(var r,i=0,o=-1,u=e.length;u>i;++i)r=e[i],t.type&&r.type!==t.type||r.name!==t.name?e[++o]=r:n.removeEventListener(r.type,r.listener,r.capture);++o?e.length=o:delete this.__on}}}function l(t,n,e){var r=jt.hasOwnProperty(t.type)?o:u;return function(i,o,u){var s,a=this,l=this.__on,f=r(n,o,u);if(l)for(var c=0,h=l.length;h>c;++c)if((s=l[c]).type===t.type&&s.name===t.name)return a.removeEventListener(s.type,s.listener,s.capture),a.addEventListener(s.type,s.listener=f,s.capture=e),void(s.value=n);this.addEventListener(t.type,f,e),s={type:t.type,name:t.name,value:n,listener:f,capture:e},l?l.push(s):this.__on=[s]}}function f(t,n,e){var r,i,o=this,u=s(t+""),f=u.length;if(!(arguments.length<2)){for(c=n?l:a,null==e&&(e=!1),r=0;f>r;++r)o.each(c(u[r],n,e));return this}var c=this.node().__on;if(c)for(var h,p=0,d=c.length;d>p;++p)for(r=0,h=c[p];f>r;++r)if((i=u[r]).type===h.type&&i.name===h.name)return h.value}function c(t){return function(){return this.querySelector(t)}}function h(t){"function"!=typeof t&&(t=c(t));for(var n=this._groups,e=n.length,r=new Array(e),i=0;e>i;++i)for(var o,u,s=n[i],a=s.length,l=r[i]=new Array(a),f=0;a>f;++f)(o=s[f])&&(u=t.call(o,o.__data__,f,s))&&("__data__"in o&&(u.__data__=o.__data__),l[f]=u);return new Nt(r,this._parents)}function p(t){return function(){return this.querySelectorAll(t)}}function d(t){"function"!=typeof t&&(t=p(t));for(var n=this._groups,e=n.length,r=[],i=[],o=0;e>o;++o)for(var u,s=n[o],a=s.length,l=0;a>l;++l)(u=s[l])&&(r.push(t.call(u,u.__data__,l,s)),i.push(u));return new Nt(r,i)}function y(t){"function"!=typeof t&&(t=Dt(t));for(var n=this._groups,e=n.length,r=new Array(e),i=0;e>i;++i)for(var o,u=n[i],s=u.length,a=r[i]=new Array(s),l=0;s>l;++l)(o=u[l])&&t.call(o,o.__data__,l,u)&&(a[l]=o);return new Nt(r,this._parents)}function _(t){return function(){return t}}function v(t,n,e,r,i,o){for(var u,s=0,a=n.length,l=o.length;l>s;++s)(u=n[s])?(u.__data__=o[s],r[s]=u):e[s]=new w(t,o[s]);for(;a>s;++s)(u=n[s])&&(i[s]=u)}function m(t,n,e,r,i,o,u){var s,a,l,f={},c=n.length,h=o.length,p=new Array(c);for(s=0;c>s;++s)(a=n[s])&&(p[s]=l=Rt+u.call(a,a.__data__,s,n),l in f?i[s]=a:f[l]=a);for(s=0;h>s;++s)l=Rt+u.call(t,o[s],s,o),(a=f[l])?(r[s]=a,a.__data__=o[s],f[l]=null):e[s]=new w(t,o[s]);for(s=0;c>s;++s)(a=n[s])&&f[p[s]]===a&&(i[s]=a)}function g(t,n){if(!t)return p=new Array(this.size()),l=-1,this.each(function(t){p[++l]=t}),p;var e=n?m:v,r=this._parents,i=this._groups;"function"!=typeof t&&(t=_(t));for(var o=i.length,u=new Array(o),s=new Array(o),a=new Array(o),l=0;o>l;++l){var f=r[l],c=i[l],h=c.length,p=t.call(f,f&&f.__data__,l,r),d=p.length,y=s[l]=new Array(d),g=u[l]=new Array(d),w=a[l]=new Array(h);e(f,c,y,g,w,p,n);for(var x,b,A=0,S=0;d>A;++A)if(x=y[A]){for(A>=S&&(S=A+1);!(b=g[S])&&++S<d;);x._next=b||null}}return u=new Nt(u,r),u._enter=s,u._exit=a,u}function w(t,n){this.ownerDocument=t.ownerDocument,this.namespaceURI=t.namespaceURI,this._next=null,this._parent=t,this.__data__=n}function x(t){return new Array(t.length)}function b(){return new Nt(this._enter||this._groups.map(x),this._parents)}function A(){return new Nt(this._exit||this._groups.map(x),this._parents)}function S(t){for(var n=this._groups,e=t._groups,r=n.length,i=e.length,o=Math.min(r,i),u=new Array(r),s=0;o>s;++s)for(var a,l=n[s],f=e[s],c=l.length,h=u[s]=new Array(c),p=0;c>p;++p)(a=l[p]||f[p])&&(h[p]=a);for(;r>s;++s)u[s]=n[s];return new Nt(u,this._parents)}function E(){for(var t=this._groups,n=-1,e=t.length;++n<e;)for(var r,i=t[n],o=i.length-1,u=i[o];--o>=0;)(r=i[o])&&(u&&u!==r.nextSibling&&u.parentNode.insertBefore(r,u),u=r);return this}function C(t){function n(n,e){return n&&e?t(n.__data__,e.__data__):!n-!e}t||(t=N);for(var e=this._groups,r=e.length,i=new Array(r),o=0;r>o;++o){for(var u,s=e[o],a=s.length,l=i[o]=new Array(a),f=0;a>f;++f)(u=s[f])&&(l[f]=u);l.sort(n)}return new Nt(i,this._parents).order()}function N(t,n){return n>t?-1:t>n?1:t>=n?0:NaN}function T(){var t=arguments[0];return arguments[0]=this,t.apply(null,arguments),this}function M(){var t=new Array(this.size()),n=-1;return this.each(function(){t[++n]=this}),t}function P(){for(var t=this._groups,n=0,e=t.length;e>n;++n)for(var r=t[n],i=0,o=r.length;o>i;++i){var u=r[i];if(u)return u}return null}function B(){var t=0;return this.each(function(){++t}),t}function L(){return!this.node()}function H(t){for(var n=this._groups,e=0,r=n.length;r>e;++e)for(var i,o=n[e],u=0,s=o.length;s>u;++u)(i=o[u])&&t.call(i,i.__data__,u,o);return this}function O(t){return function(){this.removeAttribute(t)}}function q(t){return function(){this.removeAttributeNS(t.space,t.local)}}function z(t,n){return function(){this.setAttribute(t,n)}}function D(t,n){return function(){this.setAttributeNS(t.space,t.local,n)}}function j(t,n){return function(){var e=n.apply(this,arguments);null==e?this.removeAttribute(t):this.setAttribute(t,e)}}function W(t,n){return function(){var e=n.apply(this,arguments);null==e?this.removeAttributeNS(t.space,t.local):this.setAttributeNS(t.space,t.local,e)}}function k(t,e){var r=n(t);if(arguments.length<2){var i=this.node();return r.local?i.getAttributeNS(r.space,r.local):i.getAttribute(r)}return this.each((null==e?r.local?q:O:"function"==typeof e?r.local?W:j:r.local?D:z)(r,e))}function R(t){return t.ownerDocument&&t.ownerDocument.defaultView||t.document&&t||t.defaultView}function V(t){return function(){this.style.removeProperty(t)}}function I(t,n,e){return function(){this.style.setProperty(t,n,e)}}function U(t,n,e){return function(){var r=n.apply(this,arguments);null==r?this.style.removeProperty(t):this.style.setProperty(t,r,e)}}function G(t,n,e){var r;return arguments.length>1?this.each((null==n?V:"function"==typeof n?U:I)(t,n,null==e?"":e)):R(r=this.node()).getComputedStyle(r,null).getPropertyValue(t)}function X(t){return function(){delete this[t]}}function $(t,n){return function(){this[t]=n}}function F(t,n){return function(){var e=n.apply(this,arguments);null==e?delete this[t]:this[t]=e}}function J(t,n){return arguments.length>1?this.each((null==n?X:"function"==typeof n?F:$)(t,n)):this.node()[t]}function K(t){return t.trim().split(/^|\s+/)}function Q(t){return t.classList||new Y(t)}function Y(t){this._node=t,this._names=K(t.getAttribute("class")||"")}function Z(t,n){for(var e=Q(t),r=-1,i=n.length;++r<i;)e.add(n[r])}function tt(t,n){for(var e=Q(t),r=-1,i=n.length;++r<i;)e.remove(n[r])}function nt(t){return function(){Z(this,t)}}function et(t){return function(){tt(this,t)}}function rt(t,n){return function(){(n.apply(this,arguments)?Z:tt)(this,t)}}function it(t,n){var e=K(t+"");if(arguments.length<2){for(var r=Q(this.node()),i=-1,o=e.length;++i<o;)if(!r.contains(e[i]))return!1;return!0}return this.each(("function"==typeof n?rt:n?nt:et)(e,n))}function ot(){this.textContent=""}function ut(t){return function(){this.textContent=t}}function st(t){return function(){var n=t.apply(this,arguments);this.textContent=null==n?"":n}}function at(t){return arguments.length?this.each(null==t?ot:("function"==typeof t?st:ut)(t)):this.node().textContent}function lt(){this.innerHTML=""}function ft(t){return function(){this.innerHTML=t}}function ct(t){return function(){var n=t.apply(this,arguments);this.innerHTML=null==n?"":n}}function ht(t){return arguments.length?this.each(null==t?lt:("function"==typeof t?ct:ft)(t)):this.node().innerHTML}function pt(){this.nextSibling&&this.parentNode.appendChild(this)}function dt(){return this.each(pt)}function yt(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function _t(){return this.each(yt)}function vt(t){var n="function"==typeof t?t:i(t);return this.select(function(){return this.appendChild(n.apply(this,arguments))})}function mt(){return null}function gt(t,n){var e="function"==typeof t?t:i(t),r=null==n?mt:"function"==typeof n?n:c(n);return this.select(function(){return this.insertBefore(e.apply(this,arguments),r.apply(this,arguments)||null)})}function wt(){var t=this.parentNode;t&&t.removeChild(this)}function xt(){return this.each(wt)}function bt(t){return arguments.length?this.property("__data__",t):this.node().__data__}function At(t,n,e){var r=R(t),i=r.CustomEvent;i?i=new i(n,e):(i=r.document.createEvent("Event"),e?(i.initEvent(n,e.bubbles,e.cancelable),i.detail=e.detail):i.initEvent(n,!1,!1)),t.dispatchEvent(i)}function St(t,n){return function(){return At(this,t,n)}}function Et(t,n){return function(){return At(this,t,n.apply(this,arguments))}}function Ct(t,n){return this.each(("function"==typeof n?Et:St)(t,n))}function Nt(t,n){this._groups=t,this._parents=n}function Tt(){return new Nt([[document.documentElement]],Vt)}function Mt(t){return"string"==typeof t?new Nt([[document.querySelector(t)]],[document.documentElement]):new Nt([[t]],Vt)}function Pt(t){function n(){var n=Mt(document.createElement("div"));return n.attr("id",t).classed(A,!0).style("position","absolute").style("top",0).style("left",0).style("opacity",0).style("pointer-events","none").style("box-sizing","border-box"),n.node()}function e(t){return(t=t.node())?"svg"===t.tagName.toLowerCase()?t:t.ownerSVGElement:void 0}function r(){return null===S&&(S=n(),T.appendChild(S)),Mt(S)}function i(t){if(E=e(t)){C=E.createSVGPoint(),E=Mt(E),E.append("defs");var n=E.select("defs"),r=n.selectAll("style").data(M?[M]:[]);r.exit().remove(),r=r.enter().append("style").attr("type","text/css").merge(r),r.text(M)}}function o(){var t=p();return{top:t.n.y-S.offsetHeight,left:t.n.x-S.offsetWidth/2}}function u(){var t=p();return{top:t.s.y,left:t.s.x-S.offsetWidth/2}}function s(){var t=p();return{top:t.e.y-S.offsetHeight/2,left:t.e.x}}function a(){var t=p();return{top:t.w.y-S.offsetHeight/2,left:t.w.x-S.offsetWidth}}function l(){var t=p();return{top:t.nw.y-S.offsetHeight,left:t.nw.x-S.offsetWidth}}function f(){var t=p();return{top:t.ne.y-S.offsetHeight,left:t.ne.x}}function c(){var t=p();return{top:t.sw.y,left:t.sw.x-S.offsetWidth}}function h(){var t=p();return{top:t.se.y,left:t.se.x}}function p(){for(var t=N||Wt.target;"undefined"==typeof t.getScreenCTM&&"undefined"===t.parentNode;)t=t.parentNode;var n={},e=t.getScreenCTM(),r=t.getBBox(),i=r.width,o=r.height,u=r.x,s=r.y;return C.x=u,C.y=s,n.nw=C.matrixTransform(e),C.x+=i,n.ne=C.matrixTransform(e),C.y+=o,n.se=C.matrixTransform(e),C.x-=i,n.sw=C.matrixTransform(e),C.y-=o/2,n.w=C.matrixTransform(e),C.x+=i,n.e=C.matrixTransform(e),C.x-=i/2,C.y-=o/2,n.n=C.matrixTransform(e),C.y+=o,n.s=C.matrixTransform(e),n}var d=function(t){return"function"==typeof t?t:function(){return t}},y=function(){return"n"},_=function(){return[0,0]},v=function(){return" "},m=function(t){return t instanceof Node},g=[".d3-tip {line-height: 1;font-weight: bold;padding: 12px;background: rgba(0, 0, 0, 0.8);color: #fff;border-radius: 2px;pointer-events: none;}","/* Creates a small triangle extender for the tooltip */",".d3-tip:after {box-sizing: border-box;display: inline;font-size: 10px;width: 100%;line-height: 1;color: rgba(0, 0, 0, 0.8);position: absolute;pointer-events: none;}","/* Northward tooltips */",'.d3-tip.n:after {content: "\\25bc";margin: -1px 0 0 0;top: 100%;left: 0;text-align: center;}',"/* Eastward tooltips */",'.d3-tip.e:after {content: "\\25C0";margin: -4px 0 0 0;top: 50%;left: -8px;}',"/* Southward tooltips */",'.d3-tip.s:after {content: "\\25B2";margin: 0 0 1px 0;top: -7px;left: 0;text-align: center;}',"/* Westward tooltips */",'.d3-tip.w:after {content: "\\25B6";margin: -4px 0 0 -1px;top: 50%;left: 100%;}'].join("\n"),w=y,x=_,b=v,A="d3-tip",S=n(),E=null,C=null,N=null,T=null,M=g;i.self=function(){return"g"+(t?"#"+t:"."+A)},i.id=function(){return t},i.classed=function(t){return arguments.length?(A=t,i):A},i.show=function(){T||i.parent(document.body);var t=[].slice.call(arguments);N=this,1===t.length&&m(t[0])&&(N=t[0],t[0]=N.__data__);var n,e=b.apply(N,t),o=x.apply(N,t),u=w.apply(N,t),s=r(),a=B.length,l=S.offsetParent.getBoundingClientRect();for(s.html(e).style("opacity",1).style("pointer-events","all");a--;)s.classed(B[a],!1);return n=P[u].apply(N),s.classed(u,!0).style("top",n.top+o[0]-l.top+"px").style("left",n.left+o[1]-l.left+"px"),i},i.hide=function(){var t=r();return t.style("opacity",0).style("pointer-events","none"),i},i.attr=function(t){if(arguments.length<2&&"string"==typeof t)return r().attr(t);var n=[].slice.call(arguments);return Tt.prototype.attr.apply(r(),n),i},i.direction=function(t){return arguments.length?(w=null==t?t:d(t),i):w},i.offset=function(t){return arguments.length?(x=null==t?t:d(t),i):x},i.html=function(t){return arguments.length?(b=null==t?t:d(t),i):b},i.destroy=function(){return S&&(r().remove(),S=null),i},i.style=function(t){return arguments.length?(M=t,i):M},i.parent=function(t){if(!arguments.length)return T;T=t||document.body,T.appendChild(S);var n=Mt(S.offsetParent);return"static"===n.style("position")&&n.style("position","relative"),i};var P={n:o,s:u,e:s,w:a,nw:l,ne:f,sw:c,se:h},B=Object.keys(P);return i}var Bt="0.2.2",Lt="http://www.w3.org/1999/xhtml",Ht={svg:"http://www.w3.org/2000/svg",xhtml:Lt,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"},Ot=function(t){return function(){return this.matches(t)}};if("undefined"!=typeof document){var qt=document.documentElement;if(!qt.matches){var zt=qt.webkitMatchesSelector||qt.msMatchesSelector||qt.mozMatchesSelector||qt.oMatchesSelector;Ot=function(t){return function(){return zt.call(this,t)}}}}var Dt=Ot,jt={},Wt=null;if("undefined"!=typeof document){var kt=document.documentElement;"onmouseenter"in kt||(jt={mouseenter:"mouseover",mouseleave:"mouseout"})}var Rt="$";w.prototype={constructor:w,appendChild:function(t){return this._parent.insertBefore(t,this._next)},insertBefore:function(t,n){return this._parent.insertBefore(t,n)},querySelector:function(t){return this._parent.querySelector(t)},querySelectorAll:function(t){return this._parent.querySelectorAll(t)}},Y.prototype={add:function(t){var n=this._names.indexOf(t);0>n&&(this._names.push(t),this._node.setAttribute("class",this._names.join(" ")))},remove:function(t){var n=this._names.indexOf(t);n>=0&&(this._names.splice(n,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(t){return this._names.indexOf(t)>=0}};var Vt=[null];Nt.prototype=Tt.prototype={constructor:Nt,select:h,selectAll:d,filter:y,data:g,enter:b,exit:A,merge:S,order:E,sort:C,call:T,nodes:M,node:P,size:B,empty:L,each:H,attr:k,style:G,property:J,classed:it,text:at,html:ht,raise:dt,lower:_t,append:vt,insert:gt,remove:xt,datum:bt,on:f,dispatch:Ct},t.version=Bt,t.tip=Pt,Object.defineProperty(t,"__esModule",{value:!0})}); | ||
//# sourceMappingURL=d3-rs-tip.umd-es2015.min.js.map |
@@ -15,4 +15,5 @@ 'use strict'; | ||
var browserSync = require('browser-sync').create(); | ||
var babel = require('rollup-plugin-babel'); | ||
var includes = require('rollup-plugin-includepaths'); | ||
var buble = require('rollup-plugin-buble'); | ||
var commonjs = require('rollup-plugin-commonjs'); | ||
var nodeResolve = require('rollup-plugin-node-resolve'); | ||
var sourcemaps = require('gulp-sourcemaps'); | ||
@@ -50,19 +51,39 @@ var source = require('vinyl-source-stream'); | ||
return rollup({ | ||
moduleName: outputFilename.replace(/-/g, '_'), | ||
globals: globalMap, | ||
entry: './index.js', | ||
format: 'umd', | ||
sourceMap: true, | ||
plugins: [ includes({ paths: [ 'src/' ] }), babel() ] | ||
}) | ||
.pipe(source('main.js', './src')) | ||
.pipe(buffer()) | ||
.pipe(sourcemaps.init({ loadMaps: true })) | ||
.pipe(rename({basename: outputFilename})) | ||
.pipe(rename({suffix: '.umd-es2015'})) | ||
.pipe(gulp.dest('distribution/')) | ||
.pipe(uglify()) | ||
.pipe(rename({suffix: '.min'})) | ||
.pipe(sourcemaps.write('.')) | ||
.pipe(gulp.dest('distribution/')); | ||
moduleName: outputFilename.replace(/-/g, '_'), | ||
globals: globalMap, | ||
entry: 'index.js', | ||
format: 'umd', | ||
sourceMap: true, | ||
plugins: [ | ||
nodeResolve({ | ||
// use "jsnext:main" if possible | ||
// – see https://github.com/rollup/rollup/wiki/jsnext:main | ||
jsnext: true, // Default: false | ||
// use "main" field or index.js, even if it's not an ES6 module | ||
// (needs to be converted from CommonJS to ES6 | ||
// – see https://github.com/rollup/rollup-plugin-commonjs | ||
main: true, // Default: true | ||
// not all files you want to resolve are .js files | ||
extensions: [ '.js', '.json' ], // Default: ['.js'] | ||
// whether to prefer built-in modules (e.g. `fs`, `path`) or | ||
// local ones with the same names | ||
preferBuiltins: false // Default: true | ||
}), | ||
commonjs(), | ||
buble() | ||
] | ||
}) | ||
.pipe(source('main.js', './src')) | ||
.pipe(buffer()) | ||
.pipe(sourcemaps.init({ loadMaps: true })) | ||
.pipe(rename({basename: outputFilename})) | ||
.pipe(rename({suffix: '.umd-es2015'})) | ||
.pipe(gulp.dest('distribution/')) | ||
.pipe(uglify()) | ||
.pipe(rename({suffix: '.min'})) | ||
.pipe(sourcemaps.write('.')) | ||
.pipe(gulp.dest('distribution/')); | ||
}); | ||
@@ -69,0 +90,0 @@ |
export var name = "@redsift/d3-rs-tip"; | ||
export var version = "0.2.1"; | ||
export var version = "0.2.2"; | ||
export var description = "Tip for graphs using D3v4."; | ||
@@ -10,4 +10,4 @@ export var keywords = ["redsift","d3","tip"]; | ||
export var repository = {"type":"git","url":"https://github.com/redsift/d3-rs-tip.git"}; | ||
export var scripts = {"serve":"gulp -o d3-rs-tip -g d3-selection serve","build":"gulp -o d3-rs-tip -g d3-selection build","pretest":"npm outdated && npm run build","test":"tape 'test/**/*-test.js' && eslint index.js src","version":"json2module package.json > package.js","prepublish":"npm run build"}; | ||
export var scripts = {"serve":"gulp -o d3-rs-tip serve","build":"gulp -o d3-rs-tip build","pretest":"npm outdated && npm run build","test":"tape 'test/**/*-test.js' && eslint index.js src","version":"json2module package.json > package.js","prepublish":"npm run build"}; | ||
export var dependencies = {"d3-selection":"~0.8.0"}; | ||
export var devDependencies = {"@redsift/tape-reel":"~0.0.2","babel-preset-es2015-rollup":"^1.1.0","browser-sync":"^2.13.0","del":"^2.2.0","eslint":"^2.10.2","gulp":"^3.9.1","gulp-plumber":"^1.1.0","gulp-rename":"^1.2.2","gulp-sourcemaps":"^2.0.0-alpha","gulp-uglify":"^1.5.3","gulp-util":"^3.0.7","json2module":"~0.0.3","rollup":"^0.26","rollup-plugin-babel":"^2.5.1","rollup-plugin-includepaths":"^0.1.2","rollup-stream":"^1.6.0","vinyl-buffer":"^1.0.0","vinyl-source-stream":"^1.1.0","yargs":"^4.7.1"}; | ||
export var devDependencies = {"@redsift/tape-reel":"~0.0.2","babel-preset-es2015-rollup":"^1.1.0","browser-sync":"^2.13.0","del":"^2.2.0","eslint":"^2.10.2","gulp":"^3.9.1","gulp-plumber":"^1.1.0","gulp-rename":"^1.2.2","gulp-sourcemaps":"^2.0.0-alpha","gulp-uglify":"^1.5.3","gulp-util":"^3.0.7","json2module":"~0.0.3","rollup":"^0.26","rollup-plugin-buble":"^0.11.0","rollup-plugin-commonjs":"^3.0.0","rollup-plugin-node-resolve":"^1.7.0","rollup-stream":"^1.6.0","vinyl-buffer":"^1.0.0","vinyl-source-stream":"^1.1.0","yargs":"^4.7.1"}; |
{ | ||
"name": "@redsift/d3-rs-tip", | ||
"version": "0.2.1", | ||
"version": "0.2.2", | ||
"description": "Tip for graphs using D3v4.", | ||
@@ -22,4 +22,4 @@ "keywords": [ | ||
"scripts": { | ||
"serve": "gulp -o d3-rs-tip -g d3-selection serve", | ||
"build": "gulp -o d3-rs-tip -g d3-selection build", | ||
"serve": "gulp -o d3-rs-tip serve", | ||
"build": "gulp -o d3-rs-tip build", | ||
"pretest": "npm outdated && npm run build", | ||
@@ -47,4 +47,5 @@ "test": "tape 'test/**/*-test.js' && eslint index.js src", | ||
"rollup": "^0.26", | ||
"rollup-plugin-babel": "^2.5.1", | ||
"rollup-plugin-includepaths": "^0.1.2", | ||
"rollup-plugin-buble": "^0.11.0", | ||
"rollup-plugin-commonjs": "^3.0.0", | ||
"rollup-plugin-node-resolve": "^1.7.0", | ||
"rollup-stream": "^1.6.0", | ||
@@ -51,0 +52,0 @@ "vinyl-buffer": "^1.0.0", |
@@ -18,3 +18,2 @@ # d3-rs-tip | ||
var rtip = tip() | ||
.attr('class', 'd3-tip') | ||
.html(d => d.text) | ||
@@ -21,0 +20,0 @@ elmS.call(rtip); |
@@ -13,3 +13,3 @@ /** | ||
export default function tip() { | ||
export default function tip(id) { | ||
var d3_tip_functor = (v) => (typeof v === "function" ? v : () => v); | ||
@@ -19,2 +19,3 @@ var d3_tip_direction = () => 'n'; | ||
var d3_tip_html = () => ' '; | ||
var IsDOMElement = (o) => o instanceof Node; | ||
var defaultTipStyle = [ | ||
@@ -37,2 +38,3 @@ '.d3-tip {line-height: 1;font-weight: bold;padding: 12px;background: rgba(0, 0, 0, 0.8);color: #fff;border-radius: 2px;pointer-events: none;}', | ||
html = d3_tip_html, | ||
classed = 'd3-tip', | ||
node = initNode(), | ||
@@ -48,2 +50,4 @@ svg = null, | ||
node | ||
.attr('id', id) | ||
.classed(classed, true) | ||
.style('position','absolute') | ||
@@ -86,2 +90,10 @@ .style('top', 0) | ||
_impl.self = function() { return 'g' + (id ? '#' + id : '.' + classed); } | ||
_impl.id = function() { return id; }; | ||
_impl.classed = function(_) { | ||
return arguments.length ? (classed = _, _impl) : classed; | ||
}; | ||
// Public - show the tooltip on the screen | ||
@@ -92,10 +104,12 @@ // | ||
if(!parent) _impl.parent(document.body); | ||
var args = [].slice.call(arguments) | ||
if(args[args.length - 1] instanceof SVGElement) { | ||
target = args.pop() | ||
var args = [].slice.call(arguments); | ||
target = this; | ||
if(args.length === 1 && IsDOMElement(args[0])){ | ||
target = args[0]; | ||
args[0] = target.__data__; | ||
} | ||
var content = html.apply(this, args), | ||
poffset = offset.apply(this, args), | ||
dir = direction.apply(this, args), | ||
var content = html.apply(target, args), | ||
poffset = offset.apply(target, args), | ||
dir = direction.apply(target, args), | ||
nodel = getNodeEl(), | ||
@@ -111,3 +125,3 @@ i = directions.length, | ||
while(i--) nodel.classed(directions[i], false) | ||
coords = direction_callbacks[dir].apply(this) | ||
coords = direction_callbacks[dir].apply(target) | ||
nodel.classed(dir, true) | ||
@@ -147,19 +161,2 @@ .style('top', (coords.top + poffset[0]) - parentCoords.top + 'px') | ||
// Public: Proxy style calls to the d3 tip container. Sets or gets a style value. | ||
// | ||
// n - name of the property | ||
// v - value of the property | ||
// | ||
// Returns tip or style property value | ||
_impl.style = function(n) { | ||
if (arguments.length < 2 && typeof n === 'string') { | ||
return getNodeEl().style(n) | ||
} else { | ||
var args = [].slice.call(arguments) | ||
selection.prototype.style.apply(getNodeEl(), args) | ||
} | ||
return _impl; | ||
} | ||
// Public: Set or get the direction of the tooltip | ||
@@ -213,4 +210,4 @@ // | ||
_impl.style = function(value) { | ||
return arguments.length ? (style = defaultTipStyle + value, _impl) : style; | ||
_impl.style = function(_) { | ||
return arguments.length ? (style = _, _impl) : style; | ||
} | ||
@@ -217,0 +214,0 @@ |
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
167072
1513
1
20
43
1