beeswarm on square and circle path
A beeswarm animation arranges 300 colored circles along a square path, then morphs the path into a circle using the Flubber library’s shape interpolation. The code uses d3.forceSimulation with forceCollide, forceX, and forceY to pack the circles onto the path, while transition.attrTween animates the path shape change. A button triggers the switch between square and circular layouts. Data values map to colors via d3.scaleSequential with an interpolateRainbow scale, and each bee’s position is calculated from its path length using node.getPointAtLength.
AI-generated descriptionPlaying with the Beeswarm along a path approach, forked from <a href='http://bl.ocks.org/1wheel/'>1wheel</a>'s block: <a href='http://bl.ocks.org/1wheel/615030f6847276d7db775ce2b80563c1'>beeswarm-path</a>, which was suggested by Arman.
The 'square' path needs to start half way up the left hand side (50, 400) so the start and end of the path lines up with the final circle path.
It uses Flubber (https://github.com/veltman/flubber) to create a nice transition between the square and circle.
forked from <a href='http://bl.ocks.org/tomshanley/'>tomshanley</a>'s block: <a href='http://bl.ocks.org/tomshanley/0260ae1c415011e3361a54ff977e7268'>beeswarm on square and circle path</a>
forked from <a href='http://bl.ocks.org/tomshanley/'>tomshanley</a>'s block: <a href='http://bl.ocks.org/tomshanley/2fb1dac5dfacbf6a7a30708ec6f269ef'>beeswarm on square and circle path</a>
forked from <a href='http://bl.ocks.org/tomshanley/'>tomshanley</a>'s block: <a href='http://bl.ocks.org/tomshanley/d275639b91ab3fd94446f25422fc46c4'>beeswarm on square and circle path</a>