Save the chart diagram drawn on paper that can be displayed on editable paper

Work on diagrams of joint work on paper. I can load a chart drawn on paper using the following code:

var svgDoc = paper.svg;
var serializer = new XMLSerializer();
var svgString = serializer.serializeToString(svgDoc);

Now I want to save this svg on a server that can be displayed on paper again so that I can edit it and save it again.

is it possible in the joints ???

thanks

+4
source share
1 answer

Nope. Import SVG is not possible in JointJS. How you should do this is to export the chart in JSON and import it back:

var json = JSON.stringify(graph);
// send the json to the server, store to DB or whatever....

// ... later on...

// load back the json to the diagram:
graph.fromJSON(JSON.parse(json))

See http://jointjs.com/api#joint.dia.Graph:toJSON

+5
source

Source: https://habr.com/ru/post/1608806/


All Articles