Skip to content

Commit 3f37635

Browse files
committed
update legend alignments + build dist files
1 parent dd8a980 commit 3f37635

File tree

3 files changed

+13
-9
lines changed

3 files changed

+13
-9
lines changed

dist/plotly.js

+6-4
Original file line numberDiff line numberDiff line change
@@ -97827,15 +97827,17 @@ module.exports = function draw(gd, opts) {
9782797827
var yanchor = getYanchor(opts);
9782897828
// Adjust centering of the legend box
9782997829
var lx;
97830+
var fullPlotWidth = gs.l + gs.w;
9783097831
if (xanchor === 'center' && yanchor === 'top') {
97831-
lx = (gs.w * opts.x - 0.5 * opts._width) * 1.8;
97832+
lx = ((fullPlotWidth * 0.5) - (opts._width * 0.5)) + ((fullPlotWidth-opts._width) / 3.99)-20;
9783297833
} else if (xanchor === 'center' && yanchor === 'bottom') {
97833-
lx = (gs.l + gs.w * opts.x - FROM_TL[getXanchor(opts)] * opts._width)-30;
97834+
lx = ((fullPlotWidth * 0.5) - (opts._width * 0.5))-5;
9783497835
} else if (xanchor === 'center' && yanchor === 'middle') {
97835-
lx = (gs.l + gs.w * opts.x - FROM_TL[getXanchor(opts)] * opts._width)-15;
97836+
lx = ((fullPlotWidth * 0.5) - (opts._width * 0.5));
9783697837
} else {
97837-
lx = gs.l + gs.w * opts.x - FROM_TL[getXanchor(opts)] * opts._width;
97838+
lx = fullPlotWidth * opts.x - FROM_TL[getXanchor(opts)] * opts._width;
9783897839
}
97840+
9783997841
var ly = gs.t + gs.h * (1 - opts.y) - FROM_TL[getYanchor(opts)] * opts._effHeight;
9784097842

9784197843
if(opts._main && fullLayout.margin.autoexpand) {

dist/plotly.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/legend/draw.js

+6-4
Original file line numberDiff line numberDiff line change
@@ -138,15 +138,17 @@ module.exports = function draw(gd, opts) {
138138
var yanchor = getYanchor(opts);
139139
// Adjust centering of the legend box
140140
var lx;
141+
var fullPlotWidth = gs.l + gs.w;
141142
if (xanchor === 'center' && yanchor === 'top') {
142-
lx = (gs.w * opts.x - 0.5 * opts._width) * 1.8;
143+
lx = ((fullPlotWidth * 0.5) - (opts._width * 0.5)) + ((fullPlotWidth-opts._width) / 3.99)-20;
143144
} else if (xanchor === 'center' && yanchor === 'bottom') {
144-
lx = (gs.l + gs.w * opts.x - FROM_TL[getXanchor(opts)] * opts._width)-30;
145+
lx = ((fullPlotWidth * 0.5) - (opts._width * 0.5))-5;
145146
} else if (xanchor === 'center' && yanchor === 'middle') {
146-
lx = (gs.l + gs.w * opts.x - FROM_TL[getXanchor(opts)] * opts._width)-15;
147+
lx = ((fullPlotWidth * 0.5) - (opts._width * 0.5));
147148
} else {
148-
lx = gs.l + gs.w * opts.x - FROM_TL[getXanchor(opts)] * opts._width;
149+
lx = fullPlotWidth * opts.x - FROM_TL[getXanchor(opts)] * opts._width;
149150
}
151+
150152
var ly = gs.t + gs.h * (1 - opts.y) - FROM_TL[getYanchor(opts)] * opts._effHeight;
151153

152154
if(opts._main && fullLayout.margin.autoexpand) {

0 commit comments

Comments
 (0)