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

审批流AntV框架蚂蚁数据可视化X6饼图(注释详尽)

大家好,这次使用的是AntV的蚂蚁数据可视化X6框架,类似于审批流的场景等,代码如下:
X6框架参考网址:https://x6.antv.vision/zh/examples/showcase/practices#bpmn
可以进入该网址,直接复制下方代码进行调试或观察。
效果图如下:
在这里插入图片描述

<canvas id="container"></canvas>
import { Graph, Cell } from '@antv/x6'

const data = [
  {
    "id": "1",
    "shape": "event",
    "width": 40,
    "height": 40,
    "position": {
      "x": 50,
      "y": 180
    }
  },
  {
    "id": "2",
    "shape": "activity",
    "width": 100,
    "height": 60,
    "position": {
      "x": 20,
      "y": 280
    },
    "label": "请假申请"
  },
  {
    "id": "3",
    "shape": "bpmn-edge",
    "source": "1",
    "target": "2"
  },
  {
    "id": "4",
    "shape": "gateway",
    "width": 55,
    "height": 55,
    "position": {
      "x": 170,
      "y": 282.5
    }
  },
  {
    "id": "5",
    "shape": "bpmn-edge",
    "source": "2",
    "target": "4"
  },
  {
    "id": "6",
    "shape": "activity",
    "width": 100,
    "height": 60,
    "position": {
      "x": 300,
      "y": 240
    },
    "label": "领导审批"
  },
  {
    "id": "7",
    "shape": "activity",
    "width": 100,
    "height": 60,
    "position": {
      "x": 300,
      "y": 320
    },
    "label": "人事审批"
  },
  {
    "id": "8",
    "shape": "bpmn-edge",
    "source": "4",
    "target": "6"
  },
  {
    "id": "9",
    "shape": "bpmn-edge",
    "source": "4",
    "target": "7"
  },
  {
    "id": "10",
    "shape": "gateway",
    "width": 55,
    "height": 55,
    "position": {
      "x": 460,
      "y": 282.5
    }
  },
  {
    "id": "11",
    "shape": "bpmn-edge",
    "source": "6",
    "target": "10"
  },
  {
    "id": "12",
    "shape": "bpmn-edge",
    "source": "7",
    "target": "10"
  },
  {
    "id": "13",
    "shape": "activity",
    "width": 100,
    "height": 60,
    "position": {
      "x": 560,
      "y": 280
    },
    "label": "人事审批"
  },
  {
    "id": "14",
    "shape": "bpmn-edge",
    "source": "10",
    "target": "13"
  },
  {
    "id": "15",
    "shape": "event",
    "width": 40,
    "height": 40,
    "position": {
      "x": 710,
      "y": 290
    },
    "attrs": {
      "body": {
        "strokeWidth": 4
      }
    }
  },
  {
    "id": "16",
    "shape": "bpmn-edge",
    "source": "13",
    "target": "15"
  }
]
// 设置event类型节点的样式(起点和终点的样式)
Graph.registerNode(
  'event',
  {
    inherit: 'circle',
    attrs: {
      body: {
        strokeWidth: 2,
        stroke: '#5F95FF',
        fill: '#FFF',
      },
    },
  },
  true,
)
// 设置activity类型节点的样式
Graph.registerNode(
  'activity',
  {
    inherit: 'rect',
    markup: [
      {
        tagName: 'rect',
        selector: 'body',
      },
      {
        tagName: 'image',
        selector: 'img',
      },
      {
        tagName: 'text',
        selector: 'label',
      },
    ],
    attrs: {
      body: {
        rx: 6,
        ry: 6,
        stroke: '#5F95FF',
        fill: '#EFF4FF',
        strokeWidth: 1,
      },
      img: {
        x: 6,
        y: 6,
        width: 16,
        height: 16,
        'xlink:href':
          'https://gw.alipayobjects.com/mdn/rms_43231b/afts/img/A*pwLpRr7QPGwAAAAAAAAAAAAAARQnAQ',
      },
      label: {
        fontSize: 12,
        fill: '#262626',
      },
    },
  },
  true,
)
// 设置gateway类型节点的样式
Graph.registerNode(
  'gateway',
  {
    inherit: 'polygon',
    attrs: {
      body: {
        refPoints: '0,10 10,0 20,10 10,20',
        strokeWidth: 2,
        stroke: '#5F95FF',
        fill: '#EFF4FF',
      },
      label: {
        text: '+',
        fontSize: 40,
        fill: '#5F95FF',
      },
    },
  },
  true,
)
// 设置bpmn-edge类型线段的样式
Graph.registerEdge(
  'bpmn-edge',
  {
    inherit: 'edge',
    attrs: {
      line: {
        stroke: '#A2B1C3',
        strokeWidth: 2,
      },
    },
  },
  true,
)
// 设置展示canvas图表的容器
const graph = new Graph({
  container: document.getElementById('container')!,
  connecting: {
    router: 'orth',
  },
})

