|
1 | | -import { AfterViewInit, Component, ElementRef, ViewChild } from '@angular/core' |
2 | | -import { GraphComponent, GraphEditorInputMode, License, Point, Rect } from 'yfiles' |
3 | | -import licenseData from '../../license.json' |
| 1 | +import { AfterViewInit, Component, ElementRef, ViewChild } from '@angular/core'; |
| 2 | +import { GraphComponent, GraphEditorInputMode, License, Point, Rect } from 'yfiles'; |
| 3 | +import licenseData from '../../license.json'; |
4 | 4 |
|
5 | | -License.value = licenseData |
| 5 | +License.value = licenseData; |
6 | 6 |
|
7 | 7 | @Component({ |
8 | 8 | selector: 'app-graph-component', |
9 | 9 | templateUrl: './graph-component.component.html', |
10 | 10 | styleUrls: ['./graph-component.component.css'] |
11 | 11 | }) |
12 | 12 | export class GraphComponentComponent implements AfterViewInit { |
13 | | - @ViewChild('graphComponentRef', { static: false }) graphComponentRef!: ElementRef |
14 | | - graphComponent!: GraphComponent |
| 13 | + @ViewChild('graphComponentRef', { static: false }) graphComponentRef!: ElementRef; |
| 14 | + graphComponent!: GraphComponent; |
15 | 15 |
|
16 | 16 | ngAfterViewInit() { |
17 | 17 | // instantiate a new GraphComponent |
18 | | - this.graphComponent = new GraphComponent(this.graphComponentRef.nativeElement) |
| 18 | + this.graphComponent = new GraphComponent(this.graphComponentRef.nativeElement); |
19 | 19 |
|
20 | 20 | // configure an input mode for out of the box editing |
21 | | - this.graphComponent.inputMode = new GraphEditorInputMode() |
| 21 | + this.graphComponent.inputMode = new GraphEditorInputMode(); |
22 | 22 |
|
23 | 23 | // create some graph elements |
24 | | - this.createSampleGraph(this.graphComponent.graph) |
| 24 | + this.createSampleGraph(this.graphComponent.graph); |
25 | 25 |
|
26 | 26 | // center the newly created graph |
27 | | - this.graphComponent.fitGraphBounds() |
| 27 | + this.graphComponent.fitGraphBounds(); |
28 | 28 | } |
29 | 29 |
|
30 | 30 | createSampleGraph(graph) { |
31 | 31 | // create some nodes |
32 | | - const node1 = graph.createNodeAt(new Point(30, 30)) |
33 | | - const node2 = graph.createNodeAt(new Point(150, 30)) |
34 | | - const node3 = graph.createNode(new Rect(230, 200, 60, 30)) |
| 32 | + const node1 = graph.createNodeAt(new Point(30, 30)); |
| 33 | + const node2 = graph.createNodeAt(new Point(150, 30)); |
| 34 | + const node3 = graph.createNode(new Rect(230, 200, 60, 30)); |
35 | 35 |
|
36 | 36 | // create some edges between the nodes |
37 | | - graph.createEdge(node1, node2) |
38 | | - graph.createEdge(node1, node3) |
39 | | - const edge = graph.createEdge(node2, node3) |
| 37 | + graph.createEdge(node1, node2); |
| 38 | + graph.createEdge(node1, node3); |
| 39 | + const edge = graph.createEdge(node2, node3); |
40 | 40 | // Creates the first bend for edge at (260, 30) |
41 | | - graph.addBend(edge, new Point(260, 30)) |
| 41 | + graph.addBend(edge, new Point(260, 30)); |
42 | 42 |
|
43 | 43 | // add labels to some graph elements |
44 | | - graph.addLabel(node1, 'n1') |
45 | | - graph.addLabel(node2, 'n2') |
46 | | - graph.addLabel(node3, 'n3') |
| 44 | + graph.addLabel(node1, 'n1'); |
| 45 | + graph.addLabel(node2, 'n2'); |
| 46 | + graph.addLabel(node3, 'n3'); |
47 | 47 | } |
48 | 48 | } |
0 commit comments