如何将另一个Paper变量添加到JointJs的HTML视图中

How to add another Paper variable to JointJs HTML view?

本文关键字:JointJs HTML 视图 添加 另一个 Paper 变量      更新时间:2023-09-26

我正在学习jointjs教程,尤其是HelloWorld(http://www.jointjs.com/tutorial#hello-世界)。除了文本中的空格"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>