0

I was hoping to find a way to pack circle nodes into rectangles defined by their aggregate totals, but am struggling to find a way how. After failing at implementation a version described here, I wanted to reach out and ask if there was any known way to do this generally. I have attached a JSFiddle of what I currently have - I've initialized a number of nodes, assigned them randomly to a group number, and am calling the barView function which separates these nodes dependent on their groups. I am hoping to have these nodes be confined within the dimensions of their respective bars, such that dragging these nodes cannot remove them from their box, but they can move within it. I would really appreciate your help in this.

Thank you!

http://jsfiddle.net/abf2er7z/2/

Imas
  • 177
  • 1
  • 1
  • 12
  • You base the height of the bar on the sum of the `total` field of the group. How do you know that you have enough area to fit all circles? Bar height ~= `N*total_max*0.5`, no relation to radius what soever. Do not use a timer to start next phase, use `simulation.on('end,..)` and set `end` handler to `null` inside callback – rioV8 Aug 09 '18 at 10:21
  • https://i.imgur.com/SfmIkgJ.png : `Group C` does not have enough room – rioV8 Aug 09 '18 at 10:43
  • Hi @rioV8 - for the purposes of the example and to get appropriately sized shapes, I didn't base it on their sizes (though this is how I have it approximately in my real implementation). I am curious as to how you were able to get the simulation behavior attached in your image, I would appreciate your help! – Imas Aug 09 '18 at 14:56
  • @rioV8 Hi again! I've been racking my head about how you were able to enable both circle-rectangle and circle-circle collisions in your simulation, as well as pack into a rectangular shape in your image. Can I see how you were able to implement this? I appreciate it! – Imas Aug 09 '18 at 20:51

0 Answers0