私はjavascript、jointjs、nodejsの新しいユーザーです。nodejsでjointjsを使う方法
/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を変更します。私はnodejsプロジェクトをビルドするためにwebstormを使用 、ファイル構造は以下の通りですポスト: 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にグラフオブジェクトをレンダリングできますか? ありがとうございます。
ありがとうございます。私はまだクライアントのグラフオブジェクトを扱う方法についてはまだ混乱しています。私はサーバーとクライアントを交換する必要があります。クライアントのhtmlでグラフを受け入れる方法のサンプルコードを提供しますか?私はgraph.fromJSON(graphJSON)を使うべきですか?クライアントのHTML /翡翠のスクリプトでサーバーのデータを取得するには? –
あなたの解決策を見て、AJAXはより良い方法です。 – Calvinxiao