Skip to content

Instantly share code, notes, and snippets.

View robinfhu's full-sized avatar

Robin Hu robinfhu

View GitHub Profile
@robinfhu
robinfhu / README.md
Last active September 10, 2023 10:53

Chart tooltips using quadtrees

Adding tooltip interactivity to charts is one of the most desired features, but also one of the tricker ones to implement. One common solution is to attach .on('mouseover') event handlers to each circle element. This will work okay, except when points start overlapping. You will also start using up lots of memory if the number of points is very large.

A more advanced technique is to use d3.geom.voronoi. This solves the problem of overlapping points, but you still run into performance issues. That's because