Files
SaaS-lib/lib/component/flowChart/flow-chart.vue
xuziqiang d0155dbe3c push
2024-05-15 17:29:42 +08:00

72 lines
2.1 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template><div id="container"></div> </template>
<script lang="ts">
import { defineComponent } from 'vue';
import { Graph } from '@antv/x6';
export default defineComponent({
name: 'NsFlowChart',
setup() {},
mounted() {
const data = {
// 节点
nodes: [
{
id: 'node1', // String可选节点的唯一标识
x: 40, // Number必选节点位置的 x 值
y: 40, // Number必选节点位置的 y 值
width: 80, // Number可选节点大小的 width 值
height: 40, // Number可选节点大小的 height 值
label: 'hello', // String节点标签
line: {
stroke: 'orange',
},
},
{
id: 'node2', // String节点的唯一标识
x: 160, // Number必选节点位置的 x 值
y: 180, // Number必选节点位置的 y 值
width: 80, // Number可选节点大小的 width 值
height: 40, // Number可选节点大小的 height 值
label: 'world', // String节点标签
},
],
// 边
edges: [
{
source: 'node1', // String必须起始节点 id
target: 'node2', // String必须目标节点 id
},
],
};
const graph = new Graph({
container: document.getElementById('container') as HTMLElement,
background: {
color: '#191F27', // 设置画布背景颜色
},
grid: {
size: 10, // 网格大小 10px
type: 'dot',
visible: false, // 渲染网格背景
args: {
color: '#fff', // 网格线/点颜色
thickness: 0.5, // 网格线宽度/网格点大小
},
},
snapline: {
enabled: true,
className: 'my-snapline',
},
});
graph.fromJSON(data);
},
});
</script>
<style lang="less" scoped>
#container {
width: 1000px;
height: 100%;
}
</style>