I have tried to add new cells into an existing graph by using graph.resetCells() method.
But I keep getting the same error : Uncaught TypeError: dia.Graph: cell type must be a string.
Here is my implement code:
<div id="paper" style="width:300px;height:300px;border:1px black solid">
</div>
<button id="test"> Click me </button>
<script>
var graph = new joint.dia.Graph();
var paper = new joint.dia.Paper({
el: $('#paper'),
width: 800,
height: 600,
model: graph,
gridSize: 1
});
var cell = new joint.shapes.basic.Rect({
position: { x: 50, y: 50 },
size: { width: 50, height: 50},
});
graph.addCell(cell);
$("#test").on("click",function(){
var newcell = new joint.shapes.basic.Rect({
position: { x: 100, y: 100 },
size: { width: 50, height: 50},
});
graph.resetCells(newcell);
});
</script>
I'm hoping someone could help me out!
Thank you!