antvis / XFlow

React component for building interactive diagrams.
https://x6.antv.antgroup.com/xflow/guide/introduction
MIT License
564 stars 233 forks source link

DAG解决方案中一个输入桩支持多个连线 #396

Closed nikohan closed 1 year ago

nikohan commented 1 year ago

描述你想申请的功能

DAG解决方案中一个输入桩支持多个连线,目前无法同一个输入桩

描述你想要的解决方案

DAG解决方案中一个输入桩支持多个连线

描述你所考虑的替代方案

DAG解决方案中一个输入桩支持多个连线

你的网站或应用程序实例

No response

屏幕截图或视频

image

xflow-bot[bot] commented 1 year ago

👋 @nikohan

Thanks for opening your first issue here! If you're reporting a 🐞 bug, please make sure you include steps to reproduce it.

To help make it easier for us to investigate your issue, please follow the contributing guidelines.

We get a lot of issues on this repo, so please be patient and we will get back to you as soon as we can.

nikohan commented 1 year ago

已解决:在DAG解决方案文档的定制连线交互逻辑中有示例,代码如下

      // 注册修改graphOptions配置的钩子
      hooks.graphOptions.registerHook({
        name: 'custom-x6-options',
        after: 'dag-extension-x6-options',
        handler: async options => {
          const graphOptions: Graph.Options = {
            connecting: {
              // 是否触发交互事件
              validateMagnet() {
                // return magnet.getAttribute('port-group') !== NsGraph.AnchorGroup.TOP
                return true
              },
              // 显示可用的链接桩
              validateConnection({ sourceView, targetView, sourceMagnet, targetMagnet }) {
                // 不允许连接到自己
                if (sourceView === targetView) {
                  return false
                }
                // 只能从上游节点的输出链接桩创建连接
                // if ( sourceMagnet.getAttribute('port-group') === NsGraph.AnchorGroup.TOP) {
                //   return false
                // }
                // 只能连接到下游节点的输入桩
                // if (targetMagnet.getAttribute('port-group') !== NsGraph.AnchorGroup.TOP) {
                //   return false
                // }
                // 没有起点的返回false
                if (!sourceMagnet) {
                  return false
                }
                if (!targetMagnet) {
                  return false
                }
                const node = targetView!.cell as any
                // 判断目标链接桩是否可连接
                const portId = targetMagnet.getAttribute('port')!
                const port = node.getPort(portId)
                return !!port
              },
            },
          }
          options.connecting = { ...options.connecting, ...graphOptions.connecting }
        },
      }),
xflow-bot[bot] commented 1 week ago

This thread has been automatically locked because it has not had recent activity.

Please open a new issue for related bugs and link to relevant comments in this thread.