Skip to content
This repository was archived by the owner on Apr 21, 2023. It is now read-only.

Horizontal legend spacing #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

markwatabe
Copy link

No description provided.

@mboorstin
Copy link

Please remove the booger file.

Copy link

@mboorstin mboorstin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does this respond to legend groups (ie traceorder: "grouped" with an appropriate legendgroup trace)?

@@ -590,14 +591,14 @@ function computeLegendDimensions(gd, groups, traces) {
maxTraceWidth = 0,
offsetX = 0;

// calculate largest width for traces and use for width of all legend items
// calculate largest width for traces and use for width of all legend items (if horizontalspacing mode is 'column')
traces.each(function(d) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maxTraceWidth isn't used unless isHorizontalColumn is true, so don't compute it if not.

traces.each(function(d) {
maxTraceWidth = Math.max(40 + d[0].width, maxTraceWidth);
});

traces.each(function(d) {
var legendItem = d[0],
traceWidth = maxTraceWidth,
traceWidth = isHorizontalColumn ? maxTraceWidth : 40 + d[0].width,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is the 40 coming from? Leave a comment.


exports.isHorizontalColumn = function isHorizontalColumn(legendLayout) {
return legendLayout.horizontalspacing === 'column';
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing newline

describe('isHorizontalColumn', function() {
var isHorizontalColumn = helpers.isHorizontalColumn;

it('should return true when option horizontalspacing is "column"', function() {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Break this into two tests: should return true when option horizontalspacing is "column", and should return false when option horizontalspacing is "wrapped"

@@ -628,3 +637,54 @@ describe('legend restyle update', function() {
});
});
});

describe('legend horizontal spacing', function() {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good tests!

@mboorstin mboorstin force-pushed the horizontal-legend-spacing branch from e5836b4 to 8296b90 Compare October 12, 2016 18:04
quickgiant pushed a commit that referenced this pull request Aug 16, 2019
* Fix bug in scattergl plot
* Added tests for scattergl plot update
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants