|
4 | 4 | </template>
|
5 | 5 |
|
6 | 6 | <script>
|
7 |
| - import { GraphComponent, GraphEditorInputMode, License, Point, Rect } from 'yfiles' |
8 |
| - import licenseData from '../license.json' |
9 |
| -
|
10 |
| - License.value = licenseData |
11 |
| -
|
12 |
| - export default { |
13 |
| - name: 'GraphComponent', |
14 |
| - mounted() { |
15 |
| - // instantiate a new GraphComponent |
16 |
| - this.graphComponent = new GraphComponent('#graph-component') |
17 |
| -
|
18 |
| - // configure an input mode for out of the box editing |
19 |
| - this.graphComponent.inputMode = new GraphEditorInputMode() |
20 |
| -
|
21 |
| - // create some graph elements |
22 |
| - this.createSampleGraph(this.graphComponent.graph) |
23 |
| -
|
24 |
| - // center the newly created graph |
25 |
| - this.graphComponent.fitGraphBounds() |
| 7 | +import { GraphComponent, GraphEditorInputMode, License, Point, Rect } from 'yfiles' |
| 8 | +import licenseData from '../license.json' |
| 9 | +
|
| 10 | +License.value = licenseData |
| 11 | +
|
| 12 | +export default { |
| 13 | + name: 'GraphComponent', |
| 14 | + mounted() { |
| 15 | + // instantiate a new GraphComponent |
| 16 | + this.graphComponent = new GraphComponent('#graph-component') |
| 17 | +
|
| 18 | + // configure an input mode for out of the box editing |
| 19 | + this.graphComponent.inputMode = new GraphEditorInputMode() |
| 20 | +
|
| 21 | + // create some graph elements |
| 22 | + this.createSampleGraph(this.graphComponent.graph) |
| 23 | +
|
| 24 | + // center the newly created graph |
| 25 | + this.graphComponent.fitGraphBounds() |
| 26 | + }, |
| 27 | + methods: { |
| 28 | + createSampleGraph(graph) { |
| 29 | + // create some nodes |
| 30 | + const node1 = graph.createNodeAt(new Point(30, 30)) |
| 31 | + const node2 = graph.createNodeAt(new Point(150, 30)) |
| 32 | + const node3 = graph.createNode(new Rect(230, 200, 60, 30)) |
| 33 | +
|
| 34 | + // create some edges between the nodes |
| 35 | + graph.createEdge(node1, node2) |
| 36 | + graph.createEdge(node1, node3) |
| 37 | + const edge = graph.createEdge(node2, node3) |
| 38 | + // Creates the first bend for edge at (260, 30) |
| 39 | + graph.addBend(edge, new Point(260, 30)) |
| 40 | +
|
| 41 | + // add labels to some graph elements |
| 42 | + graph.addLabel(node1, 'n1') |
| 43 | + graph.addLabel(node2, 'n2') |
| 44 | + graph.addLabel(node3, 'n3') |
26 | 45 | },
|
27 |
| - methods: { |
28 |
| - createSampleGraph(graph) { |
29 |
| - // create some nodes |
30 |
| - const node1 = graph.createNodeAt(new Point(30, 30)) |
31 |
| - const node2 = graph.createNodeAt(new Point(150, 30)) |
32 |
| - const node3 = graph.createNode(new Rect(230, 200, 60, 30)) |
33 |
| -
|
34 |
| - // create some edges between the nodes |
35 |
| - graph.createEdge(node1, node2) |
36 |
| - graph.createEdge(node1, node3) |
37 |
| - const edge = graph.createEdge(node2, node3) |
38 |
| - // Creates the first bend for edge at (260, 30) |
39 |
| - graph.addBend(edge, new Point(260, 30)) |
40 |
| -
|
41 |
| - // add labels to some graph elements |
42 |
| - graph.addLabel(node1, 'n1') |
43 |
| - graph.addLabel(node2, 'n2') |
44 |
| - graph.addLabel(node3, 'n3') |
45 |
| - } |
46 |
| - } |
47 |
| - } |
| 46 | + }, |
| 47 | +} |
48 | 48 | </script>
|
49 | 49 |
|
50 | 50 | <style scoped>
|
51 |
| -/* yfiles.css is an integral part of the library and must be loaded wherever a yFiles GraphComponent is created */ |
52 |
| -@import '~yfiles/yfiles.css'; |
53 |
| -
|
54 | 51 | #graph-component {
|
55 | 52 | width: 500px;
|
56 | 53 | height: 500px;
|
|
0 commit comments