antv G6之流程图

<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>状态2操作流程图</title>
    <script src="https://gw.alipayobjects.com/os/lib/antv/g6/4.8.10/dist/g6.min.js"></script>
    <style>
        #container {
            width: 100%;
            height: 600px;
            border: 1px solid #e8e8e8;
            border-radius: 4px;
        }
        body {
            font-family: sans-serif;
        }
    </style>
</head>
<body>
    <h2>状态 "2" 内部操作流程</h2>
    <div id="container"></div>
    <script>
        // 初始化图实例
        const graph = new G6.Graph({
            container: 'container',
            width: document.getElementById('container').scrollWidth,
            height: 600,
            fitView: true,
            fitViewPadding: 20,
            modes: {
                default: ['drag-canvas', 'zoom-canvas', 'drag-node']
            },
            defaultNode: {
                type: 'rect',
                size: [140, 60],
                style: {
                    fill: '#f6ffed',
                    stroke: '#52c41a',
                    lineWidth: 1,
                    radius: 4
                },
                labelCfg: {
                    style: {
                        fill: '#333',
                        fontSize: 12,
                        cursor: 'default'
                    },
                    position: 'center'
                }
            },
            defaultEdge: {
                style: {
                    stroke: '#aaa',
                    lineWidth: 1,
                    endArrow: true
                }
            }
        });

        // 准备数据 - 手动设置节点位置
        const data = {
            nodes: [
                // 操作节点在左侧
                {
                    id: 'op175',
                    label: '提交\nID: 175\n15:07:24',
                    x: 200,//去掉就是一条直线上
                    y: 150
                },
                {
                    id: 'op176',
                    label: '提交\nID: 176\n15:07:33\n备注: 2',
                    x: 200,
                    y: 300
                },
                {
                    id: 'op177',
                    label: '提交\nID: 177\n15:26:20',
                    x: 200,
                    y: 450
                },
                // 主状态节点在右侧
                {
                    id: 'state2',
                    label: '状态 2\n(待处理)',
                    style: {
                        fill: '#e6f7ff',
                        stroke: '#1890ff',
                        lineWidth: 2
                    },
                    size: [160, 70],
                    x: 500,
                    y: 300
                }
            ],
            edges: [
                // 提交操作之间的连线
                { source: 'op175', target: 'op176' },
                { source: 'op176', target: 'op177' },
                // 只让最后一个提交操作连接到状态2
                { source: 'op177', target: 'state2' }
            ]
        };

        // 加载数据并渲染
        graph.data(data);
        graph.render();

        // 可选:监听窗口大小变化,调整画布大小
        window.addEventListener('resize', () => {
            if (!graph.get('destroyed')) {
                graph.changeSize(document.getElementById('container').scrollWidth, 600);
                graph.fitView();
            }
        });
    </script>
</body>
</html>

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值