Smart routing manhattan not giving orthogonal lines
See original GitHub issueTwo React
element with top, bottom, right, left
ports and elements are connected via link. Here i am using manhattan
router. But i am not getting line segment 100% vertically & horizontally.
Elements port configuration
...
ports: {
groups: {
'left': {
position: {
name: 'left'
}
},
'bottom': {
position: {
name: 'bottom'
}
},
'top': {
position: {
name: 'top'
}
},
'right': {
position: {
name: 'right'
}
}
}
}
...
Link configugration
...
source: {
id: iBlock.id,
port: 'top'
},
target: {
id: bBlock.id,
port: 'right'
},
router: {
name: 'manhattan',
}
...
Demo: https://jsfiddle.net/pathikdevani/8qkLbxad/ Expected result: link should be collection of orthogonal(horizontal & vertical) segments.
JointJS version: 2.0.1 Browser : Google Chrome, Mozilla Firefox
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Synthesis of Optimal Nonorthogonal Routes
Traditionally, routing algorithms perform Manhattan, or orthogonal, routing. ... wires given by Manhattan routes makes the most efficient use.
Read more >Interactively Routing Your PCB in Altium Designer
In the PCB editor, interactive routing is an intelligent process. After launching the command, click on a pad to select a connection to...
Read more >Global and detailed routing
Global routing first partitions the rout- ing region into tiles and decides tile-to-tile paths for all nets while attempting to optimize some given...
Read more >Cell - Joint API
If it is not possible to place the anchor so that the link would be orthogonal, the anchor is placed at the center...
Read more >Routing Orthogonal Diagram Connectors in JavaScript - Medium
Route Grid · If the point has a neighbor horizontally or vertically, without skipping places, add a connection. · When adding a connection,...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I forgot to mention one more thing… In your example, there are node positions off the grid. When you have the grid size === 10, then you should have the nodes positions dividable by 10 as well.
You don’t need to care about this, just call the
paper.snapToGrid
function, it will adjust the position to be on the actual grid. So in your code, you would have:(~line 380)
block.set("position", paper.snapToGrid(node.position.x , node.position.y));
also, you can visualize the grid - check the http://resources.jointjs.com/docs/jointjs/v2.0/joint.html#dia.Paper.prototype.options.drawGrid
paper.snapToGrid
is working fine in this problem.Thanks @vtalas