question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Smart routing manhattan not giving orthogonal lines

See original GitHub issue

Two 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:closed
  • Created 6 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
vtalascommented, Jan 8, 2018

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

0reactions
pathikdevanicommented, Jan 8, 2018

paper.snapToGrid is working fine in this problem.

Thanks @vtalas

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found