UNPKG

@antv/g6

Version:

graph visualization frame work

2 lines 9.36 kB
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("@antv/g6")):"function"==typeof define&&define.amd?define(["@antv/g6"],e):"object"==typeof exports?exports.Minimap=e(require("@antv/g6")):t.Minimap=e(t.G6)}(window,function(t){return function(t){var e={};function n(r){if(e[r])return e[r].exports;var i=e[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)n.d(r,i,function(e){return t[e]}.bind(null,i));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=43)}([,,function(t,e,n){var r=n(15),i=n(3),o=5;function a(t,e,n,s){for(var u in n=n||0,s=s||o,e)if(e.hasOwnProperty(u)){var f=e[u];null!==f&&r(f)?(r(t[u])||(t[u]={}),n<s?a(t[u],f,n+1,s):t[u]=e[u]):i(f)?(t[u]=[],t[u]=t[u].concat(f)):void 0!==f&&(t[u]=f)}}t.exports=function(){for(var t=new Array(arguments.length),e=t.length,n=0;n<e;n++)t[n]=arguments[n];for(var r=t[0],i=1;i<e;i++)a(r,t[i]);return r}},function(t,e,n){var r=n(4),i=Array.isArray?Array.isArray:function(t){return r(t,"Array")};t.exports=i},function(t,e){var n={}.toString;t.exports=function(t,e){return n.call(t)==="[object "+e+"]"}},,,function(t,e,n){var r=n(12),i=n(3);t.exports=function(t,e){if(t)if(i(t))for(var n=0,o=t.length;n<o&&!1!==e(t[n],n);n++);else if(r(t))for(var a in t)if(t.hasOwnProperty(a)&&!1===e(t[a],a))break}},function(t,e,n){var r=n(2),i=n(7),o=n(16),a=function(){function t(t){this._cfgs=r(this.getDefaultCfgs(),t)}var e=t.prototype;return e.getDefaultCfgs=function(){return{}},e.initPlugin=function(t){var e=this;e.set("graph",t);var n=e.getEvents(),r={};i(n,function(n,i){var a=o(e,n);r[i]=a,t.on(i,a)}),this._events=r,this.init()},e.init=function(){},e.getEvents=function(){return{}},e.get=function(t){return this._cfgs[t]},e.set=function(t,e){this._cfgs[t]=e},e.destroy=function(){},e.destroyPlugin=function(){this.destroy();var t=this.get("graph"),e=this._events;i(e,function(e,n){t.off(n,e)}),this._events=null,this._cfgs=null,this.destroyed=!0},t}();t.exports=a},function(t,e){t.exports=function(t,e){if(t)for(var n in e)e.hasOwnProperty(n)&&(t.style[n]=e[n]);return t}},,,function(t,e){var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t};t.exports=function(t){var e=void 0===t?"undefined":n(t);return null!==t&&"object"===e||"function"===e}},,function(t,e){var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t};t.exports=function(t){return"object"===(void 0===t?"undefined":n(t))&&null!==t}},function(t,e,n){var r=n(14),i=n(4);t.exports=function(t){if(!r(t)||!i(t,"Object"))return!1;if(null===Object.getPrototypeOf(t))return!0;for(var e=t;null!==Object.getPrototypeOf(e);)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(t)===e}},function(t,e){t.exports=function(t,e){if(t["_wrap_"+e])return t["_wrap_"+e];var n=function(n){t[e](n)};return t["_wrap_"+e]=n,n}},function(t,e,n){var r=n(4);t.exports=function(t){return r(t,"String")}},,,,function(t,e){var n=document.createElement("table"),r=document.createElement("tr"),i=/^\s*<(\w+|!)[^>]*>/,o={tr:document.createElement("tbody"),tbody:n,thead:n,tfoot:n,td:r,th:r,"*":document.createElement("div")};t.exports=function(t){var e=i.test(t)&&RegExp.$1;e in o||(e="*");var n=o[e];t=t.replace(/(^\s*)|(\s*$)/g,""),n.innerHTML=""+t;var r=n.childNodes[0];return n.removeChild(r),r}},,,,,function(t,e){t.exports=function(t){return null===t||void 0===t}},,,,,,,,,,,,,,,,function(e,n){e.exports=t},function(t,e,n){function r(){return(r=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t}).apply(this,arguments)}var i=n(42).G,o=n(8),a=n(17),s=n(26),u=n(21),f=n(9),c=n(7),p=Math.max,h=function(t){function e(){return t.apply(this,arguments)||this}!function(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e}(e,t);var n=e.prototype;return n.init=function(){this.initContainer()},n.getDefaultCfgs=function(){return{container:null,className:"g6-minimap",viewportClassName:"g6-minimap-viewport",type:"default",size:[200,120],delegateStyle:{fill:"#40a9ff",stroke:"#096dd9"},refresh:!0}},n.getEvents=function(){return{beforepaint:"updateCanvas",beforeanimate:"disableRefresh",afteranimate:"enableRefresh",viewportchange:"disableOneRefresh"}},n.disableRefresh=function(){this.set("refresh",!1)},n.enableRefresh=function(){this.set("refresh",!0),this.updateCanvas()},n.disableOneRefresh=function(){this.set("viewportChange",!0)},n.initContainer=function(){var t=this.get("graph"),e=this.get("size"),n=this.get("className"),r=this.get("container"),o=u('<div class="'+n+'" style="width:'+e[0]+"px; height:"+e[1]+'px"></div>');a(r)&&(r=document.getElementById(r)),r?r.appendChild(o):t.get("container").appendChild(o),this.set("container",o);var s=u('<div class="g6-minimap-container"></div>');o.appendChild(s);var f=new i.Canvas({containerDOM:s,width:e[0],height:e[1],pixelRatio:t.get("pixelRatio")});this.set("canvas",f),this.updateCanvas()},n.initViewport=function(){var t,e,n,r,i,o,a,c=this,p=this._cfgs,h=p.size,l=p.graph,g=this.get("canvas").get("containerDOM"),d=u('<div class="'+p.viewportClassName+'" style="position:absolute;left:0;top:0;box-sizing:border-box;border: 2px solid #1980ff"></div>');g.addEventListener("mousedown",function(s){if(p.refresh=!1,s.target===d){var u=d.style;r=parseInt(u.left,10),i=parseInt(u.top,10),o=parseInt(u.width,10),a=parseInt(u.height,10),o>=h[0]||a>=h[1]||(n=!0,t=s.clientX,e=s.clientY)}},!1),g.addEventListener("mousemove",function(u){if(n&&!s(u.clientX)&&!s(u.clientY)){var p=t-u.clientX,g=e-u.clientY;r-p<0?p=r:r-p+o>h[0]&&(p=r+o-h[0]),i-g<0?g=i:i-g+a>h[1]&&(g=i+a-h[1]),f(d,{left:(r-=p)+"px",top:(i-=g)+"px"});var v=c.get("ratio");l.translate(p/v,g/v),t=u.clientX,e=u.clientY}},!1),g.addEventListener("mouseleave",function(){n=!1,p.refresh=!0},!1),g.addEventListener("mouseup",function(){n=!1,p.refresh=!0},!1),this.set("viewport",d),g.appendChild(d)},n.updateCanvas=function(){if(this.get("refresh")){this.get("viewportChange")&&(this.set("viewportChange",!1),this._updateViewport());var t=this.get("size"),e=this.get("graph"),n=this.get("canvas");switch(this.get("type")){case"default":this._updateGraphShapes();break;case"keyShape":this._updateKeyShapes();break;case"delegate":this._updateDelegateShapes();break;default:this._updateGraphShapes()}var r=n.getBBox(),i=p(r.width,e.get("width")),o=p(r.height,e.get("height")),a=n.get("pixelRatio"),s=Math.min(t[0]/i,t[1]/o);n.resetMatrix();var u=-(r.minX>0?0:r.minX),f=-(r.minY>0?0:r.minY);n.translate(u,f),n.scale(s*a,s*a);var c=(t[0]-i*s)/2,h=(t[1]-o*s)/2;n.translate(c*a,h*a),n.draw(),this.set("ratio",s),this.set("dx",c+u*s),this.set("dy",h+f*s),this._updateViewport()}},n._updateKeyShapes=function(){var t=this._cfgs.graph,e=this.get("canvas"),n=e.get("children")[0];n||(n=e.addGroup()).setMatrix(t.get("group").getMatrix());var r=t.getNodes();n.clear(),this._getGraphEdgeKeyShape(n),c(r,function(t){if(t.isVisible()){var e=n.addGroup();e.setMatrix(t.get("group").attr("matrix")),e.add(t.get("keyShape").clone())}})},n._updateGraphShapes=function(){var t=this.get("graph"),e=this.get("canvas"),n=t.get("group").clone();n.resetMatrix(),e.get("children")[0]=n},n._updateDelegateShapes=function(){var t=this._cfgs.graph,e=this.get("canvas"),n=e.get("children")[0]||e.addGroup(),i=this.get("delegateStyle");n.clear(),this._getGraphEdgeKeyShape(n),c(t.getNodes(),function(t){if(t.isVisible()){var e=t.getBBox();n.addShape("rect",{attrs:r({x:e.minX,y:e.minY,width:e.width,height:e.height},i)})}})},n._getGraphEdgeKeyShape=function(t){var e=this.get("graph");c(e.getEdges(),function(e){e.isVisible()&&t.add(e.get("keyShape").clone())})},n._updateViewport=function(){var t=this.get("ratio"),e=this.get("dx"),n=this.get("dy"),r=this.get("graph"),i=this.get("size"),o=r.get("width"),a=r.get("height"),s=r.getPointByCanvas(0,0),u=r.getPointByCanvas(o,a),c=this.get("viewport");c||this.initViewport();var p=(u.x-s.x)*t,h=(u.y-s.y)*t,l=s.x*t+e,g=s.y*t+n;p>i[0]&&(p=i[0]),h>i[1]&&(h=i[1]),this.set("ratio",t),f(c,{left:l>0?l+"px":0,top:g>0?g+"px":0,width:p+"px",height:h+"px"})},n.getCanvas=function(){return this.get("canvas")},n.getViewport=function(){return this.get("viewport")},n.getContainer=function(){return this.get("container")},n.destroy=function(){this.get("canvas").destroy();var t=this.get("container");t.parentNode.removeChild(t)},e}(o);t.exports=h}])}); //# sourceMappingURL=minimap.js.map