I really want to use the cool functions of automove in my dash cytoscape graph.
What is the best way to do it? As I am not familiar with JS it is difficult for me to understand the cytoscape instances and the correct way of registering automove.
I see two possibilities there (neither of them worked so far):
- Adding cytoscape-automove.js in the assets folder.
- I am not sure it is possible to register a js extension when cytoscape is already initiated . I had errors like this
ReferenceError: cytoscape is not defined
orTypeError: cytoscape is not a function
- Modifying the dash_cytoscape package by cloning it and
npm install cytoscape-automove
.
- Is it even a good idea?) I am desperate as you can see.
- I have tried to
npm run build:all
but I suspect the way I am registeringautomove
in the files is incorrect… I am using a testing clienside callback in the app:
app.clientside_callback(
"""
function(elements) {
var cy = window.cy;
if (!cy) {
console.error("Cytoscape instance is not available.");
return '';
}
// Check if automove is available
if (typeof cy.nodes().automove !== 'function') {
console.error("Automove is not available!");
return '';
}
console.log("Automove available:", typeof cy.nodes().automove);
cy.nodes().automove({
reposition: 'mean',
nodesMatching: cy.nodes(),
dragWith: cy.nodes()
});
return '';
}
""",
Output('dummy-output', 'children'),
[Input('graph', 'elements')]
)
and getting “Automove is not available!” of course…
Could someone push me in the right direction? I’d appreciate any advice!