Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unstable/shaky layouting within compound nodes when using avoidOverlap #177

Closed
EyMaddis opened this issue Jun 20, 2016 · 2 comments · Fixed by cytoscape/cytoscape.js-cola#11

Comments

@EyMaddis
Copy link

EyMaddis commented Jun 20, 2016

I use the cytoscape adapter with compound nodes. It appears that the node within a compound/group are not stable and switch positions with each frame, as you can see below:

shaky layout

Is there a way to mitigate this jumping? All the examples from the website which have compound nodes seem to animate smoothly.

Layout options:

            name: 'cola',
            maxSimulationTime: 4000,
            padding: 6,
            ungrabifyWhileSimulating: true

The following graph data was used:

{
    "nodes": [
        {
            "data": {
                "id": "test-system123-nodeGroup-1",
                "name": "CoCoMe",
                "systemId": "system123",
                "type": "nodeGroup",
                "label": "CoCoMe"
            }
        },
        {
            "data": {
                "id": "test-system123-node-2",
                "name": "Logicnode",
                "ip": "10.0.0.2",
                "hostname": "host2",
                "nodeGroupId": "test-system123-nodeGroup-1",
                "systemId": "system123",
                "type": "node",
                "label": "Logicnode",
                "parent": "test-system123-nodeGroup-1"
            }
        },
        {
            "data": {
                "id": "test-system123-node-3",
                "name": "Adapter",
                "ip": "10.0.0.2",
                "hostname": "host3",
                "nodeGroupId": "test-system123-nodeGroup-1",
                "systemId": "system123",
                "type": "node",
                "label": "Adapter",
                "parent": "test-system123-nodeGroup-1"
            }
        },
        {
            "data": {
                "id": "test-system123-node-4",
                "name": "Database",
                "ip": "10.0.0.2",
                "hostname": "host4",
                "nodeGroupId": "test-system123-nodeGroup-1",
                "systemId": "system123",
                "type": "node",
                "label": "Database",
                "parent": "test-system123-nodeGroup-1"
            }
        },
        {
            "data": {
                "id": "test-system123-node-1",
                "name": "WebNode",
                "ip": "10.0.0.1",
                "hostname": "test hostname",
                "nodeGroupId": "test-system123-nodeGroup-1",
                "systemId": "system123",
                "type": "node",
                "label": "WebNode",
                "parent": "test-system123-nodeGroup-1"
            }
        },
        {
            "data": {
                "id": "test-system123-serviceInstance-4",
                "name": "Inventory",
                "nodeId": "test-system123-node-2",
                "serviceId": "test-system123-service-4",
                "systemId": "system123",
                "type": "serviceInstance",
                "label": "Inventory",
                "parent": "test-system123-node-2"
            }
        },
        {
            "data": {
                "id": "test-system123-serviceInstance-5",
                "name": "Data",
                "nodeId": "test-system123-node-3",
                "serviceId": "test-system123-service-5",
                "systemId": "system123",
                "type": "serviceInstance",
                "label": "Data",
                "parent": "test-system123-node-3"
            }
        },
        {
            "data": {
                "id": "test-system123-serviceInstance-6",
                "name": "PostgreSQL",
                "nodeId": "test-system123-node-4",
                "serviceId": "test-system123-service-6",
                "systemId": "system123",
                "type": "serviceInstance",
                "label": "PostgreSQL",
                "parent": "test-system123-node-4"
            }
        },
        {
            "data": {
                "id": "test-system123-serviceInstance-1",
                "name": "FrontEnd",
                "nodeId": "test-system123-node-1",
                "serviceId": "test-system123-service-1",
                "systemId": "system123",
                "type": "serviceInstance",
                "label": "FrontEnd",
                "parent": "test-system123-node-1"
            }
        },
        {
            "data": {
                "id": "test-system123-serviceInstance-2",
                "name": "WebService",
                "nodeId": "test-system123-node-2",
                "serviceId": "test-system123-service-2",
                "systemId": "system123",
                "type": "serviceInstance",
                "label": "WebService",
                "parent": "test-system123-node-2"
            }
        },
        {
            "data": {
                "id": "test-system123-serviceInstance-3",
                "name": "CashDesk",
                "nodeId": "test-system123-node-2",
                "serviceId": "test-system123-service-3",
                "systemId": "system123",
                "type": "serviceInstance",
                "label": "CashDesk",
                "parent": "test-system123-node-2"
            }
        }
    ],
    "edges": [
        {
            "data": {
                "id": "test-system123-communicationInstance-1",
                "sourceId": "test-system123-serviceInstance-1",
                "targetId": "test-system123-serviceInstance-2",
                "communicationId": null,
                "systemId": "system123",
                "type": "communicationInstance",
                "source": "test-system123-serviceInstance-1",
                "target": "test-system123-serviceInstance-2"
            }
        },
        {
            "data": {
                "id": "test-system123-communicationInstance-2",
                "sourceId": "test-system123-serviceInstance-2",
                "targetId": "test-system123-serviceInstance-3",
                "communicationId": null,
                "systemId": "system123",
                "type": "communicationInstance",
                "source": "test-system123-serviceInstance-2",
                "target": "test-system123-serviceInstance-3"
            }
        },
        {
            "data": {
                "id": "test-system123-communicationInstance-3",
                "sourceId": "test-system123-serviceInstance-3",
                "targetId": "test-system123-serviceInstance-4",
                "communicationId": null,
                "systemId": "system123",
                "type": "communicationInstance",
                "source": "test-system123-serviceInstance-3",
                "target": "test-system123-serviceInstance-4"
            }
        },
        {
            "data": {
                "id": "test-system123-communicationInstance-4",
                "sourceId": "test-system123-serviceInstance-3",
                "targetId": "test-system123-serviceInstance-5",
                "communicationId": null,
                "systemId": "system123",
                "type": "communicationInstance",
                "source": "test-system123-serviceInstance-3",
                "target": "test-system123-serviceInstance-5"
            }
        },
        {
            "data": {
                "id": "test-system123-communicationInstance-5",
                "sourceId": "test-system123-serviceInstance-4",
                "targetId": "test-system123-serviceInstance-5",
                "communicationId": null,
                "systemId": "system123",
                "type": "communicationInstance",
                "source": "test-system123-serviceInstance-4",
                "target": "test-system123-serviceInstance-5"
            }
        },
        {
            "data": {
                "id": "test-system123-communicationInstance-6",
                "sourceId": "test-system123-serviceInstance-5",
                "targetId": "test-system123-serviceInstance-6",
                "communicationId": null,
                "systemId": "system123",
                "type": "communicationInstance",
                "source": "test-system123-serviceInstance-5",
                "target": "test-system123-serviceInstance-6"
            }
        }
    ]
}

Please note that the graph above if dynamically generated, therefor I cannot set any fixed positions as I don't know how the graph has to look like beforehand.

I would appreciate some help. Thanks

EDIT: I noticed that it only happens when avoidOverlap is set.

@EyMaddis EyMaddis changed the title unstable/shaky layouting within compound nodes unstable/shaky layouting within compound nodes when using avoidOverlap Jun 22, 2016
@EyMaddis
Copy link
Author

EyMaddis commented Aug 29, 2016

I created a jsbin to with the graph model the cytoscape adapter generated from the data above, rendered with D3:

http://jsbin.com/sedezekade/1/edit?html,js,output

Notice that the output has the input data within the HTML file. I also added names and some debugging information (like _sourceName), just to make things easier.
Everything except the data was extracted from the smallgroups example.

@EyMaddis
Copy link
Author

I fixed it locally!

It happens because the cytoscape adapter adds all descendants as leaves of a compound node, but I should only add direct children which are leaves.

I will create a PR for the cytoscape adapter!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant