iVis-at-Bilkent / cytoscape.js-fcose

fCoSE: a fast Compound Spring Embedder
MIT License
134 stars 25 forks source link

if `relativePlacementConstraint` is empty array it gives error #40

Closed canbax closed 3 years ago

canbax commented 3 years ago

If relativePlacementConstraint is an empty array I get an error saying.

core.js:6014 ERROR TypeError: Cannot read property 'forEach' of undefined at Function.ConstraintHandler.handleConstraints (cose-base.js:899) at CoSELayout.classicLayout (cose-base.js:1457) at CoSELayout.layout (cose-base.js:1409) at CoSELayout.Layout.runLayout (layout-base.js:2710) at coseLayout (cytoscape-fcose.js:936) at Layout.run (cytoscape-fcose.js:444) at CytoscapeComponent. (cytoscape.ts:73) at later (graph-helper.ts:11) at ZoneDelegate.invokeTask (zone-evergreen.js:391) at Object.onInvokeTask (core.js:39680)

Maybe it is intentional. Or maybe it should be like this. I'm not sure.

ugurdogrusoz commented 3 years ago

When constraint arrays are empty, we could just ignore them I think.

hasanbalci commented 3 years ago

I added basic validity check for constraint options. If it isn't an array or an empty array, then we ignore that option. Other than this, entering the correct format is the responsibility of the user since we cannot check whether every input is valid or not.