A SVG-based diagram component for Vue
npm i diagram-vue --save
import { DiagramEditor } from "diagram-vue";
import "diagram-vue/dist/diagram.css";
<DiagramEditor v-model="graph"></DiagramEditor>
See Data specification.
import Diagram from 'diagram-vue';
import "diagram-vue/dist/diagram.css";
<Diagram
:width="2000"
:height="1000"
:fluid="false"
scale="1"
background="#fafafa"
:nodes="nodes"
:links="links"
:editable="editable"
:labels="{
edit: 'Edit',
remove: 'Remove',
link: 'Link',
select: 'Select',
cancel: 'Cancel'
}"
@editNode="editNode"
@editLink="editLink"
@nodeChanged="nodeChanged"
@linkChanged="linkChanged"
>
</Diagram>
props: {
width: Number,
height: Number,
background: String,
nodes: Array,
links: Array,
editable: Boolean,
labels: Object,
fluid: Boolean
}
See Data specification.
editNode(node /* selected node */) {
/* event handler */
},
editLink(link /* selected link */) {
/* event handler */
},
nodeChanged(obj /* array of nodes */) {
/* event handler */
const nodes = obj.nodes
},
linkChanged(obj /* array of links */) {
/* event handler */
const links = obj.links
},
nodeRemoved(id /*Identifier of node*/){
/* event handler */
},
linkRemoved(id /*Identifier of link*/){
/* event handler */
},
nodeClicked(id /* identifier of node */) {
/* event handler */
console.log("your clicked in node: ", id)
},
linkClicked(id /* identifier of link */) {
/* event handler */
console.log("your clicked in link: ", id)
}
Use plain JavaScript.
document.getElementById('svg-diagram-show-area').innerHTML; // <svg ...>...</svg>
yarn install
yarn run serve
yarn run build
yarn run test
yarn run lint
yarn run test:e2e
yarn run test:unit