react-diagrams icon indicating copy to clipboard operation
react-diagrams copied to clipboard

On deserialization of diagram, links are not getting rendered

Open PikkaPikkachu opened this issue 7 years ago • 3 comments

getDiagram(){
    let engine = this.props.app.getDiagramEngine();
    let model = engine.getDiagramModel();
    model.deSerializeDiagram(JSON.parse(layout), engine);
    engine.setDiagramModel(model);
    this.forceUpdate();
}

I am using this code, to render the diagram from saved model. The links are initially not visible, they only appear after a user's click on the canvas. Any suggestions to why this could be happening?

PikkaPikkachu avatar Jun 26 '19 06:06 PikkaPikkachu

I just started using this package, but I think calling this is worth a try:

engine.repaintCanvas();

jackietieu avatar Jun 26 '19 19:06 jackietieu

@jackietieu thanks for the suggestion, however, I also had to add a delay to make it work. It was related to the links taking time to establish relation between nodes. So I added a delay like so, to render the links as well:

setTimeout(() => {
      engine.repaintCanvas();
      this.forceUpdate();
    });

PikkaPikkachu avatar Jun 27 '19 07:06 PikkaPikkachu

This should be fixed in the 6 beta, gonna close this for now (I overhauled the system entirely)

dylanvorster avatar Aug 11 '19 13:08 dylanvorster