Skip to content

Pointer pooling in 0.6.18 hides picks that 0.6.17 showed #2475

Open

Description

@max-sixty

Since 0.6.18, pointer marks that share a plot can hide each other's picks in two ways. Both examples below show every pick on 0.6.17 and lose one on 0.6.19, checked by dispatching a pointermove at the stated place and waiting two animation frames.

1. A pointer that picks nothing outranks a real pick. A pointer that picks nothing still enters the pool, ranked by ri = maxRadius * maxRadius. The frame callback in update (src/interactions/pointer.js) picks the entry with the smallest ri, so the empty entry wins whenever the real pick is farther from the pointer than the empty pointer's maxRadius, and every pointer renders null. Below, the second mark reaches 1px. Pointing 10px right of "near" shows its tip on 0.6.17 and nothing on 0.6.19; with pool: false on both tips, 0.6.19 shows it.

Plot.plot({
  x: {domain: [0, 10]},
  y: {domain: [0, 10]},
  marks: [
    Plot.dot([{id: "near", x: 2, y: 2}], {x: "x", y: "y", title: "id", tip: true}),
    Plot.dot([{id: "far", x: 9, y: 9}], {x: "x", y: "y", title: "id", tip: {maxRadius: 1}})
  ]
})

The same happens with the default reach whenever a pick lies more than 40px from the pointer, which a tip picking along one axis (tip: "x" or tip: "y") does routinely, since its weighted pick ignores most of the other axis. Facets are pooled whatever pool says, so a faceted chart with tip: "x" loses its tip when the pointer is 60px above a point and the other facet picks nothing, even with pool: false. In 0.6.17 the faceted path deleted an empty facet's entry (facetState.delete(index.fi)) before comparing. Ranking only entries that picked something restores both cases:

for (const c of pool.map.values()) if (c.ii != null && (!best || c.ri < best.ri)) best = c;

2. A later mark's pool: false is ignored. The per-plot pointer state is created by the first pointer mark that renders, with pool: this.pool ? {map: new Map()} : null, and every later pointer mark uses state.pool ?? facetPool. When a tip renders first, a later highlight mark that sets pool: false joins the tip's pool and loses to the tip's nearer pick. Pointing at "near" below draws the tip and the red ring on 0.6.17, and only the tip on 0.6.19. With the two marks in the other order, 0.6.19 draws both.

Plot.plot({
  x: {domain: [0, 10]},
  y: {domain: [0, 10]},
  marks: [
    Plot.tip([{id: "near", x: 2, y: 2}], Plot.pointer({x: "x", y: "y", title: "id"})),
    Plot.dot([{x: 2.2, y: 2}], Plot.pointer({x: "x", y: "y", pool: false, r: 8, stroke: "red", fill: "none"}))
  ]
})

Fixing the first case doesn't change the second: with the ranking change above, 0.6.19 still draws only the tip here.

This was written by Claude Code on behalf of max-sixty

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions