Comments (1)
This issue doesn't only apply to CyLeaflet AIO component. It is caused when the Cytoscape component is loaded and then its position on the DOM changes. I have been able to reproduce this behaviour by inputing a large number of elements to Cytoscape and having a dcc.Markdown
above it. For some reason, the content in the dcc.Markdown
loads after the Cytoscape
so this is pushed down.
Easier ways to reproduce this would be to change the style of the elements around the Cytoscape component via callback. Any changes that result in modifying the position of the Cytoscape component will cause this mouse mismatch. For example, if you look closely at the video attached in the description it's possible to see that the mismatch is only vertical and of the exact height of the text between the title and the Cytoscape component.
The issue is solved by calling the cytoscape function cy.resize()
, which is equivalent to resizing the window manually (as shown in the video).
The problem is where do we call this function since it can't run automatically when the DOM changes?
A partial solution would be to add it on a viewport
event and on ('dragfree add remove')
so we can make sure that only the first click is mismatching.
This code can be used to replicate the issue.
import dash
from dash import html, dcc, callback, Input, Output
import dash_cytoscape as cyto
lat_init = 45.5
lon_init = -73.576
elements = [
{"data": {"id": str(x), "lat": lat_init + x / 1000, "lon": lon_init}}
for x in range(10)
]
stylesheet = [
{
"selector": "node",
"style": {
"width": 1000,
"height": 100,
"background-color": "red",
},
},
]
def serve_layout():
return html.Div(
children=[
html.H1("DASH CYTOSCAPE"),
html.Hr(),
dcc.Markdown(
"""
* Several
* lines
* to
* show
* mismatch
""",
id="text",
),
cyto.CyLeaflet(
id="cyleaflet",
cytoscape_props=dict(
elements=elements,
stylesheet=stylesheet,
)
),
html.Button("Show/hide text", id="btn")
],
)
@callback(
Output("text", "style"),
Input("btn", "n_clicks")
)
def click(click):
if not click or click % 2 == 0:
return {"display": "block"}
return {"display": "none"}
app = dash.Dash(__name__)
server = app.server
app.layout = serve_layout
if __name__ == "__main__":
app.run_server(debug=True)
from dash-cytoscape.
Related Issues (20)
- Cannot replicate documentation example
- [BUG] Find_by_id with method "dfs" not working in util tree class
- [Feature request]: clickNodeData callback
- invalidateDimensions and resize HOT 2
- Q: Is this repo being actively managed? HOT 2
- Readme Gallery Demos Broken
- [BUG] Elements positions don't match specification in preset layout
- Dash fails to load extra layouts: No such layout `cola` found.
- Infinite zoom out remove the object
- Feature request: Tooltip for nodes and edges
- Adding Elements does not work with Clientside Callbacks
- [BUG] CyLeaflet: Updating Leaflet tile layers does not change max zoom of CyLeaflet HOT 1
- [BUG] CyLeaflet: Updating tile layer causes map to be initially blue before pan/zoom HOT 1
- CyLeaflet: Allow access to updated lat/lon of Cytoscape elements when modified by user HOT 1
- CyLeaflet: Provide way of updating Dash Cytoscape `elements` via callback
- [Feature Request] Allow custom function for nodeRepulsion attribute in cose layout
- Performance of CyLeaflet for larger numbers of nodes (>1000) HOT 1
- [BUG] node label cannot be updated when connected to an edge, after upgrading `dash-cytoscape` from `0.3.0` to `1.0.0`
- [Bug ]demo usage-image-export.py results in Invalid argument error 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 dash-cytoscape.