-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Layout grids #2399
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
Layout grids #2399
Changes from 1 commit
001bd9b
606a601
f01db07
82fbae2
cd6e823
1aec7f7
446f9f9
40dd784
670bdd5
6b8d461
4b43e35
794669b
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 |
---|---|---|
|
@@ -17,14 +17,20 @@ var handleDomainDefaults = require('../../plots/domain').defaults; | |
|
||
function handleLineDefaults(traceIn, traceOut, defaultColor, layout, coerce) { | ||
|
||
coerce('line.color', defaultColor); | ||
|
||
if(hasColorscale(traceIn, 'line') && Lib.isArray(traceIn.line.color)) { | ||
coerce('line.colorscale'); | ||
colorscaleDefaults(traceIn, traceOut, layout, coerce, {prefix: 'line.', cLetter: 'c'}); | ||
} | ||
else { | ||
coerce('line.color', defaultColor); | ||
var lineColor = coerce('line.color', defaultColor); | ||
|
||
if(hasColorscale(traceIn, 'line') && Lib.isArray(lineColor)) { | ||
if(lineColor.length) { | ||
coerce('line.colorscale'); | ||
colorscaleDefaults(traceIn, traceOut, layout, coerce, {prefix: 'line.', cLetter: 'c'}); | ||
// TODO: I think it would be better to keep showing lines beyond the last line color | ||
// but I'm not sure what color to give these lines - probably black or white | ||
// depending on the background color? | ||
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. I agree here. Currently, scatter traces with This probably deserves a new issue. 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. Great -> #2405 |
||
traceOut._commonLength = Math.min(traceOut._commonLength, lineColor.length); | ||
} | ||
else { | ||
traceOut.line.color = defaultColor; | ||
} | ||
} | ||
} | ||
|
||
|
@@ -53,7 +59,10 @@ function dimensionsDefaults(traceIn, traceOut) { | |
} | ||
|
||
var values = coerce('values'); | ||
var visible = coerce('visible', values.length > 0); | ||
var visible = coerce('visible'); | ||
if(!(values && values.length)) { | ||
visible = dimensionOut.visible = false; | ||
} | ||
|
||
if(visible) { | ||
coerce('label'); | ||
|
@@ -63,21 +72,14 @@ function dimensionsDefaults(traceIn, traceOut) { | |
coerce('range'); | ||
coerce('constraintrange'); | ||
|
||
commonLength = Math.min(commonLength, dimensionOut.values.length); | ||
commonLength = Math.min(commonLength, values.length); | ||
} | ||
|
||
dimensionOut._index = i; | ||
dimensionsOut.push(dimensionOut); | ||
} | ||
|
||
if(isFinite(commonLength)) { | ||
for(i = 0; i < dimensionsOut.length; i++) { | ||
dimensionOut = dimensionsOut[i]; | ||
if(dimensionOut.visible && dimensionOut.values.length > commonLength) { | ||
dimensionOut.values = dimensionOut.values.slice(0, commonLength); | ||
} | ||
} | ||
} | ||
traceOut._commonLength = commonLength; | ||
|
||
return dimensionsOut; | ||
} | ||
|
@@ -97,11 +99,18 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout | |
traceOut.visible = false; | ||
} | ||
|
||
// make default font size 10px, | ||
// since we're not slicing uneven arrays anymore, stash the length in each dimension | ||
// but we can't do this in dimensionsDefaults (yet?) because line.color can also | ||
// truncate | ||
for(var i = 0; i < dimensions.length; i++) { | ||
if(dimensions[i].visible) dimensions[i]._length = traceOut._commonLength; | ||
} | ||
|
||
// make default font size 10px (default is 12), | ||
// scale linearly with global font size | ||
var fontDflt = { | ||
family: layout.font.family, | ||
size: Math.round(layout.font.size * (10 / 12)), | ||
size: Math.round(layout.font.size / 1.2), | ||
color: layout.font.color | ||
}; | ||
|
||
|
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.
Thanks for making this more readable albeit less functional. 👌