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.

1,217 lines (1,216 loc) 105 kB
import { CommonModule } from '@angular/common'; import { EventEmitter, Injectable, ɵɵdefineInjectable, Directive, ElementRef, Input, Output, NgModule, CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA } from '@angular/core'; import { Network } from 'vis-network/standalone'; export { DataSet } from 'vis-network/standalone'; import { __assign } from 'tslib'; /** * @fileoverview added by tsickle * Generated from: lib/ngx-vis-network-etsisi.service.ts * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ /** * \@description This service allow CRUD operations for graph networks. * Also, it exposes all available events from Vis Network * @export NgxVisNetworkEtsisiService */ var NgxVisNetworkEtsisiService = /** @class */ (function () { function NgxVisNetworkEtsisiService() { /** * \@description Fired when the user clicks the mouse or taps on a touchscreen device. * \@memberOf NgxVisNetworkEtsisiService */ this.click = new EventEmitter(); /** * \@description Fired when the user double clicks the mouse or double taps on a touchscreen device. * Since a double click is in fact 2 clicks, 2 click events are fired, followed by a double click event. * If you do not want to use the click events if a double click event is fired, * just check the time between click events before processing them. * \@memberOf NgxVisNetworkEtsisiService */ this.doubleClick = new EventEmitter(); /** * \@description Fired when the user click on the canvas with the right mouse button. * The right mouse button does not select by default. * You can use the method getNodeAt to select the node if you want. * \@memberOf NgxVisNetworkEtsisiService */ this.oncontext = new EventEmitter(); /** * \@description Fired when the user clicks and holds the mouse or taps and holds on a touchscreen device. * A click event is also fired in this case. * \@memberOf NgxVisNetworkEtsisiService */ this.hold = new EventEmitter(); /** * \@description Fired after drawing on the canvas has been completed. * Can be used to draw on top of the network. * \@memberOf NgxVisNetworkEtsisiService */ this.release = new EventEmitter(); /** * \@description Fired when the selection has changed by user action. * This means a node or edge has been selected, added to the selection or deselected. * All select events are only triggered on click and hold. * \@memberOf NgxVisNetworkEtsisiService */ this.select = new EventEmitter(); /** * \@description Fired when a node has been selected by the user. * \@memberOf NgxVisNetworkEtsisiService */ this.selectNode = new EventEmitter(); /** * Fired when an edge has been selected by the user. * \@memberOf NgxVisNetworkEtsisiService */ this.selectEdge = new EventEmitter(); /** * \@description Fired when a node (or nodes) has (or have) been deselected by the user. * The previous selection is the list of nodes and edges that were selected before the last user event. * \@memberOf NgxVisNetworkEtsisiService */ this.deselectNode = new EventEmitter(); /** * \@description Fired when an edge (or edges) has (or have) been deselected by the user. * The previous selection is the list of nodes and edges that were selected before the last user event. * \@memberOf NgxVisNetworkEtsisiService */ this.deselectEdge = new EventEmitter(); /** * \@description Fired when starting a drag. * \@memberOf NgxVisNetworkEtsisiService */ this.dragStart = new EventEmitter(); /** * \@description Fired when dragging node(s) or the view. * \@memberOf NgxVisNetworkEtsisiService */ this.dragging = new EventEmitter(); /** * \@description Fired when the drag has finished. * \@memberOf NgxVisNetworkEtsisiService */ this.dragEnd = new EventEmitter(); /** * \@description Fired if the option interaction:{hover:true} is enabled and the mouse hovers over a node. * \@memberOf NgxVisNetworkEtsisiService */ this.hoverNode = new EventEmitter(); /** * \@description Fired if the option interaction:{hover:true} is enabled and the mouse moved away from a node it was hovering over before. * \@memberOf NgxVisNetworkEtsisiService */ this.blurNode = new EventEmitter(); /** * \@description Fired if the option interaction:{hover:true} is enabled and the mouse hovers over an edge. * \@memberOf NgxVisNetworkEtsisiService */ this.hoverEdge = new EventEmitter(); /** * \@description Fired if the option interaction:{hover:true} is enabled and the mouse moved away from an edge it was hovering over before. * \@memberOf NgxVisNetworkEtsisiService */ this.blurEdge = new EventEmitter(); /** * \@description Fired when the popup (tooltip) is shown. * \@memberOf NgxVisNetworkEtsisiService */ this.showPopup = new EventEmitter(); /** * \@description Fired when the popup (tooltip) is hidden. * \@memberOf NgxVisNetworkEtsisiService */ this.hidePopup = new EventEmitter(); /** * \@description Fired when stabilization starts. * This is also the case when you drag a node and the physics simulation restarts to stabilize again. * Stabilization does not necessarily imply 'without showing'. * \@memberOf NgxVisNetworkEtsisiService */ this.startStabilizing = new EventEmitter(); /** * \@description Fired when a multiple of the updateInterval number of iterations is reached. * This only occurs in the 'hidden' stabilization. * \@memberOf NgxVisNetworkEtsisiService */ this.stabilizationProgress = new EventEmitter(); /** * \@description Fired when the 'hidden' stabilization finishes. * This does not necessarily mean the network is stabilized; * it could also mean that the amount of iterations defined in the options has been reached. * \@memberOf NgxVisNetworkEtsisiService */ this.stabilizationIterationsDone = new EventEmitter(); /** * \@description Fired when the network has stabilized or when the stopSimulation() has been called. * The amount of iterations it took could be used to tweak the maximum amount of iterations needed to stabilize the network. * \@memberOf NgxVisNetworkEtsisiService */ this.stabilized = new EventEmitter(); /** * \@description Fired when the user zooms in or out. * The properties tell you which direction the zoom is in. * The scale is a number greater than 0, which is the same that you get with network.getScale(). * When fired by clicking the zoom in or zoom out navigation buttons, the pointer property of the object passed will be null. * \@memberOf NgxVisNetworkEtsisiService */ this.zoom = new EventEmitter(); /** * \@description Fired when the size of the canvas has been resized, either by a redraw call when the container div has changed in size, * a setSize() call with new values or a setOptions() with new width and/or height values. * \@memberOf NgxVisNetworkEtsisiService */ this.resize = new EventEmitter(); /** * \@description Fired before the redrawing begins. The simulation step has completed at this point. * Can be used to move custom elements before starting drawing the new frame. * \@memberOf NgxVisNetworkEtsisiService */ this.initRedraw = new EventEmitter(); /** * \@description Fired when an animation is finished. * \@memberOf NgxVisNetworkEtsisiService */ this.animationFinished = new EventEmitter(); /** * \@description Fired when a user changes any option in the configurator. * The options object can be used with the setOptions method or stringified using JSON.stringify(). * You do not have to manually put the options into the network: this is done automatically. * You can use the event to store user options in the database. * \@memberOf NgxVisNetworkEtsisiService */ this.configChange = new EventEmitter(); /** * \@description Fired after the Canvas has been cleared, scaled and translated to * the viewing position but before all edges and nodes are drawn. * Can be used to draw behind the network. * \@memberOf NgxVisNetworkEtsisiService */ this.beforeDrawing = new EventEmitter(); /** * \@description Fired after drawing on the canvas has been completed. * Can be used to draw on top of the network. * \@memberOf NgxVisNetworkEtsisiService */ this.afterDrawing = new EventEmitter(); this.auxGraphs = {}; this.seedGraphs = {}; } /** * @description It creates a new graph network. * @param container is the html element where the graph will be added. * @param id is the graph network id. * @param nodes to generate the graph network. * @param edges to generate the graph network. * @param options to generate the graph network. * @throws Thrown when the graph network has already been rendered. * @memberOf NgxVisNetworkEtsisiService */ /** * \@description It creates a new graph network. * @throws Thrown when the graph network has already been rendered. * \@memberOf NgxVisNetworkEtsisiService * @param {?} container is the html element where the graph will be added. * @param {?} id is the graph network id. * @param {?} nodes to generate the graph network. * @param {?} edges to generate the graph network. * @param {?=} options to generate the graph network. * @return {?} */ NgxVisNetworkEtsisiService.prototype.create = /** * \@description It creates a new graph network. * @throws Thrown when the graph network has already been rendered. * \@memberOf NgxVisNetworkEtsisiService * @param {?} container is the html element where the graph will be added. * @param {?} id is the graph network id. * @param {?} nodes to generate the graph network. * @param {?} edges to generate the graph network. * @param {?=} options to generate the graph network. * @return {?} */ function (container, id, nodes, edges, options) { if (this.auxGraphs[id]) { throw new Error("Graph " + id + " exists"); } this.auxGraphs[id] = { network: new Network(container, { nodes: nodes, edges: edges }, options), nodes: nodes, edges: edges, options: options }; this.seedGraphs[id] = { nodes: nodes.getDataSet().get(), edges: edges.getDataSet().get(), options: options }; }; /** * @description It gets the number of nodes for a graph with a concrete id. * @param id is the graph network id. * @memberOf NgxVisNetworkEtsisiService */ /** * \@description It gets the number of nodes for a graph with a concrete id. * \@memberOf NgxVisNetworkEtsisiService * @param {?} id is the graph network id. * @return {?} */ NgxVisNetworkEtsisiService.prototype.getNodesCount = /** * \@description It gets the number of nodes for a graph with a concrete id. * \@memberOf NgxVisNetworkEtsisiService * @param {?} id is the graph network id. * @return {?} */ function (id) { if (this.auxGraphs[id]) { return this.auxGraphs[id].nodes.length; } return 0; }; /** * @description It gets the number of edges for a graph with a concrete id. * @param id is the graph network id. * @memberOf NgxVisNetworkEtsisiService */ /** * \@description It gets the number of edges for a graph with a concrete id. * \@memberOf NgxVisNetworkEtsisiService * @param {?} id is the graph network id. * @return {?} */ NgxVisNetworkEtsisiService.prototype.getEdgesCount = /** * \@description It gets the number of edges for a graph with a concrete id. * \@memberOf NgxVisNetworkEtsisiService * @param {?} id is the graph network id. * @return {?} */ function (id) { if (this.auxGraphs[id]) { return this.auxGraphs[id].edges.length; } return 0; }; /** * @description It gets the nodes for a graph with a concrete id. * @param id is the graph network id. * @memberOf NgxVisNetworkEtsisiService */ /** * \@description It gets the nodes for a graph with a concrete id. * \@memberOf NgxVisNetworkEtsisiService * @param {?} id is the graph network id. * @return {?} */ NgxVisNetworkEtsisiService.prototype.getNodes = /** * \@description It gets the nodes for a graph with a concrete id. * \@memberOf NgxVisNetworkEtsisiService * @param {?} id is the graph network id. * @return {?} */ function (id) { if (this.auxGraphs[id]) { return this.auxGraphs[id].nodes; } return null; }; /** * @description It gets the edges for a graph with a concrete id. * @param id is the graph network id. * @memberOf NgxVisNetworkEtsisiService */ /** * \@description It gets the edges for a graph with a concrete id. * \@memberOf NgxVisNetworkEtsisiService * @param {?} id is the graph network id. * @return {?} */ NgxVisNetworkEtsisiService.prototype.getEdges = /** * \@description It gets the edges for a graph with a concrete id. * \@memberOf NgxVisNetworkEtsisiService * @param {?} id is the graph network id. * @return {?} */ function (id) { if (this.auxGraphs[id]) { return this.auxGraphs[id].edges; } return null; }; /** * @description It returns if a graph with a concrete id exists. * @param id is the graph network id. * @memberOf NgxVisNetworkEtsisiService */ /** * \@description It returns if a graph with a concrete id exists. * \@memberOf NgxVisNetworkEtsisiService * @param {?} id is the graph network id. * @return {?} */ NgxVisNetworkEtsisiService.prototype.isAnExistingGraphNetwork = /** * \@description It returns if a graph with a concrete id exists. * \@memberOf NgxVisNetworkEtsisiService * @param {?} id is the graph network id. * @return {?} */ function (id) { return !!this.auxGraphs[id]; }; /** * @description Adds a node in a graph network. * @param id is the graph network id * @param data is the node info. * @throws Thrown when the graph network doesn't exist. * @memberOf NgxVisNetworkEtsisiService */ /** * \@description Adds a node in a graph network. * @throws Thrown when the graph network doesn't exist. * \@memberOf NgxVisNetworkEtsisiService * @param {?} id is the graph network id * @param {?} data is the node info. * @return {?} */ NgxVisNetworkEtsisiService.prototype.addNode = /** * \@description Adds a node in a graph network. * @throws Thrown when the graph network doesn't exist. * \@memberOf NgxVisNetworkEtsisiService * @param {?} id is the graph network id * @param {?} data is the node info. * @return {?} */ function (id, data) { if (this.auxGraphs[id]) { this.auxGraphs[id].nodes.add(data); } else { throw new Error("Graph " + id + " doesn't exist."); } }; /** * @description Updates a node in a graph network. * @param id is the graph network id. * @param data is the node info. * @throws Thrown when the graph network doesn't exist. * @memberOf NgxVisNetworkEtsisiService */ /** * \@description Updates a node in a graph network. * @throws Thrown when the graph network doesn't exist. * \@memberOf NgxVisNetworkEtsisiService * @param {?} id is the graph network id. * @param {?} data is the node info. * @return {?} */ NgxVisNetworkEtsisiService.prototype.updateNode = /** * \@description Updates a node in a graph network. * @throws Thrown when the graph network doesn't exist. * \@memberOf NgxVisNetworkEtsisiService * @param {?} id is the graph network id. * @param {?} data is the node info. * @return {?} */ function (id, data) { if (this.auxGraphs[id]) { this.auxGraphs[id].nodes.update(data); } else { throw new Error("Graph " + id + " doesn't exist."); } }; /** * @description Removes a concrete node in a graph network. * @param id is the graph network id. * @param nodeId is the node id. * @throws Thrown when the graph network doesn't exist. * @memberOf NgxVisNetworkEtsisiService */ /** * \@description Removes a concrete node in a graph network. * @throws Thrown when the graph network doesn't exist. * \@memberOf NgxVisNetworkEtsisiService * @param {?} id is the graph network id. * @param {?} nodeId is the node id. * @return {?} */ NgxVisNetworkEtsisiService.prototype.removeNode = /** * \@description Removes a concrete node in a graph network. * @throws Thrown when the graph network doesn't exist. * \@memberOf NgxVisNetworkEtsisiService * @param {?} id is the graph network id. * @param {?} nodeId is the node id. * @return {?} */ function (id, nodeId) { if (this.auxGraphs[id]) { this.auxGraphs[id].nodes.remove(nodeId); } else { throw new Error("Graph " + id + " doesn't exist."); } }; /** * @description Adds a concrete edge in a graph network. * @param id is the graph network id. * @param data is the edge info. * @throws Thrown when the graph network doesn't exist. * @memberOf NgxVisNetworkEtsisiService */ /** * \@description Adds a concrete edge in a graph network. * @throws Thrown when the graph network doesn't exist. * \@memberOf NgxVisNetworkEtsisiService * @param {?} id is the graph network id. * @param {?} data is the edge info. * @return {?} */ NgxVisNetworkEtsisiService.prototype.addEdge = /** * \@description Adds a concrete edge in a graph network. * @throws Thrown when the graph network doesn't exist. * \@memberOf NgxVisNetworkEtsisiService * @param {?} id is the graph network id. * @param {?} data is the edge info. * @return {?} */ function (id, data) { if (this.auxGraphs[id]) { this.auxGraphs[id].edges.add(data); } else { throw new Error("Graph " + id + " doesn't exist."); } }; /** * @description Removes an edge in a graph network. * @param id is the graph network id. * @param edgeId is the edge id. * @throws Thrown when the graph network doesn't exist. * @memberOf NgxVisNetworkEtsisiService */ /** * \@description Removes an edge in a graph network. * @throws Thrown when the graph network doesn't exist. * \@memberOf NgxVisNetworkEtsisiService * @param {?} id is the graph network id. * @param {?} edgeId is the edge id. * @return {?} */ NgxVisNetworkEtsisiService.prototype.removeEdge = /** * \@description Removes an edge in a graph network. * @throws Thrown when the graph network doesn't exist. * \@memberOf NgxVisNetworkEtsisiService * @param {?} id is the graph network id. * @param {?} edgeId is the edge id. * @return {?} */ function (id, edgeId) { if (this.auxGraphs[id]) { this.auxGraphs[id].edges.remove(edgeId); } else { throw new Error("Graph " + id + " doesn't exist."); } }; /** * @description Updates a background node in a graph network for only one node. * @param id is the graph network id. * @param nodeId is the node id that we want to change * @param backgroundColor is the background color to edit the node * @memberOf NgxVisNetworkEtsisiService */ /** * \@description Updates a background node in a graph network for only one node. * \@memberOf NgxVisNetworkEtsisiService * @param {?} id is the graph network id. * @param {?} nodeId is the node id that we want to change * @param {?} backgroundColor is the background color to edit the node * @return {?} */ NgxVisNetworkEtsisiService.prototype.setBackgroundNode = /** * \@description Updates a background node in a graph network for only one node. * \@memberOf NgxVisNetworkEtsisiService * @param {?} id is the graph network id. * @param {?} nodeId is the node id that we want to change * @param {?} backgroundColor is the background color to edit the node * @return {?} */ function (id, nodeId, backgroundColor) { /** @type {?} */ var selectedNode = this.getNodes(id).get(nodeId); this.updateNode(id, __assign({}, selectedNode, { color: { background: backgroundColor } })); }; /** * @description Gets the node positions using an array of nodes id for a graph node. * @param id is the graph network id. * @param nodeIds is the array of nodes id. * @memberOf NgxVisNetworkEtsisiService */ /** * \@description Gets the node positions using an array of nodes id for a graph node. * \@memberOf NgxVisNetworkEtsisiService * @param {?} id is the graph network id. * @param {?} nodeIds is the array of nodes id. * @return {?} */ NgxVisNetworkEtsisiService.prototype.getNodePositions = /** * \@description Gets the node positions using an array of nodes id for a graph node. * \@memberOf NgxVisNetworkEtsisiService * @param {?} id is the graph network id. * @param {?} nodeIds is the array of nodes id. * @return {?} */ function (id, nodeIds) { return this.auxGraphs[id].network.getPositions(nodeIds); }; /** * @description It comes back to the initial state for a graph network. * @param id is the graph network id. * @throws Thrown when the graph network doesn't exist. * @memberOf NgxVisNetworkEtsisiService */ /** * \@description It comes back to the initial state for a graph network. * @throws Thrown when the graph network doesn't exist. * \@memberOf NgxVisNetworkEtsisiService * @param {?} id is the graph network id. * @return {?} */ NgxVisNetworkEtsisiService.prototype.resetGraph = /** * \@description It comes back to the initial state for a graph network. * @throws Thrown when the graph network doesn't exist. * \@memberOf NgxVisNetworkEtsisiService * @param {?} id is the graph network id. * @return {?} */ function (id) { if (this.auxGraphs[id]) { this.setOptions(id, this.seedGraphs[id].options); this.updateNode(id, this.seedGraphs[id].nodes); this.updateEdge(id, this.seedGraphs[id].edges); } else { throw new Error("Graph " + id + " doesn't exist."); } }; /** * @description If you like the layout of your network and would like it to start in the same way next time, * ask for the seed using this method * and put it in the layout.randomSeed option. * @param id is the graph network id. * @returns id of the previous seed * @memberOf NgxVisNetworkEtsisiService */ /** * \@description If you like the layout of your network and would like it to start in the same way next time, * ask for the seed using this method * and put it in the layout.randomSeed option. * \@memberOf NgxVisNetworkEtsisiService * @param {?} id is the graph network id. * @return {?} id of the previous seed */ NgxVisNetworkEtsisiService.prototype.getSeed = /** * \@description If you like the layout of your network and would like it to start in the same way next time, * ask for the seed using this method * and put it in the layout.randomSeed option. * \@memberOf NgxVisNetworkEtsisiService * @param {?} id is the graph network id. * @return {?} id of the previous seed */ function (id) { if (this.auxGraphs[id]) { return this.auxGraphs[id].network.getSeed(); } return -1; }; /** * @description Zooms out so all nodes fit on the canvas. * @param id is the graph network id. * @param options to fit the graph network. * @throws Thrown when the graph network doesn't exist. * @memberOf NgxVisNetworkEtsisiService */ /** * \@description Zooms out so all nodes fit on the canvas. * @throws Thrown when the graph network doesn't exist. * \@memberOf NgxVisNetworkEtsisiService * @param {?} id is the graph network id. * @param {?=} options to fit the graph network. * @return {?} */ NgxVisNetworkEtsisiService.prototype.fit = /** * \@description Zooms out so all nodes fit on the canvas. * @throws Thrown when the graph network doesn't exist. * \@memberOf NgxVisNetworkEtsisiService * @param {?} id is the graph network id. * @param {?=} options to fit the graph network. * @return {?} */ function (id, options) { if (this.auxGraphs[id]) { this.auxGraphs[id].network.fit(options); } else { throw new Error("Graph " + id + " doesn't exist."); } }; /** * @description Redraw a graph network. * @param id is the graph network id. * @throws Thrown when the graph network doesn't exist. * @memberOf NgxVisNetworkEtsisiService */ /** * \@description Redraw a graph network. * @throws Thrown when the graph network doesn't exist. * \@memberOf NgxVisNetworkEtsisiService * @param {?} id is the graph network id. * @return {?} */ NgxVisNetworkEtsisiService.prototype.redraw = /** * \@description Redraw a graph network. * @throws Thrown when the graph network doesn't exist. * \@memberOf NgxVisNetworkEtsisiService * @param {?} id is the graph network id. * @return {?} */ function (id) { if (this.auxGraphs[id]) { this.auxGraphs[id].network.redraw(); } else { throw new Error("Graph " + id + " doesn't exist."); } }; /** * @description Returns the current scale of the network. 1.0 is comparable to 100%, 0 is zoomed out infinitely. * @param id is the graph network id. * @throws Thrown when the graph network doesn't exist. * @memberOf NgxVisNetworkEtsisiService */ /** * \@description Returns the current scale of the network. 1.0 is comparable to 100%, 0 is zoomed out infinitely. * @throws Thrown when the graph network doesn't exist. * \@memberOf NgxVisNetworkEtsisiService * @param {?} id is the graph network id. * @return {?} */ NgxVisNetworkEtsisiService.prototype.getScale = /** * \@description Returns the current scale of the network. 1.0 is comparable to 100%, 0 is zoomed out infinitely. * @throws Thrown when the graph network doesn't exist. * \@memberOf NgxVisNetworkEtsisiService * @param {?} id is the graph network id. * @return {?} */ function (id) { if (this.auxGraphs[id]) { return this.auxGraphs[id].network.getScale(); } else { throw new Error("Graph " + id + " doesn't exist."); } }; /** * @description This function converts canvas coordinates to coordinates on the DOM. * Input and output are in the form of {x:Number,y:Number}. * The DOM values are relative to the network container. * @param id is the graph network id. * @param position is the Canvas coordinates. * @throws Thrown when the graph network doesn't exist. * @memberOf NgxVisNetworkEtsisiService */ /** * \@description This function converts canvas coordinates to coordinates on the DOM. * Input and output are in the form of {x:Number,y:Number}. * The DOM values are relative to the network container. * @throws Thrown when the graph network doesn't exist. * \@memberOf NgxVisNetworkEtsisiService * @param {?} id is the graph network id. * @param {?} position is the Canvas coordinates. * @return {?} */ NgxVisNetworkEtsisiService.prototype.canvasToDom = /** * \@description This function converts canvas coordinates to coordinates on the DOM. * Input and output are in the form of {x:Number,y:Number}. * The DOM values are relative to the network container. * @throws Thrown when the graph network doesn't exist. * \@memberOf NgxVisNetworkEtsisiService * @param {?} id is the graph network id. * @param {?} position is the Canvas coordinates. * @return {?} */ function (id, position) { if (this.auxGraphs[id]) { return this.auxGraphs[id].network.canvasToDOM(position); } else { throw new Error("Graph " + id + " doesn't exist."); } }; /** * @description This function converts DOM coordinates to coordinates on the canvas. * Input and output are in the form of {x:Number,y:Number}. * The DOM values are relative to the network container. * @param id is the graph network id. * @param position is the Canvas coordinates. * @throws Thrown when the graph network doesn't exist. * @memberOf NgxVisNetworkEtsisiService */ /** * \@description This function converts DOM coordinates to coordinates on the canvas. * Input and output are in the form of {x:Number,y:Number}. * The DOM values are relative to the network container. * @throws Thrown when the graph network doesn't exist. * \@memberOf NgxVisNetworkEtsisiService * @param {?} id is the graph network id. * @param {?} position is the Canvas coordinates. * @return {?} */ NgxVisNetworkEtsisiService.prototype.domToCanvas = /** * \@description This function converts DOM coordinates to coordinates on the canvas. * Input and output are in the form of {x:Number,y:Number}. * The DOM values are relative to the network container. * @throws Thrown when the graph network doesn't exist. * \@memberOf NgxVisNetworkEtsisiService * @param {?} id is the graph network id. * @param {?} position is the Canvas coordinates. * @return {?} */ function (id, position) { if (this.auxGraphs[id]) { return this.auxGraphs[id].network.DOMtoCanvas(position); } else { throw new Error("Graph " + id + " doesn't exist."); } }; /** * @description Sets an event listener. Depending on the type of event you get different parameters for the callback function. * Look at the event section of the documentation for more information. * @param id is the graph network id. * @param eventName is the event name that we want to listen. * @param preventDefault is to stop the default behaviour of the event. * @memberOf NgxVisNetworkEtsisiService */ /** * \@description Sets an event listener. Depending on the type of event you get different parameters for the callback function. * Look at the event section of the documentation for more information. * \@memberOf NgxVisNetworkEtsisiService * @param {?} id is the graph network id. * @param {?} eventName is the event name that we want to listen. * @param {?=} preventDefault is to stop the default behaviour of the event. * @return {?} */ NgxVisNetworkEtsisiService.prototype.on = /** * \@description Sets an event listener. Depending on the type of event you get different parameters for the callback function. * Look at the event section of the documentation for more information. * \@memberOf NgxVisNetworkEtsisiService * @param {?} id is the graph network id. * @param {?} eventName is the event name that we want to listen. * @param {?=} preventDefault is to stop the default behaviour of the event. * @return {?} */ function (id, eventName, preventDefault) { if (this.auxGraphs[id]) { /** @type {?} */ var that_1 = this; this.auxGraphs[id].network.on(eventName, (/** * @param {?} params * @return {?} */ function (params) { /** @type {?} */ var emitter = (/** @type {?} */ (that_1[eventName])); if (emitter) { emitter.emit(params ? [id].concat(params) : id); } if (preventDefault && params.event) { params.event.preventDefault(); } })); return true; } return false; }; /** * @description Removes an event listener. The function you supply has to be the exact same as the one you used in the on function. * If no function is supplied, all listeners will be removed. * Look at the event section of the documentation for more information. * @param id is the graph network id. * @param eventName is the event name that we want to listen. * @memberOf NgxVisNetworkEtsisiService */ /** * \@description Removes an event listener. The function you supply has to be the exact same as the one you used in the on function. * If no function is supplied, all listeners will be removed. * Look at the event section of the documentation for more information. * \@memberOf NgxVisNetworkEtsisiService * @param {?} id is the graph network id. * @param {?} eventName is the event name that we want to listen. * @return {?} */ NgxVisNetworkEtsisiService.prototype.off = /** * \@description Removes an event listener. The function you supply has to be the exact same as the one you used in the on function. * If no function is supplied, all listeners will be removed. * Look at the event section of the documentation for more information. * \@memberOf NgxVisNetworkEtsisiService * @param {?} id is the graph network id. * @param {?} eventName is the event name that we want to listen. * @return {?} */ function (id, eventName) { if (this.auxGraphs[id]) { this.auxGraphs[id].network.off(eventName); } }; /** * @description Sets an event listener only once. After it has taken place, the event listener will be removed. * Depending on the type of event you get different parameters for the callback function. * Look at the event section of the documentation for more information. * @param id is the graph network id. * @param eventName is the event name that we want to listen. * @memberOf NgxVisNetworkEtsisiService */ /** * \@description Sets an event listener only once. After it has taken place, the event listener will be removed. * Depending on the type of event you get different parameters for the callback function. * Look at the event section of the documentation for more information. * \@memberOf NgxVisNetworkEtsisiService * @param {?} id is the graph network id. * @param {?} eventName is the event name that we want to listen. * @return {?} */ NgxVisNetworkEtsisiService.prototype.once = /** * \@description Sets an event listener only once. After it has taken place, the event listener will be removed. * Depending on the type of event you get different parameters for the callback function. * Look at the event section of the documentation for more information. * \@memberOf NgxVisNetworkEtsisiService * @param {?} id is the graph network id. * @param {?} eventName is the event name that we want to listen. * @return {?} */ function (id, eventName) { var _this = this; if (this.auxGraphs[id]) { /** @type {?} */ var that_2 = this; this.auxGraphs[id].network.on(eventName, (/** * @param {?} params * @return {?} */ function (params) { /** @type {?} */ var emitter = (/** @type {?} */ (that_2[eventName])); if (emitter) { emitter.emit(params ? [id].concat(params) : id); _this.off(id, eventName); } })); return true; } return false; }; /** * @description Removes the network from the DOM and remove all Hammer bindings and references. * @param id is the graph network id. * @throws Thrown when the graph network doesn't exist. * @memberOf NgxVisNetworkEtsisiService */ /** * \@description Removes the network from the DOM and remove all Hammer bindings and references. * @throws Thrown when the graph network doesn't exist. * \@memberOf NgxVisNetworkEtsisiService * @param {?} id is the graph network id. * @return {?} */ NgxVisNetworkEtsisiService.prototype.destroy = /** * \@description Removes the network from the DOM and remove all Hammer bindings and references. * @throws Thrown when the graph network doesn't exist. * \@memberOf NgxVisNetworkEtsisiService * @param {?} id is the graph network id. * @return {?} */ function (id) { if (this.auxGraphs[id]) { this.auxGraphs[id].network.destroy(); delete this.auxGraphs[id]; } else { throw new Error("Graph " + id + " doesn't exist."); } }; /** * @description Updates an edge in a graph network. * @param id is the graph network id. * @param data is the edge info. * @throws Thrown when the graph network doesn't exist. * @memberOf NgxVisNetworkEtsisiService */ /** * \@description Updates an edge in a graph network. * @throws Thrown when the graph network doesn't exist. * \@memberOf NgxVisNetworkEtsisiService * @param {?} id is the graph network id. * @param {?} data is the edge info. * @return {?} */ NgxVisNetworkEtsisiService.prototype.updateEdge = /** * \@description Updates an edge in a graph network. * @throws Thrown when the graph network doesn't exist. * \@memberOf NgxVisNetworkEtsisiService * @param {?} id is the graph network id. * @param {?} data is the edge info. * @return {?} */ function (id, data) { if (this.auxGraphs[id]) { this.auxGraphs[id].edges.update(data); } else { throw new Error("Graph " + id + " doesn't exist."); } }; /** * @description Sets the options in a graph network. * @param id is the graph network id. * @param options is the configuration to modify a graph network. * @throws Thrown when the graph network doesn't exist. * @memberOf NgxVisNetworkEtsisiService */ /** * \@description Sets the options in a graph network. * @throws Thrown when the graph network doesn't exist. * \@memberOf NgxVisNetworkEtsisiService * @param {?} id is the graph network id. * @param {?} options is the configuration to modify a graph network. * @return {?} */ NgxVisNetworkEtsisiService.prototype.setOptions = /** * \@description Sets the options in a graph network. * @throws Thrown when the graph network doesn't exist. * \@memberOf NgxVisNetworkEtsisiService * @param {?} id is the graph network id. * @param {?} options is the configuration to modify a graph network. * @return {?} */ function (id, options) { if (this.auxGraphs[id]) { this.auxGraphs[id].network.setOptions(options); } else { throw new Error("Graph " + id + " doesn't exist."); } }; /** * @description Sets the data in a graph network. * @param id is the graph network id. * @param data is the data to modify a graph network. * @throws Thrown when the graph network doesn't exist. * @memberOf NgxVisNetworkEtsisiService */ /** * \@description Sets the data in a graph network. * @throws Thrown when the graph network doesn't exist. * \@memberOf NgxVisNetworkEtsisiService * @param {?} id is the graph network id. * @param {?} data is the data to modify a graph network. * @return {?} */ NgxVisNetworkEtsisiService.prototype.setData = /** * \@description Sets the data in a graph network. * @throws Thrown when the graph network doesn't exist. * \@memberOf NgxVisNetworkEtsisiService * @param {?} id is the graph network id. * @param {?} data is the data to modify a graph network. * @return {?} */ function (id, data) { if (this.auxGraphs[id]) { this.auxGraphs[id].network.setData(data); } else { throw new Error("Graph " + id + " doesn't exist."); } }; /** * @description Selects the nodes of the parameter nodeIds in a graph network * @param id is the graph network id. * @param nodeIds is an array of node ids. * @param highlightEdges is a flag to indicate if it highlights the edges. * @throws Thrown when the graph network doesn't exist. * @memberOf NgxVisNetworkEtsisiService */ /** * \@description Selects the nodes of the parameter nodeIds in a graph network * @throws Thrown when the graph network doesn't exist. * \@memberOf NgxVisNetworkEtsisiService * @param {?} id is the graph network id. * @param {?} nodeIds is an array of node ids. * @param {?=} highlightEdges is a flag to indicate if it highlights the edges. * @return {?} */ NgxVisNetworkEtsisiService.prototype.selectNodes = /** * \@description Selects the nodes of the parameter nodeIds in a graph network * @throws Thrown when the graph network doesn't exist. * \@memberOf NgxVisNetworkEtsisiService * @param {?} id is the graph network id. * @param {?} nodeIds is an array of node ids. * @param {?=} highlightEdges is a flag to indicate if it highlights the edges. * @return {?} */ function (id, nodeIds, highlightEdges) { if (this.auxGraphs[id]) { this.auxGraphs[id].network.selectNodes(nodeIds, highlightEdges); } else { throw new Error("Graph " + id + " doesn't exist."); } }; /** * @description Starts the physic simulation for a graph network * @param id is the graph network id. * @throws Thrown when the graph network doesn't exist. * @memberOf NgxVisNetworkEtsisiService */ /** * \@description Starts the physic simulation for a graph network * @throws Thrown when the graph network doesn't exist. * \@memberOf NgxVisNetworkEtsisiService * @param {?} id is the graph network id. * @return {?} */ NgxVisNetworkEtsisiService.prototype.startSimulation = /** * \@description Starts the physic simulation for a graph network * @throws Thrown when the graph network doesn't exist. * \@memberOf NgxVisNetworkEtsisiService * @param {?} id is the graph network id. * @return {?} */ function (id) { if (this.auxGraphs[id]) { this.auxGraphs[id].network.startSimulation(); } else { throw new Error("Graph " + id + " doesn't exist."); } }; /** * @description Stops the physic simulation for a graph network * @param id is the graph network id. * @throws Thrown when the graph network doesn't exist. * @memberOf NgxVisNetworkEtsisiService */ /** * \@description Stops the physic simulation for a graph network * @throws Thrown when the graph network doesn't exist. * \@memberOf NgxVisNetworkEtsisiService * @param {?} id is the graph network id. * @return {?} */ NgxVisNetworkEtsisiService.prototype.stopSimulation = /** * \@description Stops the physic simulation for a graph network * @throws Thrown when the graph network doesn't exist. * \@memberOf NgxVisNetworkEtsisiService * @param {?} id is the graph network id. * @return {?} */ function (id) { if (this.auxGraphs[id]) { this.auxGraphs[id].network.stopSimulation(); } else { throw new Error("Graph " + id + " doesn't exist."); } }; /** * @description Moves a graph network using the moveToOptions * @param id is the graph network id. * @param moveToOptions is the options to move the graph. * @throws Thrown when the graph network doesn't exist. * @memberOf NgxVisNetworkEtsisiService */ /** * \@description Moves a graph network using the moveToOptions * @throws Thrown when the graph network doesn't exist. * \@memberOf NgxVisNetworkEtsisiService * @param {?} id is the graph network id. * @param {?} moveToOptions is the options to move the graph. * @return {?} */ NgxVisNetworkEtsisiService.prototype.moveTo = /** * \@description Moves a graph network using the moveToOptions * @throws Thrown when the graph network doesn't exist. * \@memberOf NgxVisNetworkEtsisiService * @param {?} id is the graph network id. * @param {?} moveToOptions is the options to move the graph. * @return {?} */ function (id, moveToOptions) { if (this.auxGraphs[id]) { this.auxGraphs[id].network.moveTo(moveToOptions); } else { throw new Error("Graph " + id + " doesn't exist."); } }; /** * @description Gets the connected edges using a node id for a graph network. * @param id is the graph network id. * @param nodeId is the id of the node to obtain its connected edges. * @throws Thrown when the graph network doesn't exist. * @memberOf NgxVisNetworkEtsisiService */ /** * \@description Gets the connected edges using a node id for a graph network. * @throws Thrown when the graph network doesn't exist. * \@memberOf NgxVisNetworkEtsisiService * @param {?} id is the graph network id. * @param {?} nodeId is the id of the node to obtain its connected edges. * @return {?} */ NgxVisNetworkEtsisiService.prototype.getConnectedEdges = /** * \@description Gets the connected edges using a node id for a graph network. * @throws Thrown when the graph network doesn't exist. * \@memberOf NgxVisNetworkEtsisiService * @param {?} id is the graph network id. * @param {?} nodeId is the id of the node to obtain its connected edges. * @return {?} */ function (id, nodeId) { if (this.auxGraphs[id]) { this.auxGraphs[id].network.getConnectedEdges(nodeId); } else { throw new Error("Graph " + id + " doesn't exist."); } }; /** * @description Gets the connected nodes using a node/edge id for a graph network. * @param id is the graph network id. * @param nodeOrEdgeId is the id of the node/edge to obtain its connected nodes. * @throws {Error} Thrown when the graph network doesn't exist. * @memberOf NgxVisNetworkEtsisiService */ /** * \@description Gets the connected nodes using a node/edge id for a graph network. * @throws {Error} Thrown when the graph network doesn't exist. * \@memberOf NgxVisNetworkEtsisiService * @param {?} id is the graph network id. * @param {?} nodeOrEdgeId is the id of the node/edge to obtain its connected nodes. * @return {?} */ NgxVisNetworkEtsisiService.prototype.getConnectedNodes = /** * \@description Gets the connected nodes using a node/edge id for a graph network. * @throws {Error} Thrown when the graph network doesn't exist. * \@memberOf NgxVisNetworkEtsisiService * @param {?} id is the graph network id. * @param {?} nodeOrEdgeId is the id of the node/edge to obtain its connected nodes. * @return {?} */ function (id, nodeOrEdgeId) { if (this.auxGraphs[id]) { this.auxGraphs[id].network.getConnectedNodes(nodeOrEdgeId); } else { throw new Error("Graph " + id + " doesn't exist."); } }; /** * @description Gets the selected nodes for a graph network. * @param id is the graph network id. * @throws Thrown