Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Save jointjs diagram drawn on paper, which can be rendered to paper to edit

Tags:

svg

jointjs

Working on jointjs diagrams on paper. I am able to download the diagram drawn on a paper using following code:

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

Now I want to save this svg on server, which can be rendered again to paper so that I can edit it and save again.

Is it possible in jointjs?

like image 862
DEV1205 Avatar asked Sep 24 '15 12:09

DEV1205


1 Answers

Nope. SVG import is not possible in JointJS. The way you should do it is to export the diagram into JSON and than 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

like image 123
dave Avatar answered Nov 10 '22 00:11

dave