Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

同一节点现存的两个链接桩如何互相交换位置? #3846

Closed
13033445320 opened this issue Aug 14, 2023 · 5 comments
Closed

同一节点现存的两个链接桩如何互相交换位置? #3846

13033445320 opened this issue Aug 14, 2023 · 5 comments

Comments

@13033445320
Copy link

功能描述

现在有一个节点有一个链接桩组,组中分别由A,B两个连接桩,现在要求这两个连接桩可以互相交换位置

期望解决方案

node.port.ports.reverse() 后,有没有更新节点视图的方法?或者别的可以修改位置方法?

@x6-bot
Copy link
Contributor

x6-bot bot commented Aug 14, 2023

👋 @13033445320

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.

@NewByVector
Copy link
Contributor

NewByVector commented Sep 7, 2023

可以先删除再添加:

const ports = source.getPorts()
source.removePorts(ports)
source.addPorts(ports.reverse())

@13033445320
Copy link
Author

先删除的话,链接桩上的连线会断掉,还需要重新连线,数据量大的情况,不太友好。有没有更好的办法?

@NewByVector
Copy link
Contributor

可以这样操作:

const ports = [
  {
    id: '1',
    attrs: {
      text: {
        text: '1'
      },
    }
  },
  {
    id: '2',
    attrs: {
      text: {
        text: '2'
      },
    }
  }
]
const source = graph.addNode({
  shape: 'rect',
  x: 80,
  y: 80,
  width: 160,
  height: 60,
  label: 'source',
  ports,
})

const target = graph.addNode({
  shape: 'rect',
  x: 320,
  y: 320,
  width: 160,
  height: 60,
  label: 'target',
})

graph.addEdge({
  source,
  target,
})


source.prop('ports/items', ports.reverse())

@x6-bot
Copy link
Contributor

x6-bot bot commented Sep 11, 2024

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.

@x6-bot x6-bot bot locked as resolved and limited conversation to collaborators Sep 11, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants