cytoscape/cytoscape.js-arbor

Layoutstop event fired multiple times

Closed this issue · 4 comments

pmall commented

With same setup as cytoscape/cytoscape.js#1291 using cy.layout({ name: 'arbor' });, the stoplayout event is fired two times.

When using a custom layout like this example bellow it can go completely crazy, firing stoplayout instantly or multiple times at the end.

cy.layout({
    name: 'arbor',
    ungrabifyWhileSimulating: true,
    maxSimulationTime: 600000, // Big value so never stopped this way
    gravity: true,
    nodeMass: function (n, data) {
        return data.element.degree()
    },
    edgeLength: function (n, data) {

        // The more difference between the nodes degrees, the shorter the edge is.
        var degree1 = data.element.source().degree();
        var degree2 = data.element.target().degree();

        return 1/(1 + Math.abs(degree1 - degree2)) * 10;

    }
});

Another solution would be to have a rendering as good as this example with the cose layout but I cant figure out how to configure it in order to do so.

pmall commented

@maxkfranz sorry to bother you with this but I really need some way to make this work for my project.

pmall commented

@maxkfranz the fix works wonderfully. However there is still a minor problem : with firefox the first layout run automatically stops, then it works well. With chrome everything works well.

Unfortunately, the Arbor library itself is not very good. I don't think it's possible for me to fix this on my end. I don't have time to rewrite Arbor itself, especially considering there are much better layouts today. I suggest you try a different physics layout.

pmall commented

Ok thanks a lot the fix is still very useful. I'll try to workaround this. Again, thanks a lot !