-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Implement layout.legend.orientation
(closes #53)
#535
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
ff16df1
ddc6d71
f40dbd4
92ff540
869538c
b2538e1
9dc2609
f68344b
c0dfc8a
e5049c9
23e3972
25c2970
7d502fa
107883a
65aa6c0
8c6d47a
bc20390
c1632d4
313976d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,7 +21,11 @@ module.exports = function legendDefaults(layoutIn, layoutOut, fullData) { | |
containerOut = layoutOut.legend = {}; | ||
|
||
var visibleTraces = 0, | ||
defaultOrder = 'normal'; | ||
defaultOrder = 'normal', | ||
defaultX, | ||
defaultY, | ||
defaultXAnchor, | ||
defaultYAnchor; | ||
|
||
for(var i = 0; i < fullData.length; i++) { | ||
var trace = fullData[i]; | ||
|
@@ -57,14 +61,30 @@ module.exports = function legendDefaults(layoutIn, layoutOut, fullData) { | |
coerce('bordercolor'); | ||
coerce('borderwidth'); | ||
Lib.coerceFont(coerce, 'font', layoutOut.font); | ||
|
||
coerce('orientation'); | ||
if(containerOut.orientation === 'h') { | ||
var xaxis = layoutIn.xaxis; | ||
if(xaxis && xaxis.rangeslider && xaxis.rangeslider.visible) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep, that works. |
||
defaultX = 0; | ||
defaultXAnchor = 'left'; | ||
defaultY = 1.1; | ||
defaultYAnchor = 'bottom'; | ||
} | ||
else { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @n-riesco can you add a few jasmine test cases in |
||
defaultX = 0; | ||
defaultXAnchor = 'left'; | ||
defaultY = -0.1; | ||
defaultYAnchor = 'top'; | ||
} | ||
} | ||
|
||
coerce('traceorder', defaultOrder); | ||
if(helpers.isGrouped(layoutOut.legend)) coerce('tracegroupgap'); | ||
|
||
coerce('x'); | ||
coerce('xanchor'); | ||
coerce('y'); | ||
coerce('yanchor'); | ||
coerce('x', defaultX); | ||
coerce('xanchor', defaultXAnchor); | ||
coerce('y', defaultY); | ||
coerce('yanchor', defaultYAnchor); | ||
Lib.noneOrAll(containerIn, containerOut, ['x', 'y']); | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should add some smart default logic so that if a user set
orientation
to'h
', the default'x'
would be0
(instead of1.02
).Moreover, maybe we should make the default
'y'
value0
instead of1
? But that one is less obvious to me.@mdtusz @chriddyp @jackparmer should the default horizontal legend start at the bottom-left or at the top-left corner of the plot area?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd think bottom left but if we do this, we will need to take into account the case where range sliders are present. The legend is currently rendered below it so it gets hidden if it is placed in the same place.