Skip to main content
100%

Scatterplot with Voronoi

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

This interactive scatterplot uses a Voronoi partition to link each data point to its nearest region, improving tooltip responsiveness in dense areas. The visualization plots life expectancy against GDP per capita using World Bank country data, with points colored by region. However, the Voronoi cells cover the entire chart, so the author adds a distance check in the `mousemoved` function to only display tooltips when the cursor is close enough to the actual data point, preventing confusion in sparse corners. The build uses the D3.js v3 library with SVG rendering and a subtle animation.

AI-generated description

This block is based on Step 3 - Voronoi Scatterplot - Tooltip attached to circle from @NadiehBremer

The Voronoi technics (used to improve interactive experience) is something I like. But I'm quite confused when the mouse is far away from points/subjectsOfMatter. In the original example, this situation arises in the viz's top-left and bottom-right corners.

This block attempts to overcome this issue by:

  • still using the Voronoi partition to identifiy the closest point/subjectOfMmatter when they are close to each others
  • and, checking if the distance from the point to the mouse is close enought (max distance checking)

For the sake of illustration, interactive areas appear in (very) light blue. Voronoï cells and interactive zones would not be rendered in the final viz.

The implementation in this block is javascript-based (cf. function 'mousemoved'). Other ways could be:

  • clip each Voronoï cell with a circle shape (cf. this block)
  • produce adequate path for each limited Voronoï cell (adequate path = path corresponding to (voronoï cell INTERSECT max-distance-from-point circle); cf. this block)

Acknowledgments to:

mit Licensed

Similar vizzes