I attempted to implemented the same circle packing example and had overlapping circles, too. For me the problem was cause by the fact that data parent nodes had 0 children and size 0. Once I changed the parent nodes with an empty array of children into correctly formatted leaves, the problem went away.
Bad overlapping before data structure:
root = {name:"root",
children:[
{name:"badchildlessparent", children:[]},
{name:"parentnodewithchild", children:[{name:"a leaf",size=50}]}
]
}
Nicely packing after data structure:
root = {name:"root",
children:[
{name:"fixedit_now_child", size=1} ,
{name:"parentnodewithchild", children:[{name:"a leaf",size=50}]}
]
}