jgraph / mxgraph

mxGraph is a fully client side JavaScript diagramming library
Other
6.82k stars 2.06k forks source link

Graph model renders fine, but its XML does not contain the style attribute (the graph.getModel() shows undefined styles) #413

Closed Hell4Ge closed 4 years ago

Hell4Ge commented 4 years ago

Hello

I am trying to export the modified orgchart example by using your export server that has its repository there: https://github.com/jgraph/draw-image-export2

The question is how do I prepare the XML value for this, because I want to keep the gradients exported.

The first attempt I did was to use the https://jgraph.github.io/mxgraph/docs/js-api/files/util/mxImageExport-js.html codec, but this returned a 500 error after a long time of doing "something" (I suspect a timeout). I suspect that this is just wrong to use that method.

The second attempt I did was to use the XML retrieved from mxCodec like in the first example of: https://jgraph.github.io/mxgraph/docs/js-api/files/io/mxCodec-js.html This returned me pure black and white representation of my model without fixing the cell size to its content (no colors, no gradients, no styling).

I am missing something about that XML format, the draw.io page uncompressed XML consists of styled tags like mxGraphModel root mxCell or mxGeometry but mine seems to be more-like simple SVG.

How to get exported XML string with styled elements?

Edit: I noticed that my graph model have undefined styles, i made a screenshot and attached to the issue undefined

Edit2: The graph.getStylesheet() shows the model colours but how do I merge both graph.getModel() and graph.getStylesheet() ?

Edit3: I am actually doing the same thing that happens in the official draw.io source code https://github.com/jgraph/drawio/blob/88af133d284167e1fb9230fb0e45454474074d67/src/main/webapp/js/mxgraph/Dialogs.js#L1454

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.