kieler / klayjs

(deprecated) KIELER's layout algorithms for JavaScript
Eclipse Public License 1.0
231 stars 22 forks source link

Edge label placement fails where source and target are the same node and graph contains more than one node #9

Closed jbeard4 closed 8 years ago

jbeard4 commented 8 years ago

Please consider the following two cases.

Graph contains one node

screen shot 2016-04-13 at 3 17 13 pm

The edge label is positioned above the last path segment, which appears correct.

Graph contains two nodes

screen shot 2016-04-13 at 3 16 44 pm

The edge label is not positioned above the last path segment. It appears not toeflect the nav-open node's updated coordinate space.

Here is the associated JSON, JSON+layout information, and resulting SVG:

{
    "id": "root",
    "labels": [
        {
            "text": "root"
        }
    ],
    "edges": [
        {
            "id": "nav-open_nav-open",
            "source": "nav-open",
            "target": "nav-open",
            "labels": [
                {
                    "text": "menu",
                    "width": 10,
                    "height": 5
                }
            ]
        }
    ],
    "width": 12.171875,
    "height": 10,
    "children": [
        {
            "id": "nav-closed",
            "labels": [
                {
                    "text": "nav-closed"
                }
            ],
            "edges": [],
            "width": 24.765625,
            "height": 10
        },
        {
            "id": "nav-open",
            "labels": [
                {
                    "text": "nav-open"
                }
            ],
            "edges": [],
            "width": 21.953125,
            "height": 10
        }
    ]
}
{
    "id": "root",
    "labels": [
        {
            "text": "root"
        }
    ],
    "edges": [
        {
            "id": "nav-open_nav-open",
            "source": "nav-open",
            "target": "nav-open",
            "labels": [
                {
                    "text": "menu",
                    "width": 10,
                    "height": 5
                }
            ]
        }
    ],
    "width": 12.171875,
    "height": 10,
    "children": [
        {
            "id": "nav-closed",
            "labels": [
                {
                    "text": "nav-closed"
                }
            ],
            "edges": [],
            "width": 24.765625,
            "height": 10,
            "x": 0,
            "y": 0
        },
        {
            "id": "nav-open",
            "labels": [
                {
                    "text": "nav-open"
                }
            ],
            "edges": [],
            "width": 21.953125,
            "height": 10,
            "x": 0,
            "y": 0
        }
    ]
}
<?xml version="1.0"?>
<svg class="schviz2 ng-isolate-scope" display-model="displayModel" viewBox="0 0 90.76562428474426 77.99999976158142">
  <desc>Created with Snap</desc>
  <defs/>
  <g>
    <g class="node compound">
      <rect/>
      <g id="nav-closed" transform="matrix(1,0,0,1,40,12)" class="node leaf highlighted">
        <rect x="0" y="0" width="24.765625" height="10"/>
        <text x="2.5" y="2.5" style="dominant-baseline: text-before-edge;">nav-closed</text>
      </g>
      <g id="nav-open" transform="matrix(1,0,0,1,41.4062,42)" class="node leaf">
        <rect x="0" y="0" width="21.953125" height="10"/>
        <text x="2.5" y="2.5" style="dominant-baseline: text-before-edge;">nav-open</text>
      </g>
      <path d="M63.35937452316284 47 L78.76562428474426 47 L78.76562428474426 65.99999976158142 L12 65.99999976158142 L12 47  L41.40624952316284 47" class="link"/>
      <text x="12" y="12" dominant-baseline="text-before-edge">menu</text>
    </g>
  </g>
  <defs>
    <marker id="end" viewBox="0 -5 10 10" refX="10" refY="0" markerWidth="3" markerHeight="5" orient="auto">
      <path d="M0,-5L10,0L0,5"/>
    </marker>
  </defs>
</svg>

Thank you for looking into this.

uruuru commented 8 years ago

a) The node coordinates in the snippet after layout are all 0. Is it possible that you included the wrong json output?

b) To narrow down the issue, can you give it a try with the following option: separateConnComp: false. No need to include a result of that, just let me know if the issue persists.

jbeard4 commented 8 years ago

Here is the correct JSON after layout has been applied:

{
    "id": "root",
    "labels": [
        {
            "text": "root"
        }
    ],
    "edges": [
        {
            "id": "nav-open_nav-open",
            "source": "nav-open",
            "target": "nav-open",
            "labels": [
                {
                    "text": "menu",
                    "width": 10,
                    "height": 5,
                    "x": 12,
                    "y": 12
                }
            ],
            "sourcePoint": {
                "x": 63.35937452316284,
                "y": 47
            },
            "targetPoint": {
                "x": 41.40624952316284,
                "y": 47
            },
            "bendPoints": [
                {
                    "x": 78.76562428474426,
                    "y": 47
                },
                {
                    "x": 78.76562428474426,
                    "y": 65.99999976158142
                },
                {
                    "x": 12,
                    "y": 65.99999976158142
                },
                {
                    "x": 12,
                    "y": 47
                }
            ],
            "junctionPoints": []
        }
    ],
    "width": 90.76562428474426,
    "height": 77.99999976158142,
    "children": [
        {
            "id": "nav-closed",
            "labels": [
                {
                    "text": "nav-closed"
                }
            ],
            "edges": [],
            "width": 24.765625,
            "height": 10,
            "x": 39.99999952316284,
            "y": 12
        },
        {
            "id": "nav-open",
            "labels": [
                {
                    "text": "nav-open"
                }
            ],
            "edges": [],
            "width": 21.953125,
            "height": 10,
            "x": 41.40624952316284,
            "y": 42
        }
    ]
}

separateConnComp: false does not appear to have an effect.

Thank you.

uruuru commented 8 years ago

I have the feeling we don't handle the labels of orthogonal self-loops at all. The label stays in it's previous position (by default this is 0,0). So I guess your ticket becomes a feature request :).

jbeard4 commented 8 years ago

OK, thank you for letting me know. In the meantime, I have a few ideas to work around this.

Thank you for your help looking into this.