Skip to content

Commit 5ef69b3

Browse files
committed
Remove unnecessary code in repositionLegend()
1 parent e8fc236 commit 5ef69b3

File tree

1 file changed

+1
-14
lines changed

1 file changed

+1
-14
lines changed

src/components/legend/draw.js

+1-14
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,6 @@ function drawTexts(context, gd, d, i, traces) {
368368

369369
function repositionLegend(gd, traces) {
370370
var fullLayout = gd._fullLayout,
371-
gs = fullLayout._size,
372371
opts = fullLayout.legend,
373372
borderwidth = opts.borderwidth;
374373

@@ -432,39 +431,27 @@ function repositionLegend(gd, traces) {
432431
.attr('width', (gd._context.editable ? 0 : opts.width) + 40);
433432

434433
// now position the legend. for both x,y the positions are recorded as
435-
// fractions of the plot area (left, bottom = 0,0). Outside the plot
436-
// area is allowed but position will be clipped to the page.
437-
// values <1/3 align the low side at that fraction, 1/3-2/3 align the
438-
// center at that fraction, >2/3 align the right at that fraction
439-
440-
var lx = gs.l + gs.w * opts.x,
441-
ly = gs.t + gs.h * (1-opts.y);
434+
// fractions of the plot area (left, bottom = 0,0).
442435

443436
var xanchor = 'left';
444437
if(anchorUtils.isRightAnchor(opts)) {
445-
lx -= opts.width;
446438
xanchor = 'right';
447439
}
448440
if(anchorUtils.isCenterAnchor(opts)) {
449-
lx -= opts.width / 2;
450441
xanchor = 'center';
451442
}
452443

453444
var yanchor = 'top';
454445
if(anchorUtils.isBottomAnchor(opts)) {
455-
ly -= opts.height;
456446
yanchor = 'bottom';
457447
}
458448
if(anchorUtils.isMiddleAnchor(opts)) {
459-
ly -= opts.height / 2;
460449
yanchor = 'middle';
461450
}
462451

463452
// make sure we're only getting full pixels
464453
opts.width = Math.ceil(opts.width);
465454
opts.height = Math.ceil(opts.height);
466-
lx = Math.round(lx);
467-
ly = Math.round(ly);
468455

469456
// lastly check if the margin auto-expand has changed
470457
Plots.autoMargin(gd, 'legend', {

0 commit comments

Comments
 (0)