简体   繁体   English

MXGraph:边缘移动时不会重绘

[英]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.我正在开发一个与 Angular7 集成的 javascript mxGraph 应用程序。 I'm using a modified version of the ports.html example.我使用的是ports.html 示例的修改版本。

If I add two nodes and connect them, then I export it in XML with this code:如果我添加两个节点并连接它们,那么我使用以下代码将其导出为 XML:

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我找到了解决方案......它与我过去的这个问题有某种关系: 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.当一条边被移动时,它会创建一个 mxPoints 数组,由于窗口中缺少 ctor,因此无法正确解码。 The solution was adding to the window:解决方案是添加到窗口:

window['mxPoint'] = mx.mxPoint;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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