-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Add additional options for automargin property #6193
Changes from 5 commits
25a54a2
0ed3602
0702b78
35268c7
57452c2
9dfdb91
cf26237
ee97962
eed9bbf
ae1b087
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 | ||
---|---|---|---|---|
|
@@ -2622,6 +2622,8 @@ axes.drawOne = function(gd, ax, opts) { | |||
rangeSliderPush = Registry.getComponentMethod('rangeslider', 'autoMarginOpts')(gd, ax); | ||||
} | ||||
|
||||
keepSelectedAutoMargin(ax.automargin, push); | ||||
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. So if(typeof automargin === 'string') filterPush(push, ax.automargin); On another note, wondering if mutating 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 don't see the point of using a mirror if the result would still be cut off. So there is no need to filter the 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. Actually I think it's correct to filter |
||||
|
||||
Plots.autoMargin(gd, axAutoMarginID(ax), push); | ||||
Plots.autoMargin(gd, axMirrorAutoMarginID(ax), mirrorPush); | ||||
Plots.autoMargin(gd, rangeSliderAutoMarginID(ax), rangeSliderPush); | ||||
|
@@ -2636,6 +2638,39 @@ axes.drawOne = function(gd, ax, opts) { | |||
return Lib.syncOrAsync(seq); | ||||
}; | ||||
|
||||
function keepSelectedAutoMargin(automargin, push) { | ||||
if(typeof automargin === 'boolean') return push; | ||||
|
||||
var keepMargin = []; | ||||
var mapping = { | ||||
archmoj marked this conversation as resolved.
Show resolved
Hide resolved
|
||||
width: ['x', 'r', 'l', 'xl', 'xr'], | ||||
height: ['y', 't', 'b', 'yt', 'yb'], | ||||
right: ['r', 'xr'], | ||||
left: ['l', 'xl'], | ||||
top: ['t', 'yt'], | ||||
bottom: ['b', 'yb'] | ||||
}; | ||||
|
||||
Object.keys(mapping).forEach(function(key) { | ||||
if(automargin.indexOf(key) !== -1) { | ||||
mapping[key].forEach(function(item) { | ||||
keepMargin.push(item); | ||||
}); | ||||
} | ||||
}); | ||||
|
||||
Object.keys(push).forEach(function(key) { | ||||
if(keepMargin.indexOf(key) === -1) { | ||||
if(key.length === 1) { | ||||
push[key] = 0; | ||||
} else { | ||||
delete push[key]; | ||||
} | ||||
} | ||||
}); | ||||
return push; | ||||
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.
Suggested change
|
||||
} | ||||
|
||||
function getBoundaryVals(ax, vals) { | ||||
var out = []; | ||||
var i; | ||||
|
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.
Could you please elaborate why this change is needed?
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.
Just reversing the order of short-circuits to support non-string extras #6193 (comment)
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.
As @alexcjohnson wrote:
Without this, the flaglist coerce function does not pass non-string values.