如何将另一个 Paper 变量添加到 JointJs HTML 视图?
How to add another Paper variable to JointJs HTML view?
我正在学习 jointjs 教程,特别是 HelloWorld (http://www.jointjs.com/tutorial#hello-world)。基本示例工作正常,除了文本中的 space:'my box' 导致奇怪的字符。但是,按照教程中的建议添加另一篇小论文是行不通的,我没有得到教程中指示的 2 篇工作论文。建议的添加是
var paperSmall = new joint.dia.Paper({
el: $('#myholder-small'),
width: 600,
height: 100,
model: graph,
gridSize: 1
});
paperSmall.scale(.5);
paperSmall.$el.css('pointer-events', 'none');
如何把加法和主代码结合起来?主要代码如下:
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="joint.css" />
<script src="jquery.js"></script>
<script src="lodash.js"></script>
<script src="backbone.js"></script>
<script src="joint.js"></script>
</head>
<body>
<div id="myholder"></div>
<script type="text/javascript">
var graph = new joint.dia.Graph;
var paper = new joint.dia.Paper({
el: $('#myholder'),
width: 600,
height: 200,
model: graph,
gridSize: 1
});
var rect = new joint.shapes.basic.Rect({
position: { x: 100, y: 30 },
size: { width: 100, height: 30 },
attrs: { rect: { fill: 'blue' }, text: { text: 'my box', fill: 'white' } }
});
var rect2 = rect.clone();
rect2.translate(300);
var link = new joint.dia.Link({
source: { id: rect.id },
target: { id: rect2.id }
});
graph.addCells([rect, rect2, link]);
</script>
</body>
</html>
不知何故,教程没有指定第二篇论文应与 HTML 中的另一篇 div 相关联:
<div id="myholder-small"></div>
我正在学习 jointjs 教程,特别是 HelloWorld (http://www.jointjs.com/tutorial#hello-world)。基本示例工作正常,除了文本中的 space:'my box' 导致奇怪的字符。但是,按照教程中的建议添加另一篇小论文是行不通的,我没有得到教程中指示的 2 篇工作论文。建议的添加是
var paperSmall = new joint.dia.Paper({
el: $('#myholder-small'),
width: 600,
height: 100,
model: graph,
gridSize: 1
});
paperSmall.scale(.5);
paperSmall.$el.css('pointer-events', 'none');
如何把加法和主代码结合起来?主要代码如下:
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="joint.css" />
<script src="jquery.js"></script>
<script src="lodash.js"></script>
<script src="backbone.js"></script>
<script src="joint.js"></script>
</head>
<body>
<div id="myholder"></div>
<script type="text/javascript">
var graph = new joint.dia.Graph;
var paper = new joint.dia.Paper({
el: $('#myholder'),
width: 600,
height: 200,
model: graph,
gridSize: 1
});
var rect = new joint.shapes.basic.Rect({
position: { x: 100, y: 30 },
size: { width: 100, height: 30 },
attrs: { rect: { fill: 'blue' }, text: { text: 'my box', fill: 'white' } }
});
var rect2 = rect.clone();
rect2.translate(300);
var link = new joint.dia.Link({
source: { id: rect.id },
target: { id: rect2.id }
});
graph.addCells([rect, rect2, link]);
</script>
</body>
</html>
不知何故,教程没有指定第二篇论文应与 HTML 中的另一篇 div 相关联:
<div id="myholder-small"></div>