vue-visual-flow
It is based on antv/g6
the configuration of the visualization routine implemented Vue
components
Project uses rollup
packaged, are provided cjs
esm
in two modular form to introduce ways, size is only about 100K
In order to remove the business logic as much as possible, the component shares the G6 instance, as well as the currently operating node and edge instance, for users to complete their own business logic externally
About G6 api: G6
antv/g6
there will be an updated version of the problem after the disappearance of custom graphics, it does not support the new antv/g6
tracking Issue: G6-Issueissue has been fixed, use
antv/g6@3.7.3
and above
tips
and anchor configuration labelName
causes a problem can not be switched prompt information g6-issueissue has been fixed, use
antv/g6@3.8.1
and above
$ npm install @antv/g6 --save
$ npm install vue-visual-flow --save
main.js
import VisualFlow from 'vue-visual-flow';
Vue.use(VisualFlow);
index.vue
<template>
<div id="app">
<visual-flow
:tree-list="treeList"
:tool-list="toolList"
:contextmenu-list="contextmenuList"
:graph.sync="graph"
:current-node.sync="currentNode"
:current-edge.sync="currentEdge"
@contextmenuEvent="contextmenuEvent"
/>
</div>
</template>
< script >
export default {
name : 'App' ,
data ( ) {
return {
// Tree node list on the left, compatible with 2-n depth
treeList : [
// First level category
{
label : 'First level category 1' ,
showFlag : false ,
children : [
// Secondary category
{
label : 'Secondary category 1-1' ,
showFlag : false ,
children : [
// Three-level category (node)
{
// Basic attribute
label: 'Node 1' , // Node display name
tips : 'Add some node description information here~' , // (Optional) Node floating tip
inPoints : [ // Enter anchor point array
{
dataType : 'type1' , / / Custom anchor point type, only in and out anchor points of the same type can be connected
labelName : 'Incoming anchor point type is type1' , // (optional) Anchor point prompt information
} ,
{
dataType : 'type2' ,
labelName : 'Incoming anchor point type is type2' ,
} ,
] ,
outPoints : [ // Out anchor point array
{
dataType : 'type1',
labelName : 'Anchor point type is type1' ,
} ,
] ,
// Custom attribute
itemId : 'xxx' , // Node id
} ,
] ,
} ,
] ,
} ,
] ,
// Optional canvas control
toolList : [ 'zoomIn' , 'zoomOut' , 'adjustCanvas' , ' realRatio' , 'autoFormat' , 'fullScreen' ] ,
// right-click menu configuration
contextmenuList : {
// node right-click menu
node : [
{
label : 'delete node' ,
eventName :'removeNode' , // custom event contextmenuEvent will capture this field
} ,
] ,
// side right-click menu
edge : [
{
label : 'remove edge' ,
eventName : 'removeEdge' ,
} ,
] ,
// right-click menu
canvas : [
{
label : 'Don't know what to do' ,
eventName : 'unknow' ,
} ,
] ,
} ,
// Share g6 instance
graph with components : { } , // g6 instance
currentNode : { } , // Node instance
currentEdge : { } , // Edge instance when left and right keys
} ;
} ,
methods : {
contextmenuEvent ( eventName ) {
// eventName matches the field with the same name in contextmenuList
if ( eventName === 'removeNode' ) {
this . graph . removeItem ( this . currentNode);
}
if (eventName === 'removeEdge') {
this.graph.removeItem(this.currentEdge);
}
if ( eventName === 'unknow' ) {
alert ( 'Really didn't do anything' ) ;
}
} ,
} ,
} ;
</ script >
Author: qunzi0214
Source Code: https://github.com/qunzi0214/vue-visual-flow
#vue #vuejs #javascript