1 | (function (e, d) { "function" === typeof define && define.amd ? define(["d3"], d) : "object" === typeof module && module.exports ? module.exports = function (e) { e.tip = d(e); return e.tip } : e.d3.tip = d(e.d3) })(this, function (e) {
|
---|
2 | return function () {
|
---|
3 | function d(a) { a = a.node(); l = "svg" === a.tagName.toLowerCase() ? a : a.ownerSVGElement; b = l.createSVGPoint(); document.body.appendChild(c) } function k() {
|
---|
4 | var a = e.select(document.createElement("div")); a.style({ position: "absolute", top: 0, opacity: 0, "pointer-events": "none", "box-sizing": "border-box" });
|
---|
5 | return a.node()
|
---|
6 | } function g() { null === c && (c = k(), document.body.appendChild(c)); return e.select(c) } function f() {
|
---|
7 | for (var a = p || e.event.target; "undefined" === typeof a.getScreenCTM && "undefined" === a.parentNode;) a = a.parentNode; var d = {}, c = a.getScreenCTM(), a = a.getBBox(), f = a.width, g = a.height, h = a.y; b.x = a.x; b.y = h; d.nw = b.matrixTransform(c); b.x += f; d.ne = b.matrixTransform(c); b.y += g; d.se = b.matrixTransform(c); b.x -= f; d.sw = b.matrixTransform(c); b.y -= g / 2; d.w = b.matrixTransform(c); b.x += f; d.e = b.matrixTransform(c); b.x -= f / 2; b.y -=
|
---|
8 | g / 2; d.n = b.matrixTransform(c); b.y += g; d.s = b.matrixTransform(c); return d
|
---|
9 | } var h = function () { return "n" }, m = function () { return [0, 0] }, n = function () { return " " }, c = k(), l = null, b = null, p = null; d.show = function () {
|
---|
10 | var a = Array.prototype.slice.call(arguments); a[a.length - 1] instanceof SVGElement && (p = a.pop()); var b = n.apply(this, a), c = m.apply(this, a), a = h.apply(this, a), e = g(), f = q.length, k = document.documentElement.scrollTop || document.body.scrollTop, l = document.documentElement.scrollLeft || document.body.scrollLeft; for (e.html(b).style({
|
---|
11 | opacity: 1,
|
---|
12 | "pointer-events": "all"
|
---|
13 | }) ; f--;) e.classed(q[f], !1); b = r.get(a).apply(this); e.classed(a, !0).style({ top: b.top + c[0] + k + "px", left: b.left + c[1] + l + "px" }); return d
|
---|
14 | }; d.hide = function () { g().style({ opacity: 0, "pointer-events": "none" }); return d }; d.attr = function (a, b) { if (2 > arguments.length && "string" === typeof a) return g().attr(a); var c = Array.prototype.slice.call(arguments); e.selection.prototype.attr.apply(g(), c); return d }; d.style = function (a, b) {
|
---|
15 | if (2 > arguments.length && "string" === typeof a) return g().style(a); var c = Array.prototype.slice.call(arguments);
|
---|
16 | e.selection.prototype.style.apply(g(), c); return d
|
---|
17 | }; d.direction = function (a) { if (!arguments.length) return h; h = null == a ? a : e.functor(a); return d }; d.offset = function (a) { if (!arguments.length) return m; m = null == a ? a : e.functor(a); return d }; d.html = function (a) { if (!arguments.length) return n; n = null == a ? a : e.functor(a); return d }; d.destroy = function () { c && (g().remove(), c = null); return d }; var r = e.map({
|
---|
18 | n: function () { var a = f(); return { top: a.n.y - c.offsetHeight, left: a.n.x - c.offsetWidth / 2 } }, s: function () {
|
---|
19 | var a = f(); return {
|
---|
20 | top: a.s.y,
|
---|
21 | left: a.s.x - c.offsetWidth / 2
|
---|
22 | }
|
---|
23 | }, e: function () { var a = f(); return { top: a.e.y - c.offsetHeight / 2, left: a.e.x } }, w: function () { var a = f(); return { top: a.w.y - c.offsetHeight / 2, left: a.w.x - c.offsetWidth } }, nw: function () { var a = f(); return { top: a.nw.y - c.offsetHeight, left: a.nw.x - c.offsetWidth } }, ne: function () { var a = f(); return { top: a.ne.y - c.offsetHeight, left: a.ne.x } }, sw: function () { var a = f(); return { top: a.sw.y, left: a.sw.x - c.offsetWidth } }, se: function () { var a = f(); return { top: a.se.y, left: a.e.x } }
|
---|
24 | }), q = r.keys(); return d
|
---|
25 | }
|
---|
26 | }); |
---|