block by susielu 7c7bae35e0944725363a

Circle Pack Labels

Full Screen

Circle Pack Labels

A technique to hack the current d3.layout.pack to add labels by adding a label node into the circle pack data before it is processed. By using the sizes of the children, you add a node to your nested data and create a space using the pack algorithm for the label. You will need to do some filtering to display the labels differently from other nodes at that level, but feel free to use this example as a guide.

I am planning on looking at the d3 code to see how easy it would be to make a build in label layer for this layout. But for now you can follow along with this block if you need circle pack labels today!

Really fun dataset on flight delays that I plan on investigating further: Airline on-time performance data provided by the Department of Transportation’s Bureau of Transportation Statistics

Before

Alt text

After

Alt text

index.html