Skip to main content
100%

Scatterplot with Voronoi

✓ Published0🌍 Public
PPhilippe Rivière
Last edited Oct 11, 2016
Created on Sep 21, 2016

This scatterplot visualizes life expectancy versus GDP per capita for countries, using color to indicate region and circle size for GDP. The chart uses a D3.v4 Voronoi diagram, implemented with the `d3-voronoi` library’s `find(x,y,radius)` method, to detect when the mouse hovers near a data point without relying on an SVG overlay. This allows for efficient, lazy computation of the Voronoi grid and precise tooltip triggering. The interaction is enhanced with a distance limit, so tooltips appear only when the cursor is within a defined proximity of a circle.

AI-generated description

This is a D3.v4 port by Philippe Rivière of <a href='http://bl.ocks.org/nbremer/'>Nadieh Bremer</a>'s block: <a href='http://bl.ocks.org/nbremer/61cd485e399b6a71d5fb2b1072fbc6c1'>Step 6 - Final - Voronoi (Distance Limited Tooltip) Scatterplot</a>.

In addition, we use d3.voronoi.find(x,y,radius) to locate the point, instead of relying on a SVG overlay of clipped circles.

This gives:

  1. lazy computation of the Voronoi
  2. other objects are allowed capture the mouse before svg.

------ 8X --------

Nadieh:

This scatterplot is part of the extension of my blog on Using a D3 Voronoi grid to improve a chart's interactive experience. After writing that blog Franck Lebeau came with another version which uses large circles to define the tooltip region. I thought this was a great idea! But I made this variation on his code, because I felt that the extra code used in this example (versus the previous version 4) is more in line with the rest of the code.

The tooltip now reacts when you hover over an invisible large circular region around each circle.

You can find all of the steps here

forked from <a href='http://bl.ocks.org/Fil/'>Fil</a>'s block: <a href='http://bl.ocks.org/Fil/7d4ac8a6c259e3d4329c54c4f1abed34'>Step 6 - d3.v4 [UNLISTED]</a>

Similar vizzes