Interactive guideline tooltips mishandle touch coordinates and lifecycle
Problem
nv.interactiveGuideline registers a touchmove handler, but the handler reads d3.event.clientX and d3.event.clientY. Those coordinates live on TouchEvent.touches[0] (or changedTouches[0]), so touch interaction dispatches NaN chart coordinates. The tooltip position model reads the same unavailable properties and places the tooltip incorrectly.
The interactive layer also does not listen for touchend or touchcancel, leaving tooltips and guidelines visible after the gesture ends.
Reproduction
- Open an interactive-guideline chart on a touch device.
- Touch or scroll across the chart.
- Observe an incorrectly positioned tooltip, often showing the first/zero-valued point.
- End the gesture; the tooltip remains visible.
A browser test dispatching a touch at (60, 50) against an SVG at (10, 20) with (5, 5) margins currently receives mouseX: NaN instead of 45. The tooltip position returns undefined instead of (60, 50), and remains visible after touchend/touchcancel.
Proposed fix
- Normalize mouse/touch coordinates through the active touch or changed touch.
- Hide the tooltip and guideline on
touchendandtouchcancel. - Add regression coverage for coordinate dispatch, tooltip position, and lifecycle cleanup.
I have a patch and browser regression tests ready and will open a linked pull request.
Generated by OpenAI Codex and posted on behalf of @andrebrait.
Source: novus/nvd3