简体   繁体   中英

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? 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 ).

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])

Return an array of all the successors of 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 . opt object can include 3 properties ( inbound , outbound , deep ) we can play with. 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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