【发布时间】:2016-11-29 13:37:06
【问题描述】:
我是 javascript、jointjs 和 nodejs 的新用户。 我用webstorm搭建了一个nodejs项目,文件结构如下:
/test
/bin
www
/node_modules
/public
/routes
index.js
users.js
/views
error.jade
index.jade
layout.jade
app.js
pacakge.json
我想在node.js项目中使用jointjs来绘制流程图,所以我根据帖子将index.js改成如下: Explain or demonstrate integration between JointJS and Node.js
index.js
var express = require('express');
var router = express.Router();
var joint = require('jointjs');
var graph = new joint.dia.Graph;
var el1 = new joint.shapes.basic.Rect({position: {x: 50, y: 50}, attrs: {text: {fill: 'yellow'}}});
var el2 = new joint.shapes.basic.Rect({position: {x: 300, y: 200}, attrs: {text: {fill: 'yellow'}}});
var link = new joint.dia.Link({source: {id: el1.id}, target: {id: el2.id}});
graph.addCells([el1, el2, link]);
/* GET home page. */
router.get('/', function (req, res, next) {
res.render('index', {title: 'Express'});
});
module.exports = router;
然后,我对如何将 graph.toJSON() 对象发送到响应感到困惑?如何在 index.jade 中渲染图形对象? 非常感谢。
【问题讨论】:
标签: javascript node.js express jointjs