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

Function textPointPosition

src/components/drawing/index.js:1247–1267  ·  view source on GitHub ↗
(s, textPosition, fontSize, markerRadius, dontTouchParent)

Source from the content-addressed store, hash-verified

1245};
1246
1247function textPointPosition(s, textPosition, fontSize, markerRadius, dontTouchParent) {
1248 var group = d3.select(s.node().parentNode);
1249
1250 var v = textPosition.indexOf('top') !== -1 ? 'top' : textPosition.indexOf('bottom') !== -1 ? 'bottom' : 'middle';
1251 var h = textPosition.indexOf('left') !== -1 ? 'end' : textPosition.indexOf('right') !== -1 ? 'start' : 'middle';
1252
1253 // if markers are shown, offset a little more than
1254 // the nominal marker size
1255 // ie 2/1.6 * nominal, bcs some markers are a bit bigger
1256 var r = markerRadius ? markerRadius / 0.8 + 1 : 0;
1257
1258 var numLines = (svgTextUtils.lineCount(s) - 1) * LINE_SPACING + 1;
1259 var dx = TEXTOFFSETSIGN[h] * r;
1260 var dy = fontSize * 0.75 + TEXTOFFSETSIGN[v] * r + ((TEXTOFFSETSIGN[v] - 1) * numLines * fontSize) / 2;
1261
1262 // fix the overall text group position
1263 s.attr('text-anchor', h);
1264 if (!dontTouchParent) {
1265 group.attr('transform', strTranslate(dx, dy));
1266 }
1267}
1268
1269function extracTextFontSize(d, trace) {
1270 var fontSize = d.ts || trace.textfont.size;

Callers 1

index.jsFile · 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…