gojs-vue
GoJS 2.1
Based onThis project provides A Vue component for GoJS Diagrams to simplify usage of GoJS within a Vue application. the implementation of this project is inspired by gojs-react.
Installation
gojs-vue can be installed via NPM. This package has peer dependencies on gojs
and vue-property-decorator
, so make sure those are also installed or included on your application.
NPM
npm install --save gojs-vue
Usage
This package provides one component - VueDiagram - corresponding to the related GoJS classes.
<template> <VueDiagram divClassName='vue-diagram' :initDiagram="initDiagram" :nodeDataArray="nodeDataArray" :linkDataArray="linkDataArray" :modelData="modelData" @modelChange="handleModelChange" /></template>
Component Props
initDiagram
Specifies a function that is reponsible for initializing and returning a GoJS Diagram. This is where the model and templates should be instantiated. Node and link data do not need to be set up here, as they will be passed in as separate props.
{ const $ = goGraphObjectmake const diagram = diagramnodeTemplate = diagramlinkTemplate = return diagram}
nodeDataArray
Specifies the array of nodes for the Diagram's model.
nodeDataArray: key: 'Alpha' color: 'lightblue' key: 'Beta' color: 'orange' key: 'Gamma' color: 'lightgreen' key: 'Delta' color: 'pink'
Optional - divClassName
Specifies the CSS classname to add to the rendered div. The default style of rendered div is:
<style scoped>.gojs-diagram { position: relative; width: 100%; height: 100%;}</style>
Optional - linkDataArray
Specifies the array of links for the Diagram's model, only needed when using a GraphLinksModel, not for Models or TreeModels. If using a GraphLinksModel, make sure to set the GraphLinksModel's linkKeyProperty in the init function.
linkDataArray: key: -1 from: 'Alpha' to: 'Beta' key: -2 from: 'Alpha' to: 'Gamma' key: -3 from: 'Beta' to: 'Beta' key: -4 from: 'Gamma' to: 'Delta' key: -5 from: 'Delta' to: 'Alpha'
Optional - modelData
Specifies a modelData object for the Diagram's model, only necessary when using properties that will be shared by the model as a whole. See Model.modelData.
modelData: canRelink: true
onModelChange
Specifies a function to be called when a GoJS transaction has completed.
{ const insertedNodeKeys = datainsertedNodeKeys const modifiedNodeData = datamodifiedNodeData const removedNodeKeys = dataremovedNodeKeys const insertedLinkKeys = datainsertedLinkKeys const modifiedLinkData = datamodifiedLinkData const removedLinkKeys = dataremovedLinkKeys // ... make state changes}
License
This project is intended to be used alongside GoJS, and is covered by the GoJS software license