antv G6实现拓扑树绘制

该博客介绍了如何使用AntV G6库创建一个自定义的卡片节点树图,包括注册新节点类型、绘制节点形状、处理节点状态以及响应节点点击事件。示例代码展示了如何配置布局、数据加载、图的渲染和视图适配等步骤。
<template>
  <div id="antV-G6"></div>
</template>

<script>
import G6 from '@antv/g6';
export default {
  name: 'G6',
  mounted () {
    this.int();
  },
  methods: {
    int () {
      G6.registerNode('card-node', {
        draw: function drawShape (cfg, group) {
          const r = 2;
          const color = '#5B8FF9';
          const w = cfg.size[0];
          const h = cfg.size[1];
          const shape = group.addShape('rect', {
            attrs: {
              x: -w / 2,
              y: -h / 2,
              width: w, // 200,
              height: h, // 60
              stroke: color,
              radius: r,
              fill: '#fff'
            },
            name: 'main-box',
            draggable: true
          });

          group.addShape('rect', {
            attrs: {
              x: -w / 2,
              y: -h / 2,
              width: w, // 200,
              height: h / 2, // 60
              fil
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值