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

Function getCoord

src/components/fx/hover.js:2505–2542  ·  view source on GitHub ↗
(axLetter, winningPoint, fullLayout)

Source from the content-addressed store, hash-verified

2503}
2504
2505function getCoord(axLetter, winningPoint, fullLayout) {
2506 var ax = winningPoint[axLetter + 'a'];
2507 var val = winningPoint[axLetter + 'Val'];
2508
2509 var cd0 = winningPoint.cd[0];
2510
2511 if (ax.type === 'category' || ax.type === 'multicategory') val = ax._categoriesMap[val];
2512 else if (ax.type === 'date') {
2513 var periodalignment = winningPoint.trace[axLetter + 'periodalignment'];
2514 if (periodalignment) {
2515 var d = winningPoint.cd[winningPoint.index];
2516
2517 var start = d[axLetter + 'Start'];
2518 if (start === undefined) start = d[axLetter];
2519
2520 var end = d[axLetter + 'End'];
2521 if (end === undefined) end = d[axLetter];
2522
2523 var diff = end - start;
2524
2525 if (periodalignment === 'end') {
2526 val += diff;
2527 } else if (periodalignment === 'middle') {
2528 val += diff / 2;
2529 }
2530 }
2531
2532 val = ax.d2c(val);
2533 }
2534
2535 if (cd0 && cd0.t && cd0.t.posLetter === ax._id) {
2536 if (fullLayout.boxmode === 'group' || fullLayout.violinmode === 'group') {
2537 val += cd0.t.dPos;
2538 }
2539 }
2540
2541 return val;
2542}
2543
2544// Top/left hover offsets relative to graph div. As long as hover content is
2545// a sibling of the graph div, it will be positioned correctly relative to

Callers 1

_hoverFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…