cytoscape.js-layers
cytoscape.js-layers copied to clipboard
How to restyle with renderPerEdge
Hello,
How can I change the style after calling renderPerEdge? Example, changing the color between red and blue using two buttons. It seems to rerender additionally for each click if I call below code on button click.
layers.renderPerEdge(customLayer, (ctx, edge, path) => {
ctx.strokeStyle = btnColor;
ctx.stroke(path);
});
the customLayer should have an update function that you can call to force a rerender.
Alternatively, you can customize using the third parameter which events should trigger a rerender.
Sorry I'm not very good at this and not sure how to update with customLayer. What I did is assigning a variable to layers.renderPerEdge and then remove that variable renderedEdges.remove(). If it is an acceptable solution, please close this issue or let me know to close it.
have you tried calling customLayer.update() to force a render update instead?
Hi @sgratzl,
I just tried and it works great. Is there any disadvantage of removing layers.renderPerEdge.