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,070 lines (1,042 loc) 126 kB
(function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/common'), require('@angular/core'), require('vis-network/standalone')) : typeof define === 'function' && define.amd ? define('ngx-vis-network-etsisi', ['exports', '@angular/common', '@angular/core', 'vis-network/standalone'], factory) : (global = global || self, factory(global['ngx-vis-network-etsisi'] = {}, global.ng.common, global.ng.core, global.standalone)); }(this, (function (exports, common, core, standalone) { '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. ***************************************************************************** */ /* global Reflect, Promise */ var extendStatics = function(d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return extendStatics(d, b); }; function __extends(d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); } var __assign = function() { __assign = Object.assign || function __assign(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } return t; }; return __assign.apply(this, arguments); }; function __rest(s, e) { var t = {}; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p]; if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]]; } return t; } function __decorate(decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; } function __param(paramIndex, decorator) { return function (target, key) { decorator(target, key, paramIndex); } } function __metadata(metadataKey, metadataValue) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue); } function __awaiter(thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); } function __generator(thisArg, body) { var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; function verb(n) { return function (v) { return step([n, v]); }; } function step(op) { if (f) throw new TypeError("Generator is already executing."); while (_) try { if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; if (y = 0, t) op = [op[0] & 2, t.value]; switch (op[0]) { case 0: case 1: t = op; break; case 4: _.label++; return { value: op[1], done: false }; case 5: _.label++; y = op[1]; op = [0]; continue; case 7: op = _.ops.pop(); _.trys.pop(); continue; default: if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } if (t[2]) _.ops.pop(); _.trys.pop(); continue; } op = body.call(thisArg, _); } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; } } function __createBinding(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; } function __exportStar(m, exports) { for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) exports[p] = m[p]; } function __values(o) { var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; if (m) return m.call(o); if (o && typeof o.length === "number") return { next: function () { if (o && i >= o.length) o = void 0; return { value: o && o[i++], done: !o }; } }; throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); } function __read(o, n) { var m = typeof Symbol === "function" && o[Symbol.iterator]; if (!m) return o; var i = m.call(o), r, ar = [], e; try { while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); } catch (error) { e = { error: error }; } finally { try { if (r && !r.done && (m = i["return"])) m.call(i); } finally { if (e) throw e.error; } } return ar; } function __spread() { for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i])); return ar; } function __spreadArrays() { for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length; for (var r = Array(s), k = 0, i = 0; i < il; i++) for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++) r[k] = a[j]; return r; }; function __await(v) { return this instanceof __await ? (this.v = v, this) : new __await(v); } function __asyncGenerator(thisArg, _arguments, generator) { if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); var g = generator.apply(thisArg, _arguments || []), i, q = []; return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } function fulfill(value) { resume("next", value); } function reject(value) { resume("throw", value); } function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } } function __asyncDelegator(o) { var i, p; return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i; function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; } } function __asyncValues(o) { if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); var m = o[Symbol.asyncIterator], i; return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i); function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; } function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); } } function __makeTemplateObject(cooked, raw) { if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; } return cooked; }; function __importStar(mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; result.default = mod; return result; } function __importDefault(mod) { return (mod && mod.__esModule) ? mod : { default: mod }; } function __classPrivateFieldGet(receiver, privateMap) { if (!privateMap.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return privateMap.get(receiver); } function __classPrivateFieldSet(receiver, privateMap, value) { if (!privateMap.has(receiver)) { throw new TypeError("attempted to set private field on non-instance"); } privateMap.set(receiver, value); return value; } /** * @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 core.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 core.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 core.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 core.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 core.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 core.EventEmitter(); /** * \@description Fired when a node has been selected by the user. * \@memberOf NgxVisNetworkEtsisiService */ this.selectNode = new core.EventEmitter(); /** * Fired when an edge has been selected by the user. * \@memberOf NgxVisNetworkEtsisiService */ this.selectEdge = new core.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 core.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 core.EventEmitter(); /** * \@description Fired when starting a drag. * \@memberOf NgxVisNetworkEtsisiService */ this.dragStart = new core.EventEmitter(); /** * \@description Fired when dragging node(s) or the view. * \@memberOf NgxVisNetworkEtsisiService */ this.dragging = new core.EventEmitter(); /** * \@description Fired when the drag has finished. * \@memberOf NgxVisNetworkEtsisiService */ this.dragEnd = new core.EventEmitter(); /** * \@description Fired if the option interaction:{hover:true} is enabled and the mouse hovers over a node. * \@memberOf NgxVisNetworkEtsisiService */ this.hoverNode = new core.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 core.EventEmitter(); /** * \@description Fired if the option interaction:{hover:true} is enabled and the mouse hovers over an edge. * \@memberOf NgxVisNetworkEtsisiService */ this.hoverEdge = new core.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 core.EventEmitter(); /** * \@description Fired when the popup (tooltip) is shown. * \@memberOf NgxVisNetworkEtsisiService */ this.showPopup = new core.EventEmitter(); /** * \@description Fired when the popup (tooltip) is hidden. * \@memberOf NgxVisNetworkEtsisiService */ this.hidePopup = new core.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 core.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 core.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 core.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 core.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 core.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 core.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 core.EventEmitter(); /** * \@description Fired when an animation is finished. * \@memberOf NgxVisNetworkEtsisiService */ this.animationFinished = new core.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 core.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 core.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 core.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 standalone.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. * Loo