JointJS resetCells() not working! Getting an error: Uncaught TypeError: dia.Graph: cell type must be a string.

889 views
Skip to first unread message

yufeng....@gmail.com

unread,
Mar 16, 2017, 11:16:23 PM3/16/17
to JointJS
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! 

yufeng....@gmail.com

unread,
Mar 17, 2017, 12:37:12 AM3/17/17
to JointJS
I solved this problem by changing
graph.resetCells(newcell);
to
graph.resetCells([newcell]);

input an array instead of single cell name.
I hope someone could edit this method description in the API. 
Thank you.

Roman Bruckner

unread,
Mar 20, 2017, 11:06:48 AM3/20/17
to joi...@googlegroups.com
Hi,

thanks for letting us know. This was a bug in the implementation. The method ignored the cells if a single cell was passed in.

`resetCells(newCell1, newCell2)` // this works
`resetCells(newCell1)` // while this doesn't

Here is a fix: https://github.com/clientIO/joint/pull/544

Best,
Roman

--

---
You received this message because you are subscribed to the Google Groups "JointJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jointjs+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Reply all
Reply to author
Forward
0 new messages