Skip to content

Commit 2454271

Browse files
committed
Fix syntax and revert change to existing mock
1 parent 8f06d8a commit 2454271

File tree

2 files changed

+9
-13
lines changed

2 files changed

+9
-13
lines changed

src/components/legend/draw.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -163,18 +163,20 @@ function drawOne(gd, opts) {
163163
// draw the remaining pieces below
164164
if(expMargin) return;
165165

166+
var lx, ly;
167+
166168
if(legendObj.xref === 'paper') {
167-
var lx = gs.l + gs.w * legendObj.x - FROM_TL[getXanchor(legendObj)] * legendObj._width;
169+
lx = gs.l + gs.w * legendObj.x - FROM_TL[getXanchor(legendObj)] * legendObj._width;
168170
} else {
169171
legendObj.x = Lib.constrain(legendObj.x, 0, 1); // TODO: Move this to defaults setting?
170-
var lx = fullLayout.width * legendObj.x - FROM_TL[getXanchor(legendObj)] * legendObj._width;
172+
lx = fullLayout.width * legendObj.x - FROM_TL[getXanchor(legendObj)] * legendObj._width;
171173
}
172174

173175
if(legendObj.yref === 'paper') {
174-
var ly = gs.t + gs.h * (1 - legendObj.y) - FROM_TL[getYanchor(legendObj)] * legendObj._effHeight;
176+
ly = gs.t + gs.h * (1 - legendObj.y) - FROM_TL[getYanchor(legendObj)] * legendObj._effHeight;
175177
} else {
176178
legendObj.y = Lib.constrain(legendObj.y, 0, 1); // TODO: Move this to defaults setting?
177-
var ly = fullLayout.height * (1 - legendObj.y) - FROM_TL[getYanchor(legendObj)] * legendObj._effHeight;
179+
ly = fullLayout.height * (1 - legendObj.y) - FROM_TL[getYanchor(legendObj)] * legendObj._effHeight;
178180
}
179181

180182
// TODO: Does this also apply if y/xref=container?

test/image/mocks/legend_outside.json

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,9 @@
5454
"layout":{
5555
"showlegend":true,
5656
"legend":{
57-
"x": 0,
58-
"y": 0,
59-
"xref": "container",
60-
"yref": "container",
61-
"orientation": "h"
62-
},
63-
"margin": {
64-
"t": 75,
65-
"r": 115
57+
"x":1,
58+
"y":1,
59+
"xanchor":"left"
6660
}
6761
}
6862
}

0 commit comments

Comments
 (0)