You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The below code instantiates a CyLeaflet instance with 1000 nodes. It takes about 3 seconds to load in my browser (Mac OS 12.6; Chrome 120.0). A plain cyto.Cytoscape instance with the same 1000 nodes loads in <0.5s.
The profiler shows the code is spending a lot of time in this event handler:
which is triggered each time a node is added, removed, or dragged.
It makes sense that the event handler would be triggered while nodes are being added to the layout, but not clear why it's taking so much longer when part of cyto.CyLeaflet compared to just cyto.Cytoscape. More investigation needed.
Steps/Code to Reproduce
importdashfromdashimporthtml, dcc, callback, Input, Outputimportdash_cytoscapeascytoimportdash_leafletasdllat_init=45.5lon_init=-73.576print("Preparing elements")
elements= [
{"data": {"id": str(x), "lat": lat_init+x/1000, "lon": lon_init}}
forxinrange(1000)
]
print("Elements created.")
stylesheet= [
{
"selector": "node",
"style": {
"width": 1000,
"height": 100,
"background-color": "red",
},
},
]
defserve_layout():
returnhtml.Div(
children=[
html.H1("DASH CYTOSCAPE - Maximum number of nodes"),
html.Hr(),
dcc.Markdown(
""" * Displaying up to 1000 elements seems doable, but more than that the browser may crash. """
),
cyto.CyLeaflet(
id="cyleaflet",
cytoscape_props=dict(
elements=elements,
stylesheet=stylesheet,
),
),
],
)
app=dash.Dash(__name__)
server=app.serverapp.layout=serve_layoutif__name__=="__main__":
app.run_server(debug=True)
Expected Results
Actual Results
Versions
The text was updated successfully, but these errors were encountered:
The event ('dragfree add remove') gets trigger for each individual node added. So initially it would get triggered 1000 times for this code you have provided. Adding a debounce should fix this without changing any functionality.
Description
The below code instantiates a CyLeaflet instance with 1000 nodes. It takes about 3 seconds to load in my browser (Mac OS 12.6; Chrome 120.0). A plain
cyto.Cytoscape
instance with the same 1000 nodes loads in <0.5s.The profiler shows the code is spending a lot of time in this event handler:
which is triggered each time a node is added, removed, or dragged.
It makes sense that the event handler would be triggered while nodes are being added to the layout, but not clear why it's taking so much longer when part of
cyto.CyLeaflet
compared to justcyto.Cytoscape
. More investigation needed.Steps/Code to Reproduce
Expected Results
Actual Results
Versions
The text was updated successfully, but these errors were encountered: