简体   繁体   English

Jointjs - 调整父子矩形的大小

[英]Jointjs - Resizing parent child rectangles

Const r1 = new shapes.standard.Rectangle(); r1.size(120,120);
Const r2 = new shapes.standard.Rectangle(); r2.size(100,20);

r1.embed(r2);

graph.addCells([r1, r2]);

Result结果

I want to achieve the below expected result but the parent rectangle properties are being overridden by child properties and the parent is being automatically resized.我想实现以下预期结果,但父矩形属性被子属性覆盖,并且父矩形属性正在自动调整大小。 Please suggest how to retain parent properties irrespective of child dimensions.请建议如何保留父属性而不考虑子维度。

Expected result预期结果

It is difficult to say what the issue is from the code provided?从提供的代码很难说问题出在哪里? Could you post more details or code?你能发布更多细节或代码吗?

The following code produces the desired result for example.例如,以下代码会产生所需的结果。

const namespace = joint.shapes;

const graph = new joint.dia.Graph({}, { cellNamespace: namespace });

const paper = new joint.dia.Paper({
      el: document.getElementById('canvas'),
      model: graph,
      width: 600,
      height: 600,
      gridSize: 1,
      cellViewNamespace: namespace
});

const r1 = new joint.shapes.standard.Rectangle();
r1.position(35, 35);
r1.resize(120,120);

const r2 = new joint.shapes.standard.Rectangle();
r2.position(45, 125);
r2.resize(100,20);

r1.embed(r2);

graph.addCells([r1, r2]);

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM