Skip to main content
100%

Custom Beeswarm & ForceLayout

✓ Published0🌍 Public
KKcnarf
Last edited Dec 3, 2018
Created on May 24, 2016

This beeswarm chart visualizes the rank and trend of 150 French words from customer feedback, plotting each word as a circle along the x-axis while preserving its exact position. A custom placement algorithm initially arranges the circles to avoid overlap, then a force-directed layout is applied for a few iterations to reduce extreme accumulations, balancing precision with fast computation. The visualization uses d3.v3 with SVG rendering and supports hover interactions to reveal each word’s data. The code accesses the csv data through the D3 library and includes a dat.gui control panel for adjusting parameters like radius and iteration count.

AI-generated description

This <a href='http://bl.ocks.org/Kcnarf/17e82d3a3afe4a8606e48a3bff8fa50e'>block</a> is a continuation of a <a href='http://bl.ocks.org/Kcnarf/c13da7160e8d8f64d467df8988043d1f'>previous one</a>.

This sequel experiments a way to vizualise the distribution of things (whatever it is) in a horizontal way (ie. along the x-axis), where constraints/objectives are:

  • to maintain the exact position of each datum (represented by a circle) along the x-axis
  • to be able to hover each circle to show related datum
<hr/>

This block produces a beeswarm in 2 stages:

  • define a first arrangement using a custom algorythm (cf. <a href='http://bl.ocks.org/Kcnarf/c13da7160e8d8f64d467df8988043d1f'>previous block</a>)
  • then, use the ForceLayout in order to group extreme accumulations, or constraint the arrangement to a certain size

The ForceLayout is used only few times (5 iterations by default) in order to handle computation time. For comparison, with 600 points:

  • ~1200 ms <== Force only with ~300 iterations
  • ~ 100 ms <== custom only | extreme acc., no overlap, fast
  • ~ 150 ms <== custom (100ms) + force with 5 iterations (50ms) |some overlap, no extreme acc., fast
  • ~ 150ms <== Force only with ~20 iterations | cons: not so beautiful, some overlap, no extreme acc., fast

Acknowledgments to:

  • <a href='https://d3js.org/'>D3.js</a> (v3.5.5)
  • <a href='http://blockbuilder.org'>blockbuilder.org</a>
  • <a href='http://workshop.chromeexperiments.com/'>dat.gui</a>
mit Licensed

Similar vizzes