Network multipass orthogonal graph in d3.js

We want to use d3 to plot a network route that has a fixed start and end node, but different paths between them can be shared by some nodes, for example: enter image description here

I read the comments from Configure Static Graph Fixed Layouts in d3.js and successfully created a simple graph like:

enter image description here

But as I add more nodes to the graph, it becomes random (not static after the update), and not orthogonal:

enter image description here

So my questions are:

  • Is it possible to use d3.js to draw something close to the desired chart?
  • Or is there an algorithm that I should use in my graph?
+4
source share
2 answers

Dagre solved our problem. He does exactly what we need.

0
source

See my demo here.

http://jsfiddle.net/doraeimo/JEcdS/

The basic idea is to create a tree-based connection.

//1)temporarily convert a connectivity to a tree var tree = conv2tree(data); //2)calculate for nodes' coords with <code>cluster.nodes(tree);</code> var nodes = buildNodes(tree); //3)append all the edges(links) of the connectivity var links = buildLinks(data); 
+1
source

Source: https://habr.com/ru/post/1479585/


All Articles