Description
Description
I am currently using the cose
layout for a project to present a large number of nodes in a small space. Depending on the user actions within the app, the style of different nodes are updated via callbacks. I would also like to use a custom function for the nodeRepulsion
property of the cose
layout that can be modified via a callback. This is how the Cytoscape JS cose
layout works, as referenced here, and would allow me to dynamically alter the repulsion for a subset of nodes based on user input. However, Dash Cytoscape currently only allows a static numeric value to be used which is applied to all nodes.
Steps/Code to Reproduce
import dash
import dash_cytoscape as cyto
from dash import html
def custom_nodeRepulsion_func(node):
# Logic for returning a numeric repulsion value for the node
return 2048
app = dash.Dash(__name__)
app.layout = html.Div([
...
cyto.Cytoscape(
id='cytoscape',
elements=[ ... ],
layout={'name': 'cose', 'nodeRepulsion': custom_nodeRepulsion_func}
)
...
])
if __name__ == '__main__':
app.run_server(debug=True)
Expected Results
Ideally, the custom function would calculate the node repulsion for each node while building the cose
layout. This would allow for a dynamic physics-based node layout based on the user input.
Actual Results
Dash app displays "Error loading layout".
Versions
Dash 2.15.0
Dash Cytoscape 1.0.0