A SVG-based diagram component for Vue
This is a fork that I use that differs from the original in the following ways:
- (done) ported to vuejs version 3.beta.1
- (wip) ported to typescript
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'
}"
@edit-node="editNode"
@edit-link="editLink"
@node-changed="nodeChanged"
@link-changed="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
}
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