Skip to content

Commit

Permalink
Redeclare valType of title.y to be a 'number' [882]
Browse files Browse the repository at this point in the history
- Swichting the valType to 'number' spares the custom coerce function.
- In addition fixes the missing min and max bounds for y.
  • Loading branch information
rmoestl committed Nov 26, 2018
1 parent 86a88e2 commit 5fb7b8f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 15 deletions.
4 changes: 3 additions & 1 deletion src/plots/layout_attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,9 @@ module.exports = {
].join(' ')
},
y: {
valType: 'any',
valType: 'number',
min: 0,
max: 1,
dflt: 'auto',
role: 'style',
editType: 'layoutstyle',
Expand Down
15 changes: 1 addition & 14 deletions src/plots/plots.js
Original file line number Diff line number Diff line change
Expand Up @@ -1315,19 +1315,6 @@ plots.supplyLayoutGlobalDefaults = function(layoutIn, layoutOut, formatObj) {
return Lib.coerce(layoutIn, layoutOut, plots.layoutAttributes, attr, dflt);
}

// Special treatment for title.y that can be 'auto'
// or a number between 0 and 1.
function coerceTitleY() {
if(layoutIn.title && isNumeric(layoutIn.title.y)) {
var propOut = Lib.nestedProperty(layoutOut, 'title.y');
var opts = Lib.nestedProperty(plots.layoutAttributes, 'title.y').get();

Lib.valObjectMeta.number.coerceFunction(layoutIn.title.y, propOut, 'auto', opts);
} else {
coerce('title.y');
}
}

var template = layoutIn.template;
if(Lib.isPlainObject(template)) {
layoutOut.template = template;
Expand All @@ -1348,7 +1335,7 @@ plots.supplyLayoutGlobalDefaults = function(layoutIn, layoutOut, formatObj) {
coerce('title.xref');
coerce('title.yref');
coerce('title.x');
coerceTitleY();
coerce('title.y');
coerce('title.xanchor');
coerce('title.yanchor');
coerce('title.pad.t');
Expand Down

0 comments on commit 5fb7b8f

Please sign in to comment.