简体   繁体   English

JointJS-通过链接获取所有后续产品

[英]JointJS - get all successors with links

To get successors of element I'm using: 为了获得元素的后继者,我正在使用:

const successors = graph.getSuccessors(element);

But it returns elements without links. 但是它返回没有链接的元素。 Is it some way to specify this function with options joint.dia.Graph.ExploreOptions to return also links? 是否可以通过选项joint.dia.Graph.ExploreOptions指定此函数以返回链接? Or is it some other way to get successors elements with links together? 还是以其他方式将具有链接的后继元素结合在一起?

Thanks 谢谢

Rafal 拉法尔

You are looking for graph.getSubgraph(cells, [, opt]) method ( documentation ). 您正在寻找graph.getSubgraph(cells, [, opt])方法( 文档 )。

var elements = graph.getSuccessors(element).concat(element);
// find all the links between successors and the element
var subgraph = graph.getSubgraph(elements);
// remove the element itself
subgraph.splice(subgraph.indexOf(element), 1);

It looks like I found solution. 看来我找到了解决方案。

According to documentation of graph.getSuccessors(element [, opt]) 根据graph.getSuccessors(element [, opt]) 文档

Return an array of all the successors of element . 返回由element的所有后继组成的element

So I assume that there is no way to get with this function elements and link with this function. 因此,我假设没有办法使用此功能元素并与该功能链接。 I need to get links separately by getConnectedLinks . 我需要通过getConnectedLinks 单独获取链接。 opt object can include 3 properties ( inbound , outbound , deep ) we can play with. opt对象可以包含我们可以使用的3个属性( inboundoutbounddeep )。 For example to get single link with inbound connection it would be: 例如,要获得具有入站连接的单个链接,它将是:

const connectedLinks = graph.getConnectedLinks(task, { inbound: true }); // RETURNS AN ARRAY

Best regards, 最好的祝福,

Rafal 拉法尔

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM