UNPKG

ngx-vis-network-etsisi

Version:

## Description Final Degree project - Implementation of Angular library using Vis Network. The main goal of this project is get easier the use of Vis Network including an abstraction layer to different edition methods in an Angular project.

16 lines (14 loc) 12.7 kB
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@angular/common"),require("@angular/core"),require("vis-network/standalone")):"function"==typeof define&&define.amd?define("ngx-vis-network-etsisi",["exports","@angular/common","@angular/core","vis-network/standalone"],e):e((t=t||self)["ngx-vis-network-etsisi"]={},t.ng.common,t.ng.core,t.standalone)}(this,(function(t,e,r,s){"use strict"; /*! ***************************************************************************** Copyright (c) Microsoft Corporation. Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ***************************************************************************** */var o=function(){return(o=Object.assign||function(t){for(var e,r=1,s=arguments.length;r<s;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)};var i=function(){function t(){this.click=new r.EventEmitter,this.doubleClick=new r.EventEmitter,this.oncontext=new r.EventEmitter,this.hold=new r.EventEmitter,this.release=new r.EventEmitter,this.select=new r.EventEmitter,this.selectNode=new r.EventEmitter,this.selectEdge=new r.EventEmitter,this.deselectNode=new r.EventEmitter,this.deselectEdge=new r.EventEmitter,this.dragStart=new r.EventEmitter,this.dragging=new r.EventEmitter,this.dragEnd=new r.EventEmitter,this.hoverNode=new r.EventEmitter,this.blurNode=new r.EventEmitter,this.hoverEdge=new r.EventEmitter,this.blurEdge=new r.EventEmitter,this.showPopup=new r.EventEmitter,this.hidePopup=new r.EventEmitter,this.startStabilizing=new r.EventEmitter,this.stabilizationProgress=new r.EventEmitter,this.stabilizationIterationsDone=new r.EventEmitter,this.stabilized=new r.EventEmitter,this.zoom=new r.EventEmitter,this.resize=new r.EventEmitter,this.initRedraw=new r.EventEmitter,this.animationFinished=new r.EventEmitter,this.configChange=new r.EventEmitter,this.beforeDrawing=new r.EventEmitter,this.afterDrawing=new r.EventEmitter,this.auxGraphs={},this.seedGraphs={}}return t.prototype.create=function(t,e,r,o,i){if(this.auxGraphs[e])throw new Error("Graph "+e+" exists");this.auxGraphs[e]={network:new s.Network(t,{nodes:r,edges:o},i),nodes:r,edges:o,options:i},this.seedGraphs[e]={nodes:r.getDataSet().get(),edges:o.getDataSet().get(),options:i}},t.prototype.getNodesCount=function(t){return this.auxGraphs[t]?this.auxGraphs[t].nodes.length:0},t.prototype.getEdgesCount=function(t){return this.auxGraphs[t]?this.auxGraphs[t].edges.length:0},t.prototype.getNodes=function(t){return this.auxGraphs[t]?this.auxGraphs[t].nodes:null},t.prototype.getEdges=function(t){return this.auxGraphs[t]?this.auxGraphs[t].edges:null},t.prototype.isAnExistingGraphNetwork=function(t){return!!this.auxGraphs[t]},t.prototype.addNode=function(t,e){if(!this.auxGraphs[t])throw new Error("Graph "+t+" doesn't exist.");this.auxGraphs[t].nodes.add(e)},t.prototype.updateNode=function(t,e){if(!this.auxGraphs[t])throw new Error("Graph "+t+" doesn't exist.");this.auxGraphs[t].nodes.update(e)},t.prototype.removeNode=function(t,e){if(!this.auxGraphs[t])throw new Error("Graph "+t+" doesn't exist.");this.auxGraphs[t].nodes.remove(e)},t.prototype.addEdge=function(t,e){if(!this.auxGraphs[t])throw new Error("Graph "+t+" doesn't exist.");this.auxGraphs[t].edges.add(e)},t.prototype.removeEdge=function(t,e){if(!this.auxGraphs[t])throw new Error("Graph "+t+" doesn't exist.");this.auxGraphs[t].edges.remove(e)},t.prototype.setBackgroundNode=function(t,e,r){var s=this.getNodes(t).get(e);this.updateNode(t,o({},s,{color:{background:r}}))},t.prototype.getNodePositions=function(t,e){return this.auxGraphs[t].network.getPositions(e)},t.prototype.resetGraph=function(t){if(!this.auxGraphs[t])throw new Error("Graph "+t+" doesn't exist.");this.setOptions(t,this.seedGraphs[t].options),this.updateNode(t,this.seedGraphs[t].nodes),this.updateEdge(t,this.seedGraphs[t].edges)},t.prototype.getSeed=function(t){return this.auxGraphs[t]?this.auxGraphs[t].network.getSeed():-1},t.prototype.fit=function(t,e){if(!this.auxGraphs[t])throw new Error("Graph "+t+" doesn't exist.");this.auxGraphs[t].network.fit(e)},t.prototype.redraw=function(t){if(!this.auxGraphs[t])throw new Error("Graph "+t+" doesn't exist.");this.auxGraphs[t].network.redraw()},t.prototype.getScale=function(t){if(this.auxGraphs[t])return this.auxGraphs[t].network.getScale();throw new Error("Graph "+t+" doesn't exist.")},t.prototype.canvasToDom=function(t,e){if(this.auxGraphs[t])return this.auxGraphs[t].network.canvasToDOM(e);throw new Error("Graph "+t+" doesn't exist.")},t.prototype.domToCanvas=function(t,e){if(this.auxGraphs[t])return this.auxGraphs[t].network.DOMtoCanvas(e);throw new Error("Graph "+t+" doesn't exist.")},t.prototype.on=function(t,e,r){if(this.auxGraphs[t]){var s=this;return this.auxGraphs[t].network.on(e,(function(o){var i=s[e];i&&i.emit(o?[t].concat(o):t),r&&o.event&&o.event.preventDefault()})),!0}return!1},t.prototype.off=function(t,e){this.auxGraphs[t]&&this.auxGraphs[t].network.off(e)},t.prototype.once=function(t,e){var r=this;if(this.auxGraphs[t]){var s=this;return this.auxGraphs[t].network.on(e,(function(o){var i=s[e];i&&(i.emit(o?[t].concat(o):t),r.off(t,e))})),!0}return!1},t.prototype.destroy=function(t){if(!this.auxGraphs[t])throw new Error("Graph "+t+" doesn't exist.");this.auxGraphs[t].network.destroy(),delete this.auxGraphs[t]},t.prototype.updateEdge=function(t,e){if(!this.auxGraphs[t])throw new Error("Graph "+t+" doesn't exist.");this.auxGraphs[t].edges.update(e)},t.prototype.setOptions=function(t,e){if(!this.auxGraphs[t])throw new Error("Graph "+t+" doesn't exist.");this.auxGraphs[t].network.setOptions(e)},t.prototype.setData=function(t,e){if(!this.auxGraphs[t])throw new Error("Graph "+t+" doesn't exist.");this.auxGraphs[t].network.setData(e)},t.prototype.selectNodes=function(t,e,r){if(!this.auxGraphs[t])throw new Error("Graph "+t+" doesn't exist.");this.auxGraphs[t].network.selectNodes(e,r)},t.prototype.startSimulation=function(t){if(!this.auxGraphs[t])throw new Error("Graph "+t+" doesn't exist.");this.auxGraphs[t].network.startSimulation()},t.prototype.stopSimulation=function(t){if(!this.auxGraphs[t])throw new Error("Graph "+t+" doesn't exist.");this.auxGraphs[t].network.stopSimulation()},t.prototype.moveTo=function(t,e){if(!this.auxGraphs[t])throw new Error("Graph "+t+" doesn't exist.");this.auxGraphs[t].network.moveTo(e)},t.prototype.getConnectedEdges=function(t,e){if(!this.auxGraphs[t])throw new Error("Graph "+t+" doesn't exist.");this.auxGraphs[t].network.getConnectedEdges(e)},t.prototype.getConnectedNodes=function(t,e){if(!this.auxGraphs[t])throw new Error("Graph "+t+" doesn't exist.");this.auxGraphs[t].network.getConnectedNodes(e)},t.prototype.getSelectedNodes=function(t){return this.auxGraphs[t]?this.auxGraphs[t].network.getSelectedNodes():[]},t.prototype.getSelectedEdges=function(t){return this.auxGraphs[t]?this.auxGraphs[t].network.getSelectedEdges():[]},t.prototype.getNodeAt=function(t,e){if(this.auxGraphs[t])return this.auxGraphs[t].network.getNodeAt(e);throw new Error("Graph "+t+" doesn't exist.")},t.prototype.getEdgeAt=function(t,e){if(this.auxGraphs[t])return this.auxGraphs[t].network.getEdgeAt(e);throw new Error("Graph "+t+" doesn't exist.")},t.prototype.setSelection=function(t,e,r){if(void 0===r&&(r={}),!this.auxGraphs[t])throw new Error("Graph "+t+" doesn't exist.");this.auxGraphs[t].network.setSelection(e,r)},t.prototype.getSelection=function(t){if(this.auxGraphs[t])return this.auxGraphs[t].network.getSelection()},t.prototype.unselectAll=function(t){if(!this.auxGraphs[t])throw new Error("Graph "+t+" doesn't exist.");this.auxGraphs[t].network.unselectAll()},t.prototype.deleteSelected=function(t){if(!this.auxGraphs[t])throw new Error("Graph "+t+" doesn't exist.");this.auxGraphs[t].network.deleteSelected()},t.prototype.getBoundingBox=function(t,e){return this.auxGraphs[t].network.getBoundingBox(e)},t.prototype.storePositions=function(t){this.auxGraphs[t].network.storePositions()},t.prototype.addNodeMode=function(t){if(!this.auxGraphs[t])throw new Error("Graph "+t+" doesn't exist.");this.auxGraphs[t].network.addNodeMode()},t.prototype.enableEditMode=function(t){if(!this.auxGraphs[t])throw new Error("Graph "+t+" doesn't exist.");this.auxGraphs[t].network.enableEditMode()},t.prototype.addEdgeMode=function(t){if(!this.auxGraphs[t])throw new Error("Graph "+t+" doesn't exist.");this.auxGraphs[t].network.addEdgeMode()},t.prototype.disableEditMode=function(t){if(!this.auxGraphs[t])throw new Error("Graph "+t+" doesn't exist.");this.auxGraphs[t].network.disableEditMode()},t.prototype.updateClusteredNode=function(t,e,r){if(!this.auxGraphs[t])throw new Error("Graph "+t+" doesn't exist.");this.auxGraphs[t].network.updateClusteredNode(e,r)},t.prototype.getNodesInCluster=function(t,e){if(this.auxGraphs[t])return this.auxGraphs[t].network.getNodesInCluster(e);throw new Error("Graph "+t+" doesn't exist.")},t.prototype.openCluster=function(t,e,r){if(!this.auxGraphs[t])throw new Error("Graph "+t+" doesn't exist.");this.auxGraphs[t].network.openCluster(e,r)},t.prototype.isCluster=function(t,e){return!!this.auxGraphs[t]&&this.auxGraphs[t].network.isCluster(e)},t.prototype.getClusteredEdges=function(t,e){if(this.auxGraphs[t])return this.auxGraphs[t].network.getClusteredEdges(e);throw new Error("Graph "+t+" doesn't exist.")},t.prototype.cluster=function(t,e){if(!this.auxGraphs[t])throw new Error("Graph "+t+" doesn't exist.");this.auxGraphs[t].network.cluster(e)},t.prototype.clusterByConnection=function(t,e,r){if(!this.auxGraphs[t])throw new Error("Graph "+t+" doesn't exist.");this.auxGraphs[t].network.clusterByConnection(e,r)},t.prototype.clusterByHubSize=function(t,e,r){if(!this.auxGraphs[t])throw new Error("Graph "+t+" doesn't exist.");this.auxGraphs[t].network.clusterByHubsize(e,r)},t.prototype.clusterOutliers=function(t,e){if(!this.auxGraphs[t])throw new Error("Graph "+t+" doesn't exist.");this.auxGraphs[t].network.clusterOutliers(e)},t.prototype.getBaseEdge=function(t,e){if(this.auxGraphs[t])return this.auxGraphs[t].network.getBaseEdge(e);throw new Error("Graph "+t+" doesn't exist.")},t.prototype.updateClusteredEdges=function(t,e,r){if(!this.auxGraphs[t])throw new Error("Graph "+t+" doesn't exist.");this.auxGraphs[t].network.updateEdge(e,r)},t.prototype.findNode=function(t,e){if(this.auxGraphs[t])return this.auxGraphs[t].network.findNode(e);throw new Error("Graph "+t+" doesn't exist.")},t.decorators=[{type:r.Injectable,args:[{providedIn:"root"}]}],t.ctorParameters=function(){return[]},t.ngInjectableDef=r.ɵɵdefineInjectable({factory:function(){return new t},token:t,providedIn:"root"}),t}();var n=function(){function t(t,e){this.elementRef=t,this.ngxVisNetworkEtsisiService=e,this.ready=new r.EventEmitter,this.container=this.elementRef.nativeElement,this.isReady=!1}return t.prototype.ngOnInit=function(){!this.isReady&&this.etsisiVis&&this.etsisiVisNodes&&this.etsisiVisEdges&&this.createNetwork()},t.prototype.createNetwork=function(){this.ngxVisNetworkEtsisiService.create(this.container,this.etsisiVis,this.etsisiVisNodes,this.etsisiVisEdges,this.etsisiVisOptions),this.isReady=!0,this.ready.emit(this.etsisiVis)},t.prototype.ngOnDestroy=function(){this.isReady=!1,this.ngxVisNetworkEtsisiService.destroy(this.etsisiVis)},t.decorators=[{type:r.Directive,args:[{selector:"[etsisiVis]"}]}],t.ctorParameters=function(){return[{type:r.ElementRef},{type:i}]},t.propDecorators={etsisiVis:[{type:r.Input}],etsisiVisNodes:[{type:r.Input}],etsisiVisEdges:[{type:r.Input}],etsisiVisOptions:[{type:r.Input}],ready:[{type:r.Output}]},t}();var a=function(){function t(){}return t.decorators=[{type:r.NgModule,args:[{declarations:[n],imports:[e.CommonModule],exports:[n],providers:[i],schemas:[r.CUSTOM_ELEMENTS_SCHEMA,r.NO_ERRORS_SCHEMA]}]}],t}();Object.defineProperty(t,"DataSet",{enumerable:!0,get:function(){return s.DataSet}}),t.NgxVisNetworkEtsisiDirective=n,t.NgxVisNetworkEtsisiModule=a,t.NgxVisNetworkEtsisiService=i,Object.defineProperty(t,"__esModule",{value:!0})})); //# sourceMappingURL=ngx-vis-network-etsisi.umd.min.js.map