var paper = new joint.dia.Paper({
el: $('#paper'),width: 600,height: 200,model: graph
});
var graph = new joint.dia.Graph;
jsonstring = '{"employees": [ { "firstName":"John","lastName":"Doe" },{ "firstName":"Anna","lastName":"Smith" },{ "firstName":"Peter","lastName":"Jones" } ] }';
graph.fromJSON(JSON.parse(jsonstring));
最佳答案
来自joint.dia.Graph的API:
原文链接:/js/429845.htmljoint.dia.Graph is the model holding all the cells (elements and
links) of the diagram. It’s a 07001. The collection of all the cells
is stored in the property cells.
所以预期的JSON应该采用以下形式:{cells:[]}.其中,单元格是元素和链接的数组.每个元素都应该具有以下形式:
{
id: