antv g6对接后台数据_antv/g6-editor的使用详解

你好! 这是一篇讲解怎么使用g6-editor实现一个流程调度功能的文章。如果你想学习如何使用g6-editor, 可以仔细阅读这篇文章,了解一下g6-editor的基本用法知识。网上关于这方面的资料还算多,但是能比较详细讲解的是少之又少,顺手记录我在项目中的运用,希望对有这方面需求的同学有所帮助。

安装并在代码中引入

npm install @antv/g6-editor

import G6Editor from [email protected]/g6-editor';

this.editor = new G6Editor();

添加组件

// 缩略图

const minimap = new G6Editor.Minimap({

container: 'minimap'

});

// 工具栏

const toolbar = new G6Editor.Toolbar({

container: 'toolbar'

});

// 菜单

const contextmenu = new G6Editor.Contextmenu({

container: 'contextmenu'

});

// 画布

const itempannel = new G6Editor.Itempannel({

container: 'itempannel'

});

// 详情信息

const detailpannel = new G6Editor.Detailpannel({

container: 'detailpannel'

});

// 添加组件

this.editor.add(toolbar);

this.editor.add(minimap);

this.editor.add(contextmenu);

this.editor.add(itempannel);

this.editor.add(detailpannel);

container指向的是挂载组件的id。

获取当前页

// 获取最基础图类

const CPage = this.editor.getCurrentPage();

比如想获取图中的数据:node/group/edge,可用如下方式:

const nodes = CPage.getNodes() || [];

const edges = CPage.getEdges() || [];

const groups = CPage.getGroups() || [];

监听事件,如鼠标选择图形

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
These dependencies were not found: * @antv/g6-core/lib/item/item in ./node_modules/.store/cache-loader@4.1.0/node_modules/cache-loader/dist/cjs.js??ref--13-0!./node_modules/.store/babel-loader@8.3.0/node_modules/babel-loader/lib!./node_modules/.store/cache-loader@4.1.0/node_modules/cache-loader/dist/cjs.js??ref--1-0!./node_modules/.store/vue-loader@15.10.1/node_modules/vue-loader/lib??vue-loader-options!./src/views/common/SceneG6.vue?vue&type=script&lang=js& * @antv/util in ./node_modules/.store/cache-loader@4.1.0/node_modules/cache-loader/dist/cjs.js??ref--13-0!./node_modules/.store/babel-loader@8.3.0/node_modules/babel-loader/lib!./node_modules/.store/cache-loader@4.1.0/node_modules/cache-loader/dist/cjs.js??ref--1-0!./node_modules/.store/vue-loader@15.10.1/node_modules/vue-loader/lib??vue-loader-options!./src/views/Attribute.vue?vue&type=script&lang=js& * graphlib/lib/json in ./node_modules/.store/cache-loader@4.1.0/node_modules/cache-loader/dist/cjs.js??ref--13-0!./node_modules/.store/babel-loader@8.3.0/node_modules/babel-loader/lib!./node_modules/.store/cache-loader@4.1.0/node_modules/cache-loader/dist/cjs.js??ref--1-0!./node_modules/.store/vue-loader@15.10.1/node_modules/vue-loader/lib??vue-loader-options!./src/views/common/SceneRule.vue?vue&type=script&lang=js& * lodash/_initCloneByTag in ./node_modules/.store/cache-loader@4.1.0/node_modules/cache-loader/dist/cjs.js??ref--13-0!./node_modules/.store/babel-loader@8.3.0/node_modules/babel-loader/lib!./node_modules/.store/cache-loader@4.1.0/node_modules/cache-loader/dist/cjs.js??ref--1-0!./node_modules/.store/vue-loader@15.10.1/node_modules/vue-loader/lib??vue-loader-options!./src/views/Object.vue?vue&type=script&lang=js&
06-03
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值