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

Function moveShape

src/components/shapes/draw.js:495–541  ·  view source on GitHub ↗
(dx, dy)

Source from the content-addressed store, hash-verified

493 }
494
495 function moveShape(dx, dy) {
496 if (shapeOptions.type === 'path') {
497 var noOp = function (coord) {
498 return coord;
499 };
500 var moveX = noOp;
501 var moveY = noOp;
502
503 if (xPixelSized) {
504 modifyItem('xanchor', (shapeOptions.xanchor = p2x(xAnchor + dx)));
505 } else {
506 moveX = function moveX(x) {
507 return p2x(x2p(x) + dx);
508 };
509 if (xa && xa.type === 'date') moveX = helpers.encodeDate(moveX);
510 }
511
512 if (yPixelSized) {
513 modifyItem('yanchor', (shapeOptions.yanchor = p2y(yAnchor + dy)));
514 } else {
515 moveY = function moveY(y) {
516 return p2y(y2p(y) + dy);
517 };
518 if (ya && ya.type === 'date') moveY = helpers.encodeDate(moveY);
519 }
520
521 modifyItem('path', (shapeOptions.path = movePath(pathIn, moveX, moveY)));
522 } else {
523 if (xPixelSized) {
524 modifyItem('xanchor', (shapeOptions.xanchor = p2x(xAnchor + dx)));
525 } else {
526 modifyItem('x0', (shapeOptions.x0 = p2x(x0 + dx)));
527 modifyItem('x1', (shapeOptions.x1 = p2x(x1 + dx)));
528 }
529
530 if (yPixelSized) {
531 modifyItem('yanchor', (shapeOptions.yanchor = p2y(yAnchor + dy)));
532 } else {
533 modifyItem('y0', (shapeOptions.y0 = p2y(y0 + dy)));
534 modifyItem('y1', (shapeOptions.y1 = p2y(y1 + dy)));
535 }
536 }
537
538 shapePath.attr('d', getPathString(gd, shapeOptions));
539 renderVisualCues(shapeLayer, shapeOptions);
540 drawLabel(gd, index, shapeOptions, shapeGroup);
541 }
542
543 function resizeShape(dx, dy) {
544 if (isPath) {

Callers

nothing calls this directly

Calls 6

modifyItemFunction · 0.85
movePathFunction · 0.85
renderVisualCuesFunction · 0.85
drawLabelFunction · 0.85
x2pFunction · 0.70
y2pFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…