You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Linked hover: look up the bin by arithmetic instead of one object per cell #38
The server sends one [lo, step, n] triple per binned axis (x_edges, y_edges). The client expands the triples back into one bound object per bin or per cell (_hoverBoundsFromEdges in flexviz/adapters/js/plotly/traces.js) and stores them twice: as trace.customdata and in hoverCellsByTraceUid through _rebuildHoverCells. A 1000 x 1000 histogram2d builds a million objects on every update. The linked-hover matchers in plotly/hover.js then scan those cells linearly to find the one that contains a point. The scan predates this branch; the object expansion is the part the triple makes unnecessary.
Proposal
Keep the triples per trace uid instead of the expanded cells.
Resolve a coordinate to a bin index with floor((v - lo) / step), clamped to [0, n - 1], and derive the bounds of that one bin. Server and client already bin with this arithmetic.
Drop trace.customdata for binned traces once nothing reads it; pt.customdata has one reader in hover.js, which can derive the bounds from pt.x / pt.y and the triple.
Done when
No per-bin or per-cell object is built on the client for histogram, histogram2d or geo traces.
tests/test_browser.py::TestBinEdgeTripleBrowser still passes.
Hover on a 1000 x 1000 histogram2d costs O(1) per event.
#119 closes this issue for hover. Geo is the exception in the "done when" list, and it stays as it is:
Hover builds no object per bin or cell any more, for histogram and histogram2d. The client keeps the [lo, step, n] triples and finds a bin by arithmetic (binAt).
Geo still builds one GeoJSON rectangle per non-empty cell (_geoRectanglesFromEdges). The choroplethmap needs these rectangles to draw the cells, so they are not a hover cost. Geo is not a linked-hover target.
A follow-up for geo makes sense only if a measurement shows that the rectangles are slow.
Activity
jvdd commentedon Sep 29, 2026
#119 closes this issue for hover. Geo is the exception in the "done when" list, and it stays as it is:
[lo, step, n]triples and finds a bin by arithmetic (binAt)._geoRectanglesFromEdges). The choroplethmap needs these rectangles to draw the cells, so they are not a hover cost. Geo is not a linked-hover target.jvdd commentedon Sep 29, 2026
Fixed by #119.