Skip to content

Commit 8f23ef5

Browse files
committed
swap and 🔒 'calcIfAutorange' -> 'calc' for box attributes
1 parent c75cda8 commit 8f23ef5

File tree

2 files changed

+44
-8
lines changed

2 files changed

+44
-8
lines changed

src/traces/box/attributes.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ module.exports = {
7878
max: 1,
7979
dflt: 0.5,
8080
role: 'style',
81-
editType: 'calcIfAutorange',
81+
editType: 'calc',
8282
description: [
8383
'Sets the width of the whiskers relative to',
8484
'the box\' width.',
@@ -88,7 +88,7 @@ module.exports = {
8888
notched: {
8989
valType: 'boolean',
9090
role: 'style',
91-
editType: 'calcIfAutorange',
91+
editType: 'calc',
9292
description: [
9393
'Determines whether or not notches should be drawn.'
9494
].join(' ')
@@ -99,7 +99,7 @@ module.exports = {
9999
max: 0.5,
100100
dflt: 0.25,
101101
role: 'style',
102-
editType: 'calcIfAutorange',
102+
editType: 'calc',
103103
description: [
104104
'Sets the width of the notches relative to',
105105
'the box\' width.',
@@ -111,7 +111,7 @@ module.exports = {
111111
values: ['all', 'outliers', 'suspectedoutliers', false],
112112
dflt: 'outliers',
113113
role: 'style',
114-
editType: 'calcIfAutorange',
114+
editType: 'calc',
115115
description: [
116116
'If *outliers*, only the sample points lying outside the whiskers',
117117
'are shown',
@@ -127,7 +127,7 @@ module.exports = {
127127
values: [true, 'sd', false],
128128
dflt: false,
129129
role: 'style',
130-
editType: 'calcIfAutorange',
130+
editType: 'calc',
131131
description: [
132132
'If *true*, the mean of the box(es)\' underlying distribution is',
133133
'drawn as a dashed line inside the box(es).',
@@ -139,7 +139,7 @@ module.exports = {
139139
min: 0,
140140
max: 1,
141141
role: 'style',
142-
editType: 'calcIfAutorange',
142+
editType: 'calc',
143143
description: [
144144
'Sets the amount of jitter in the sample points drawn.',
145145
'If *0*, the sample points align along the distribution axis.',
@@ -152,7 +152,7 @@ module.exports = {
152152
min: -2,
153153
max: 2,
154154
role: 'style',
155-
editType: 'calcIfAutorange',
155+
editType: 'calc',
156156
description: [
157157
'Sets the position of the sample points in relation to the box(es).',
158158
'If *0*, the sample points are places over the center of the box(es).',
@@ -184,7 +184,7 @@ module.exports = {
184184
opacity: extendFlat({}, scatterMarkerAttrs.opacity,
185185
{arrayOk: false, dflt: 1, editType: 'style'}),
186186
size: extendFlat({}, scatterMarkerAttrs.size,
187-
{arrayOk: false, editType: 'calcIfAutorange'}),
187+
{arrayOk: false, editType: 'calc'}),
188188
color: extendFlat({}, scatterMarkerAttrs.color,
189189
{arrayOk: false, editType: 'style'}),
190190
line: {

test/jasmine/tests/box_test.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,4 +399,40 @@ describe('Test box restyle:', function() {
399399
.catch(failTest)
400400
.then(done);
401401
});
402+
403+
it('should update axis range accordingly on calc edits', function(done) {
404+
function _assert(msg, xrng, yrng) {
405+
var fullLayout = gd._fullLayout;
406+
expect(fullLayout.xaxis.range).toBeCloseToArray(xrng, 2, msg + ' xrng');
407+
expect(fullLayout.yaxis.range).toBeCloseToArray(yrng, 2, msg + ' yrng');
408+
}
409+
410+
Plotly.plot(gd, [{
411+
type: 'box',
412+
y: [0, 1, 1, 1, 1, 2, 2, 3, 5, 6, 10]
413+
}], {
414+
xaxis: {range: [-0.5, 0.5]},
415+
yaxis: {range: [-0.5, 10.5]}
416+
})
417+
.then(function() {
418+
_assert('auto rng / no boxpoints', [-0.5, 0.5], [-0.5, 10.5]);
419+
return Plotly.restyle(gd, 'boxpoints', 'all');
420+
})
421+
.then(function() {
422+
_assert('set rng / all boxpoints', [-0.5, 0.5], [-0.5, 10.5]);
423+
return Plotly.relayout(gd, {
424+
'xaxis.autorange': true,
425+
'yaxis.autorange': true
426+
});
427+
})
428+
.then(function() {
429+
_assert('auto rng / all boxpoints', [-0.695, 0.5], [-0.555, 10.555]);
430+
return Plotly.restyle(gd, 'boxpoints', false);
431+
})
432+
.then(function() {
433+
_assert('auto rng / no boxpoints', [-0.5, 0.5], [-0.555, 10.555]);
434+
})
435+
.catch(failTest)
436+
.then(done);
437+
});
402438
});

0 commit comments

Comments
 (0)