// 处理一下数据的格式,开始渲染图表
const cells = []
data.forEach((item: any) => {
  if (item.shape === 'bpmn-edge') {
    cells.push(graph.createEdge(item))
  } else {
    cells.push(graph.createNode(item))
  }
})
graph.resetCells(cells)
graph.zoomToFit({ padding: 10, maxScale: 1 })


文章转载自:

http://nfDyvN3x.sqrpb.cn
http://wAEsHAXz.sqrpb.cn
http://OLAxb2lC.sqrpb.cn
http://biwFCnLm.sqrpb.cn
http://e0Toiy23.sqrpb.cn
http://AybFXnKl.sqrpb.cn
http://anTe8bQm.sqrpb.cn
http://uGoviE00.sqrpb.cn
http://jIGfP9si.sqrpb.cn
http://4Gc8QqOW.sqrpb.cn
http://DMbjj8Tu.sqrpb.cn
http://zUPCN0M3.sqrpb.cn
http://VabusSv5.sqrpb.cn
http://jSac1bwM.sqrpb.cn
http://UxYO4Iyg.sqrpb.cn
http://CRM2CSj4.sqrpb.cn
http://Iq0pGdfb.sqrpb.cn
http://HRw9Ur1B.sqrpb.cn
http://o8WjKuRj.sqrpb.cn
http://SvCVJq6a.sqrpb.cn
http://9Q4N4WyX.sqrpb.cn
http://vLXmlid8.sqrpb.cn
http://riJIGfd5.sqrpb.cn
http://NO1rcaNa.sqrpb.cn
http://hS1vjdGQ.sqrpb.cn
http://zpHFx7cR.sqrpb.cn
http://lBZJgVgt.sqrpb.cn
http://afI6V8hj.sqrpb.cn
http://ILVLGVId.sqrpb.cn
http://fCuzWXIm.sqrpb.cn
http://www.dtcms.com/a/51284.html

相关文章:

  • npm : 无法加载文件 C:\Program Files\nodejs\npm.ps1,因为在此系统上禁止运行脚本。
  • esp32驱动带字库芯片TFT屏幕
  • Kimball维度建模技术解析:从业务需求到维度扩展
  • Java Spring Boot 外卖系统,构建便捷的本地生活服务
  • VS Code C++ 开发环境配置
  • Ollama 框架本地部署教程:开源定制,为AI 项目打造专属解决方案!
  • 最新的PyCharm及AI助手的安装和试用
  • H5DS编辑器是如何让企业快速构建动态页面
  • 一文读懂深度学习中的损失函数quantifying loss —— 作用、分类和示例代码
  • 权限管理Vue实现
  • CHAPTER 6 Object References, Mutability, and Recycling
  • 超越AI边界:智慧法务如何破解法律行业的“最后一公里“难题
  • ReconDreamer:通过在线恢复构建驾驶场景重建的世界模型
  • golang进阶知识专项-理解值传递
  • 记录一次Spring事务失效导致的生产问题
  • 第七节:基于Winform框架的串口助手小项目---协议解析《C#编程》
  • DeepSeek开源周:五大创新项目详解
  • 监听 RabbitMQ 延时交换机的消息数、OpenFeign 路径参数传入斜杠无法正确转义
  • Docker 部署开源项目HivisionIDPhotos详细教程
  • 【个人学习总结】反悔贪心:反悔堆+反悔自动机
  • SPL 和 SQL 能不能融合在一起?
  • 使用 marked.min.js 实现 Markdown 编辑器 —— 我的博客后台选择之旅
  • 家政保洁维修行业有没有必要做小程序?
  • 搭建一个跳板服务器的全过程
  • 数据安全VS创作自由:ChatGPT与国产AI工具隐私管理对比——论文党程序员必看的避坑指南
  • k倍区间(蓝桥杯 )
  • 基于Python的PDF特殊字体提取器开发实践
  • 3.3.2 Proteus第一个仿真图
  • ArcGIS操作:07 绘制矢量shp面
  • 服务器内存