Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] Allow custom function for nodeRepulsion attribute in cose layout #209

Open
jlalbers opened this issue Feb 24, 2024 · 0 comments

Comments

@jlalbers
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant