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

Function toMoveInsideSlice

src/traces/treemap/plot_one.js:259–330  ·  view source on GitHub ↗
(pt, opts)

Source from the content-addressed store, hash-verified

257 };
258
259 var toMoveInsideSlice = function(pt, opts) {
260 var x0 = pt.x0;
261 var x1 = pt.x1;
262 var y0 = pt.y0;
263 var y1 = pt.y1;
264 var textBB = pt.textBB;
265
266 var _hasTop = hasTop || (opts.isHeader && !hasBottom);
267
268 var anchor =
269 _hasTop ? 'start' :
270 hasBottom ? 'end' : 'middle';
271
272 var _hasRight = hasFlag('right');
273 var _hasLeft = hasFlag('left') || opts.onPathbar;
274
275 var leftToRight =
276 _hasLeft ? -1 :
277 _hasRight ? 1 : 0;
278
279 if(opts.isHeader) {
280 x0 += (isIcicle ? pad : pad.l) - TEXTPAD;
281 x1 -= (isIcicle ? pad : pad.r) - TEXTPAD;
282 if(x0 >= x1) {
283 var mid = (x0 + x1) / 2;
284 x0 = mid;
285 x1 = mid;
286 }
287
288 // limit the drawing area for headers
289 var limY;
290 if(hasBottom) {
291 limY = y1 - (isIcicle ? pad : pad.b);
292 if(y0 < limY && limY < y1) y0 = limY;
293 } else {
294 limY = y0 + (isIcicle ? pad : pad.t);
295 if(y0 < limY && limY < y1) y1 = limY;
296 }
297 }
298
299 // position the text relative to the slice
300 var transform = toMoveInsideBar(x0, x1, y0, y1, textBB, {
301 isHorizontal: false,
302 constrained: true,
303 angle: 0,
304 anchor: anchor,
305 leftToRight: leftToRight
306 });
307 transform.fontSize = opts.fontSize;
308
309 transform.targetX = viewMapX(transform.targetX);
310 transform.targetY = viewMapY(transform.targetY);
311
312 if(isNaN(transform.targetX) || isNaN(transform.targetY)) {
313 return {};
314 }
315
316 if(x0 !== x1 && y0 !== y1) {

Callers 4

draw_ancestors.jsFile · 0.85

Calls 5

toMoveInsideBarFunction · 0.85
viewMapXFunction · 0.85
viewMapYFunction · 0.85
recordMinTextSizeFunction · 0.85
hasFlagFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…