Hello, I found out that this code example from mxCodec to encode a graph model does not work as expected:
var encoder = new mxCodec();
var result = encoder.encode(graph.getModel());
var xml = mxUtils.getXml(result);
When a normal mxGraph instance is provided, everything is encoded correctly except the attributes 'source' and 'target' of an edge, the same that happens in this stackoverflow chat, which is not resolved yet (if @Nickath eventually discovered why that happens, it would be really a big help).
While debugging, the method mxCodec.prototype.getId() returns false when it checks if an Edge is an instance of mxCell. How could it be fixed?
Working code:
const encoder = new mx.mxCodec();
const xmlNode = encoder.encode(graph.getModel());
Input graph:
Graph information:
Edge when encode() is called
Encoding source and value of the edge
method getId() that returns null when checking source's value
Also, I am using the mxObjectCodec.encode written in the jsondata.html example:
I tried to recreate it through a Stackblitz app, but it is not performing the same behavior as in local. If someone encounters this problem again, I would recommend to continue the discussion here. However, many thanks for your interest
Hello, I found out that this code example from mxCodec to encode a graph model does not work as expected:
When a normal mxGraph instance is provided, everything is encoded correctly except the attributes 'source' and 'target' of an edge, the same that happens in this stackoverflow chat, which is not resolved yet (if @Nickath eventually discovered why that happens, it would be really a big help).
While debugging, the method
mxCodec.prototype.getId()
returns false when it checks if an Edge is an instance of mxCell. How could it be fixed?Working code:
Input graph:
Graph information:
Edge when encode() is called
Encoding source and value of the edge
method getId() that returns null when checking source's value
Also, I am using the
mxObjectCodec.encode
written in the jsondata.html example:Output when encode is finished:
I am developing this using angular 7, electron and the version 4.0.5 of mxgraph.
Thank you in advance!