当前位置: 首页 > article >正文

AntvX6-edge

前言

Edge 是边的基类,继承自 Cell,并定义了边的通用属性和方法。

属性

选项类型描述
sourceTerminalData起点或起始节点、连接桩信息。
targetTerminalData终点或终止节点、连接桩信息。
verticesPoint.PointLike[]路径点。
routerRouterData路由。
connectorConnectorData连接器。
labelsLabel[] string[]标签。
defaultLabelLabel默认标签

代码

1、容器
<!-- container.vue -->
<template>
  <div id="container"></div>
</template>
<script setup lang="ts">
import { Graph } from "@antv/x6";
import { onMounted } from "vue";
import { register } from "@antv/x6-vue-shape";
import elmNode from "./elmNode.vue";

register({
  shape: "elm-vue-node",
  component: elmNode,
});

onMounted(() => {
  const graph = new Graph({
    container: document.getElementById("container"),
    width: "800",
    height: "800",
  });

  graph.addNode({
    id: "site1",
    shape: "elm-vue-node",
    x: 100,
    y: 100,
    width: 80,
    height: 100,
    data: {
      classType: "test",
    },
  });

  graph.addNode({
    id: "site2",
    shape: "elm-vue-node",
    x: 400,
    y: 400,
    width: 80,
    height: 100,
    data: {
      classType: "test",
    },
  });

  graph.addEdge({
    source: {
      cell: "site1",
      connectionPoint: {
        name: "anchor",
      },
      anchor: {
        name: "top",
      },
    },
    target: {
      cell: "site2",
      connectionPoint: {
        name: "anchor",
      },
      anchor: {
        name: "bottom",
      },
    },
    connector: {
      name: "smooth",
      args: {
        radius: 20,
      },
    },
  });
});
</script>
2、组件
<!-- elmNode.vue -->
<template>
  <div>{{ label }}</div>
  <div class="node-main"></div>
</template>
<script setup lang='ts'>
import { inject, onMounted } from "vue-demi";

const getNode = inject("getNode");
let node = getNode();
let data = node.getData();
let label = data["classType"];
</script>
<style lang='less' scoped>
.node-main {
  width: 61px;
  height: 92px;
  background-image: url("../../assets/site.svg");
  background-size: 61px 92px;
}
</style>

总结

如果需要使用 connectionPointanchor 来限制锚点位置,则组件需要设置 widthheight
antvx6 中的边有非常多的用法:

相关链接

边:https://x6.antv.antgroup.com/api/model/edge
路由:https://x6.antv.antgroup.com/api/registry/router
连接器:https://x6.antv.antgroup.com/api/registry/connector
节点的锚点:https://x6.antv.antgroup.com/api/registry/node-anchor
边的锚点:https://x6.antv.antgroup.com/api/registry/edge-anchor
连接点:https://x6.antv.antgroup.com/api/registry/connection-point


http://www.kler.cn/a/280066.html

相关文章:

  • C语言 | Leetcode C语言题解之第355题设计推特
  • Git Clone
  • QGC地面站连接roslanch创建的仿真无人机
  • 【从问题中去学习k8s】k8s中的常见面试题(夯实理论基础)(十六)
  • 【C/C++】类型转换
  • 使用统计方法在AMD GPU上使用JAX Profiler可靠地比较大型生成AI模型中的算法性能
  • 关于告警,要想做好,从这些方面着手
  • TCP+UDP通信
  • 农业四情监测设备的工作原理
  • Linux系统编程:UDP和TCP
  • Day16_Zookeeper
  • SCDN的优势在哪?Edge SCDN与传统SCDN有何不同?
  • 数字经济下的支付风控新策略:区块链积分系统
  • Linux 性能观测之CPU平均负载
  • Android经典实战之Kotlin的delay函数和Java中的Thread.sleep有什么不同?
  • 8.26 T4 日记和编辑器(fhq维护kmp——kmp本身含有的单射与可合并性)
  • 超详细!!!安装Android studio创建flutter项目并运行到模拟器
  • PostgreSQL死锁问题(Deadlock found when trying to get lock)如何快速定位原因及解决
  • 【区块链 + 司法存证】易保全区块链电子数据存证保全系统 | FISCO BCOS应用案例
  • Mysql基础练习题 182.编写解决方案来报告所有重复的电子邮件 (力扣)