import {Component, ViewChild} from "@angular/core"; import {VisNgNetworkNode, VisNgNetworkEdge} from "../core"; import {VisNetworkComponent} from "../core/vis-network/vis-network.component"; import {VisNgNetworkOptions} from "../core/vis-network/interfaces/vis-ng-network-options.interface"; import {VisNetworkService} from '../core'; @Component({ selector: 'app-root', templateUrl: 'playground.component.html', styleUrls: ['playground.component.scss'], }) export class PlaygroundComponent { public nodes: VisNgNetworkNode[] = [ {id: '1', label: 'A'}, {id: '2', label: 'B'}, ]; public edges: VisNgNetworkEdge[] = [ {id: '1', from: '1', to: '2', label: '1-2', name: '1-2'}, ]; public options: VisNgNetworkOptions = { nodes: { color: { background: 'blue', }, }, physics: { enabled: false, } }; @ViewChild(VisNetworkComponent) private visNetworkRef: VisNetworkComponent; public getRawNetworkInstance() { console.log(this.visNetworkRef.rawNetworkInstance); } public getRawNetworkNodes() { console.log(this.visNetworkRef.rawNodes); } public getRawNetworkEdges() { console.log(this.visNetworkRef.rawEdges); } public getPositions() { console.log(this.service.getPositions()); } private b = true; public setPositions() { let map = new Map(); if (this.b = !this.b) { map.set('1', {x: 0, y: 0}); map.set('2', {x: 0, y: -100}); } else { map.set('1', {x: 0, y: 100}); map.set('2', {x: 100, y: 0}); } this.service.setPositions(map); } public toggleGlobalOptions() { // const next = this.options.nodes.color.background == 'red' ? 'blue' : 'red'; // this.options.nodes.color.background = next; // this.options = Object.assign({}, this.options); } // TODO public toggleOneLabel() { if (this.nodes[0].label == 'A') { this.nodes[0] = Object.assign(this.nodes[0], {label: 'AA'}); } else { this.nodes[0] = Object.assign(this.nodes[0], {label: 'A'}); } this.nodes = this.nodes.concat(); } constructor(private service: VisNetworkService) { } ngOnInit() { console.log(this.service); } }