Better layouts for tar_visnetwork
mem48 opened this issue · 2 comments
Prework
- [ x] I understand and agree to help guide.
- [ x] I understand and agree to contributing guide.
- [ x] New features take time and effort to create, and they take even more effort to maintain. So if the purpose of the feature is to resolve a struggle you are encountering personally, please consider first posting a "trouble" or "other" issue so we can discuss your use case and search for existing solutions first.
Proposal
For complex target tar_visnetwork
produces hard-to-understand networks. For example
In this case, the positioning of the targets creates a lot of crossing lines and makes the logic of the workflow hard to see. Using tar_mermaid
on the same workflow produces
Which is a lot easier to understand.
I'm guessing there is not an easy single fix to this but could tar_visnetwork
expose some of the underlying options in visNetwork
so that users could adjust the layout of the network?
tar_network()
returns a visNetwork
object that you can modify directly. And tar_network()
returns the node and edge information so custom graphs can be created.
I haven't seen a way to achieve a hierarchical layout in visNetwork
which is as nice as the mermaid.js graph in terms of the positioning of the edges. I will consider it if a really good set of options becomes available, but as far as I know visNetwork
does not support this.
I case anybody else has this problem I used
net = tar_network(TRUE)
nodes = net$vertices
edges = net$edges
names(nodes)[1] = "id"
nodes$label = nodes$id
visNetwork(nodes, edges) %>%
visEdges(arrows = "to") %>%
visIgraphLayout(layout = "layout_with_sugiyama", smooth =TRUE)
Which gives access to all the layouts described in https://igraph.org/r/doc/layout_.html