UNPKG

@antv/g6

Version:

graph visualization frame work

2 lines 4.12 kB
!function(t,o){"object"==typeof exports&&"object"==typeof module?module.exports=o(require("@antv/g6")):"function"==typeof define&&define.amd?define(["@antv/g6"],o):"object"==typeof exports?exports["plugin.tool.tooltip"]=o(require("@antv/g6")):t["plugin.tool.tooltip"]=o(t.G6)}(window,function(t){return function(t){var o={};function e(n){if(o[n])return o[n].exports;var i=o[n]={i:n,l:!1,exports:{}};return t[n].call(i.exports,i,i.exports,e),i.l=!0,i.exports}return e.m=t,e.c=o,e.d=function(t,o,n){e.o(t,o)||Object.defineProperty(t,o,{enumerable:!0,get:n})},e.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},e.t=function(t,o){if(1&o&&(t=e(t)),8&o)return t;if(4&o&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(e.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&o&&"string"!=typeof t)for(var i in t)e.d(n,i,function(o){return t[o]}.bind(null,i));return n},e.n=function(t){var o=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(o,"a",o),o},e.o=function(t,o){return Object.prototype.hasOwnProperty.call(t,o)},e.p="",e(e.s=38)}({38:function(t,o,e){var n=Object.assign||function(t){for(var o=1;o<arguments.length;o++){var e=arguments[o];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])}return t};var i=e(6),r=i.Util,p=function(){function t(o){!function(t,o){if(!(t instanceof o))throw new TypeError("Cannot call a class as a function")}(this,t),this.options=n({dx:10,dy:10,getTooltip:function(t){var o=t.item;if(o){var e=o.getModel().tooltip;if(e){var n="",i=o.type;return r.isArray(e)?e.forEach(function(t){n+='<li style="font-size: 12px;list-style-type: none;"><span>'+t[0]+"</span>: "+t[1]+"</li>"}):(i=e.title,e.list.forEach(function(t){n+='<li style="font-size: 12px;list-style-type: none;"><span>'+t[0]+"</span>: "+t[1]+"</li>"})),'\n <div class="g6-tooltip" style="\n position: absolute;\n white-space: nowrap;\n zIndex: 8;\n transition: visibility 0.2s cubic-bezier(0.23, 1, 0.32, 1), left 0.4s cubic-bezier(0.23, 1, 0.32, 1), top 0.4s cubic-bezier(0.23, 1, 0.32, 1);\n background-color: rgba(255, 255, 255, 0.9);\n box-shadow: 0px 0px 10px #aeaeae;\n border-radius: 3px;\n color: rgb(87, 87, 87);\n line-height: 20px;\n padding: 10px 10px 6px 10px;\n ">\n <h4 class="g6-tooltip-title" style="\n margin: 0;\n ">'+i+'</h4>\n <ul class="g6-tooltip-list" style="\n padding: 0;\n margin: 0;\n margin-top: 4px;\n ">\n '+n+"\n </ul>\n </div>\n "}}return null}},o)}return t.prototype.init=function(){var t=this,o=this.graph;o.on("mouseenter",function(o){o.shape&&t.onMouseEnter(o)}),o.on("mousemove",function(o){t.onMouseMove(o)}),o.on("mouseleave",function(o){t.onMouseLeave(o)})},t.prototype.onMouseEnter=function(t){var o=this.graph.getGraphContainer(),e=this.options.getTooltip(t),n=this.tooltip;n&&this.tooltip.destroy(),e?((n=r.createDOM(e)).css({position:"absolute"}),o.appendChild(n)):n=null,this.tooltip=n},t.prototype.onMouseMove=function(t){var o=t.domX,e=t.domY,n=this.tooltip;if(n){var i=this.graph,p=r.getOuterWidth(n),s=r.getOuterHeight(n),l=i.getWidth(),u=i.getHeight();n.css({top:this._getTop(s,u,e),left:this._getLeft(p,l,o)})}},t.prototype.onMouseLeave=function(){this.tooltip&&(this.tooltip.destroy(),this.tooltip=null)},t.prototype._getTop=function(t,o,e){var n=this.options.dy;return 2*t>=o?"0px":e<t+n?e+n+"px":e-t-n+"px"},t.prototype._getLeft=function(t,o,e){var n=this.options.dx;return 2*t>=o?"0px":o-e-n<t?e-t-n+"px":e+n+"px"},t.prototype.destroy=function(){this.tooltip&&this.tooltip.destroy()},t}();i.Plugins["tool.tooltip"]=p,t.exports=p},6:function(o,e){o.exports=t}})}); //# sourceMappingURL=plugin.tool.tooltip.js.map