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

Function shiftPosition

src/components/annotations/draw.js:74–92  ·  view source on GitHub ↗
(axa, dAx, axLetter, gs, options)

Source from the content-addressed store, hash-verified

72// axDomainRef: if true and axa defined, draws relative to axis domain,
73// otherwise draws relative to data (if axa defined) or paper (if not).
74function shiftPosition(axa, dAx, axLetter, gs, options) {
75 var optAx = options[axLetter];
76 var axRef = options[axLetter + 'ref'];
77 var vertical = axLetter.indexOf('y') !== -1;
78 var axDomainRef = Axes.getRefType(axRef) === 'domain';
79 var gsDim = vertical ? gs.h : gs.w;
80 if(axa) {
81 if(axDomainRef) {
82 // here optAx normalized to length of axis (e.g., normally in range
83 // 0 to 1). But dAx is in pixels. So we normalize dAx to length of
84 // axis before doing the math.
85 return optAx + (vertical ? -dAx : dAx) / axa._length;
86 } else {
87 return axa.p2r(axa.r2p(optAx) + dAx);
88 }
89 } else {
90 return optAx + (vertical ? -dAx : dAx) / gsDim;
91 }
92}
93
94/**
95 * drawRaw: draw a single annotation, potentially with modifications

Callers 2

drawArrowFunction · 0.85
drawGraphicalElementsFunction · 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…