Jointjs - Resizing parent child rectangles

Viewed 29
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

1 Answers

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]);

enter image description here

Related