Skip to content

Commit a01361c

Browse files
committed
Coerce min/max or x and y depending on xref and yref
1 parent fa5e448 commit a01361c

File tree

2 files changed

+24
-6
lines changed

2 files changed

+24
-6
lines changed

src/components/legend/attributes.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -159,16 +159,15 @@ module.exports = {
159159
},
160160
x: {
161161
valType: 'number',
162-
min: -2,
163-
max: 3,
164162
editType: 'legend',
165163
description: [
166164
'Sets the x position with respect to `xref` (in normalized coordinates) of the legend.',
167165
'When `xref` is *paper*, defaults to *1.02* for vertical legends and',
168166
'defaults to *0* for horizontal legends.',
169167
'When `xref` is *container*, defaults to *1* for vertical legends and',
170168
'defaults to *0* for horizontal legends.',
171-
'Must be between *0* and *1* if `xref` is *container*.'
169+
'Must be between *0* and *1* if `xref` is *container*.',
170+
'and between *-2* and *3* if `xref` is *paper*.'
172171
].join(' ')
173172
},
174173
xref: {
@@ -198,16 +197,15 @@ module.exports = {
198197
},
199198
y: {
200199
valType: 'number',
201-
min: -2,
202-
max: 3,
203200
editType: 'legend',
204201
description: [
205202
'Sets the y position with respect to `yref` (in normalized coordinates) of the legend.',
206203
'When `yref` is *paper*, defaults to *1* for vertical legends,',
207204
'defaults to *-0.1* for horizontal legends on graphs w/o range sliders and',
208205
'defaults to *1.1* for horizontal legends on graph with one or multiple range sliders.',
209206
'When `yref` is *container*, defaults to *1*.',
210-
'Must be between *0* and *1* if `yref` is *container*.'
207+
'Must be between *0* and *1* if `yref` is *container*',
208+
'and between *-2* and *3* if `yref` is *paper*.'
211209
].join(' ')
212210
},
213211
yref: {

src/components/legend/defaults.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,26 @@ function groupDefaults(legendId, layoutIn, layoutOut, fullData) {
147147
}
148148
}
149149

150+
Lib.coerce(containerIn, containerOut, {
151+
x: {
152+
valType: 'number',
153+
editType: 'legend',
154+
min: isPaperX ? -2 : 0,
155+
max: isPaperX ? 3 : 1,
156+
dflt: defaultX,
157+
}
158+
}, 'x');
159+
160+
Lib.coerce(containerIn, containerOut, {
161+
y: {
162+
valType: 'number',
163+
editType: 'legend',
164+
min: isPaperY ? -2 : 0,
165+
max: isPaperY ? 3 : 1,
166+
dflt: defaultY,
167+
}
168+
}, 'y');
169+
150170
coerce('traceorder', defaultOrder);
151171
if(helpers.isGrouped(layoutOut.legend)) coerce('tracegroupgap');
152172

0 commit comments

Comments
 (0)