简体   繁体   中英

MXGraph: edges are not redrawn when they are moved

this might be a stupid question and I know it is hard to tell without a look at the code... However I have an issue and maybe somebody can point me toward the right direction.

I am developing a javascript mxGraph application integrated with Angular7. I'm using a modified version of the ports.html example.

If I add two nodes and connect them, then I export it in XML with this code:

var enc = new mx.mxCodec(mx.mxUtils.createXmlDocument());
var node = enc.encode(editor.graph.getModel());
xml = mx.mxUtils.getPrettyXml(node);

I am able to save it correctly and then reload it.

However if I move the connection as shown in the image here:

导出 XML 之前

the connection is not redrawn in the graph, although it is present in the model as cell:

导入 XML 后

Here a screenshot of the model, as you can see, both connections are present but just the one that I didn't move is drawn:

在此处输入图片说明

I found the solution... It is somehow related to this past issue that I had: MxCodec decode function not working with XML

As when an edge is moved it creates an Array of mxPoints, which are not decoded properly because of missing ctor in window. The solution was adding to the window:

window['mxPoint'] = mx.mxPoint;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM