MCPcopy Index your code
hub / github.com/plotly/plotly.js / forwardHoverClickAnywhere

Function forwardHoverClickAnywhere

src/components/shapes/draw.js:195–227  ·  view source on GitHub ↗
(gd, path, plotinfo)

Source from the content-addressed store, hash-verified

193}
194
195function forwardHoverClickAnywhere(gd, path, plotinfo) {
196 if (!plotinfo?.id) return;
197
198 const node = path.node();
199
200 // Fx.hover/Fx.click compute plot-area pixel coordinates from
201 // evt.clientX/Y relative to evt.target's bounding box.
202 // The shape path's bbox differs from the plot area, so we
203 // re-target events to the subplot's nsewdrag element.
204 function patchedEvt(evt) {
205 const mainPlot = plotinfo.mainplotinfo || plotinfo;
206 const nsew = mainPlot?.draglayer?.select('.nsewdrag').node();
207 if (!nsew) return null;
208
209 return { clientX: evt.clientX, clientY: evt.clientY, target: nsew };
210 }
211
212 node.addEventListener('mousemove', (evt) => {
213 if (gd._dragging) return;
214 if (gd._fullLayout.hoveranywhere) {
215 const e = patchedEvt(evt);
216 if (e) Fx.hover(gd, e, plotinfo.id);
217 }
218 });
219
220 node.addEventListener('click', (evt) => {
221 if (gd._dragged) return;
222 if (gd._fullLayout.clickanywhere) {
223 const e = patchedEvt(evt);
224 if (e) Fx.click(gd, e, plotinfo.id);
225 }
226 });
227}
228
229function setClipPath(shapePath, gd, shapeOptions) {
230 // note that for layer="below" the clipAxes can be different from the

Callers 1

drawShapeFunction · 0.85

Calls 1

patchedEvtFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…