我想让joint.js库读取我的JSON并将其显示为图表…
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:
joint.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:
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。