Comments (8)
I suppose that this and the following similar lines breaks the layout in headless mode. I am not sure but trying to read theChild.css('padding')
in headless mode would not be appropriate. When I tried to replace theChild.css('padding')
by an arbitrary value like 0 that bug is disappeared.
In the past I wanted to use the actual padding values there but I think that making it a user option defined per node and expecting the users to pass the actual paddings using these options would be considered (#46).
Also, I think that the line which throws the error (https://github.com/cytoscape/cytoscape.js-cose-bilkent/blob/master/src/Layout/FDLayout.js#L410) would still be problematic. Because the sizes of arrays are calculated by the following 2 lines:
sizeX = parseInt(Math.ceil((graph.getRight() - graph.getLeft()) / this.repulsionRange));
sizeY = parseInt(Math.ceil((graph.getBottom() - graph.getTop()) / this.repulsionRange));
I am not sure if it is ever possible but the same error would be thrown if one of sizeX
or sizeY
is greater then or equal to 2^32 (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Invalid_array_length). I think that changing arr = new Array(sizeX)
etc. by arr = []
would be better in that case.
from cytoscape.js-cose-bilkent.
@galaxym51 I think it makes sense to do this. It's not straightforward for this layout style to support this though. Will do this when we get a chance.
from cytoscape.js-cose-bilkent.
I think all the layouts work headlessly. The only browser-specific function that might be used is requestAnimationFrame()
, and that is used only for live-animated layouts. It never makes sense to animate on the server. So even if CoSE doesn't polyfill requestAnimationFrame()
, animate: false
should work fine.
The layout could do something like
const raf = typeof requestAnimationFrame !== typeof undefined ? requestAnimationFrame : function( cb ){ cb(); };
That polyfill prevents users from misusing animate: true
on the server, as there would be no wasted time between "frames".
from cytoscape.js-cose-bilkent.
The layout is working in headless mode if styleEnabled option is also set to true. I think this is because the algorithm considers the node sizes during layout.
from cytoscape.js-cose-bilkent.
I get this error when running in headless mode in NodeJS.
.../node_modules/cytoscape-cose-bilkent/src/Layout/FDLayout.js:411
var grid = new Array(sizeX);
^
RangeError: Invalid array length
from cytoscape.js-cose-bilkent.
@zakjan did you set the styleEnabled option to true?
from cytoscape.js-cose-bilkent.
nodeDimensionsIncludeLabels: true
seems to not be respected on headless mode, probably because of this:
//Attach the label properties to compound if labels will be included in node dimensions
if (this.options.nodeDimensionsIncludeLabels) {
if (theChild.isParent()) {
var labelWidth = theChild.boundingBox({ includeLabels: true, includeNodes: false }).w;
var labelHeight = theChild.boundingBox({ includeLabels: true, includeNodes: false }).h;
var labelPos = theChild.css("text-halign");
theNode.labelWidth = labelWidth;
theNode.labelHeight = labelHeight;
theNode.labelPos = labelPos;
}
}
maybe can't use css on headless?
from cytoscape.js-cose-bilkent.
maybe can do this:
const aNodeDimensions = aNode.layoutDimensions({ nodeDimensionsIncludeLabels: true });
const aNodeTextHalign = aNodeData['text-halign'];
from cytoscape.js-cose-bilkent.
Related Issues (20)
- Graph nodes not laid out properly HOT 4
- Can a point have two parent nodes?
- Uncaught TypeError: ani.play is not a function HOT 3
- how to set node size from data? HOT 3
- "ReferenceError: self is not defined" error occurring in unstable branch HOT 2
- Uncaught TypeError: Cannot read property 'getParent' of undefined HOT 9
- Cytoscape 3.3 objects in Vue.js state cause endless recursion HOT 12
- Possible to create a planar graph? HOT 5
- Is there a way to keep the nodes on a single Y axis? HOT 1
- Multiple groups of nodes are distributed HOT 3
- Setting nodeDimensionsIncludeLabels to true works not well for zero degree nodes HOT 4
- v4.1.0 has breaking changes to v4.0 HOT 4
- Uniform node dimensions HOT 1
- Pack disconnected graph components using new utility
- Incremental tiling
- Seed for deterministic layout HOT 4
- Retain node positions when chart is being re-generated with the same dataset HOT 3
- Tree reduction during incremental layout
- Update License HOT 2
- fit not working with huge amount of data HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cytoscape.js-cose-bilkent.