Skip to content

Commit 42f4cde

Browse files
committed
simplify and fix case of fraction when zero
1 parent 452049e commit 42f4cde

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

src/components/legend/draw.js

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -354,18 +354,13 @@ function _draw(gd, legendObj) {
354354
function getTraceWidth(d, legendObj, textGap) {
355355
var legendItem = d[0];
356356
var legendWidth = legendItem.width;
357+
var mode = legendObj.entrywidthmode;
357358

358359
var traceLegendWidth = legendItem.trace.legendwidth || legendObj.entrywidth;
359360

360-
if(traceLegendWidth) {
361-
if(legendObj.entrywidthmode === 'pixels') {
362-
return traceLegendWidth + textGap;
363-
} else {
364-
return legendObj._maxWidth * traceLegendWidth;
365-
}
366-
}
361+
if(mode === 'fraction') return legendObj._maxWidth * traceLegendWidth;
367362

368-
return legendWidth + textGap;
363+
return textGap + (traceLegendWidth || legendWidth);
369364
}
370365

371366
function clickOrDoubleClick(gd, legend, legendItem, numClicks, evt) {

0 commit comments

Comments
 (0)