|
| 1 | +<template> |
| 2 | + <div class="container" > |
| 3 | + <ejs-button class="button" @click="drawNode">Draw Node</ejs-button> |
| 4 | + <ejs-button class="button" @click="editNode">Edit Node</ejs-button> |
| 5 | + <ejs-button class="button" @click="removeNode">Remove Node</ejs-button> |
| 6 | + </div> |
| 7 | + <ejs-diagram ref="diagramObject" :width="width" :height="height" /> |
| 8 | +</template> |
| 9 | + |
| 10 | +<script> |
| 11 | +import { |
| 12 | + DiagramComponent, DiagramTools |
| 13 | +} from '@syncfusion/ej2-vue-diagrams'; |
| 14 | +import { ButtonComponent } from '@syncfusion/ej2-vue-buttons'; |
| 15 | +
|
| 16 | +let nodes = [ |
| 17 | + { |
| 18 | + offsetX: 300, |
| 19 | + offsetY: 250, |
| 20 | + width: 200, |
| 21 | + height: 100, |
| 22 | + //annotations: [{content: "Basic"},{content: "Rectangle", offset: {y:0.6}}], |
| 23 | + annotations: [{content: "Flow"},{content: "Terminator", offset: {y:0.6}}], |
| 24 | + style: { fill: 'lightblue', strokeColor: 'white'}, |
| 25 | + shape: { type:'Flow', shape: 'Terminator'} |
| 26 | + } |
| 27 | +]; |
| 28 | +
|
| 29 | +let diagramInstance; |
| 30 | +
|
| 31 | +export default { |
| 32 | + name: 'App', |
| 33 | + components: { |
| 34 | + "ejs-diagram": DiagramComponent, |
| 35 | + "ejs-button": ButtonComponent |
| 36 | + }, |
| 37 | + data() { |
| 38 | + return { |
| 39 | + width: '1302px', |
| 40 | + height: '602px', |
| 41 | + //nodes: nodes |
| 42 | + drawNode: () => { |
| 43 | + diagramInstance.tool = DiagramTools.DrawOnce; |
| 44 | + diagramInstance.drawingObject = { shape: { type: 'Basic', shape: 'Rectangle' } }; |
| 45 | + }, |
| 46 | + editNode: ()=> { |
| 47 | + diagramInstance.nodes[0].width = 400; |
| 48 | + diagramInstance.nodes[0].height = 200; |
| 49 | + diagramInstance.nodes[0].annotations[0].content = "Changed Text"; |
| 50 | + diagramInstance.nodes[0].style = { fill: 'Orange', strokeColor: 'Blue' } |
| 51 | + }, |
| 52 | + removeNode: ()=> { |
| 53 | + diagramInstance.remove(diagramInstance.nodes[0]); |
| 54 | + } |
| 55 | + }; |
| 56 | + }, |
| 57 | + mounted: function () { |
| 58 | + diagramInstance = this.$refs.diagramObject.ej2Instances; |
| 59 | + diagramInstance.add(nodes[0]); |
| 60 | + } |
| 61 | +}; |
| 62 | +</script> |
| 63 | + |
| 64 | +<style> |
| 65 | +@import '../node_modules/@syncfusion/ej2-vue-diagrams/styles/material.css'; |
| 66 | +@import '../node_modules/@syncfusion/ej2-vue-buttons/styles/material.css'; |
| 67 | +
|
| 68 | +.container { |
| 69 | + text-align: left; |
| 70 | + margin-bottom: 10px; |
| 71 | +} |
| 72 | +.button { |
| 73 | + margin-right: 10px; |
| 74 | +} |
| 75 | +</style> |
0 commit comments