A Visual Flow Editor Based on Vue And Antv/g6

Introduction

vue-visual-flowIt is based on antv/g6the configuration of the visualization routine implemented Vuecomponents

Project uses rolluppackaged, are provided cjs esmin two modular form to introduce ways, size is only about 100K

Design ideas

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

Part of the problem and progress tracking

  • Currently antv/g6there will be an updated version of the problem after the disappearance of custom graphics, it does not support the new antv/g6tracking Issue: G6-Issue

issue has been fixed, use antv/g6@3.7.3and above

  • Currently does not support simultaneous node configuration settings tipsand anchor configuration labelNamecauses a problem can not be switched prompt information g6-issue

issue has been fixed, use antv/g6@3.8.1and above

demo

Personal use demo

use

installation

$ npm install @antv/g6 --save
$ npm install vue-visual-flow --save

Configuration

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 >

Download Details:

Author: qunzi0214

Source Code: https://github.com/qunzi0214/vue-visual-flow

#vue #vuejs #javascript

A Visual Flow Editor Based on Vue And Antv/g6
16.20 GEEK