Reputation: 21
I have my elements defined like where level refers to the circle layer I want that node.
elements = [{'data': {'id': 'a', 'label': 'a', 'level': 1},
{'data': {'id': 'b', 'label': 'b', 'level': 1},
{'data': {'id': 'c', 'label': 'c', 'level': 2},
.......]
I have tried the following which doesnt work (error loading layout)
app.layout = html.Div([
cyto.Cytoscape(
id='cytoscape',
elements= elements,
layout={'name': 'concentric', 'concentric': lambda x: x['data']['level']}
)
])
The javascript documentation is here https://js.cytoscape.org/#layouts and specifies
let options = {
name: 'concentric',
concentric: function( node ){ // returns numeric value for each node, placing higher nodes in levels towards the centre
return node.degree();
}
How do I set this concentric parameter?
Cheers
Upvotes: 2
Views: 654
Reputation: 1046
Unfortunately it's not possible to pass python functions to the layout
parameter in a cyto.Cytoscape
component. This is because the function will not be transpiled to a JS function, which is what is needed for the concentric
key to work inside options
.
Alternatives would be:
cyto.Cytoscape
and hard code the JS function
you'd like to use for the concentric layout. You'd need to follow the contributing instructions to build and create a custom installation.Upvotes: 2