Skip to content

Commit b1911b3

Browse files
committed
run Axes.expand on autorange: false axes
- this way `relayout(gd, 'ax.autorange', true)` does not have to go through costly editType "calc" - this makes the 'calcIfAutorange' edit type obsolete, which the following few commits will cope with
1 parent bd61c54 commit b1911b3

File tree

4 files changed

+10
-22
lines changed

4 files changed

+10
-22
lines changed

src/plots/cartesian/autorange.js

-6
Original file line numberDiff line numberDiff line change
@@ -210,10 +210,6 @@ function doAutoRange(ax) {
210210
}
211211
}
212212

213-
function needsAutorange(ax) {
214-
return ax.autorange || ax._rangesliderAutorange;
215-
}
216-
217213
/*
218214
* expand: if autoranging, include new data in the outer limits for this axis.
219215
* Note that `expand` is called during `calc`, when we don't yet know the axis
@@ -236,8 +232,6 @@ function needsAutorange(ax) {
236232
* and make it a tight bound if possible
237233
*/
238234
function expand(ax, data, options) {
239-
if(!needsAutorange(ax) || !data) return;
240-
241235
if(!ax._min) ax._min = [];
242236
if(!ax._max) ax._max = [];
243237
if(!options) options = {};

src/plots/cartesian/layout_attributes.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ module.exports = {
7878
values: [true, false, 'reversed'],
7979
dflt: true,
8080
role: 'info',
81-
editType: 'calc',
81+
editType: 'plot',
8282
impliedEdits: {'range[0]': undefined, 'range[1]': undefined},
8383
description: [
8484
'Determines whether or not the range of this axis is',

test/jasmine/tests/axes_test.js

+5-8
Original file line numberDiff line numberDiff line change
@@ -1858,24 +1858,21 @@ describe('Test axes', function() {
18581858
expect(ax._max).toEqual([{val: 6, pad: 10, extrapad: true}]);
18591859
});
18601860

1861-
it('should return early if no data is given', function() {
1861+
it('should fail if no data is given', function() {
18621862
ax = getDefaultAx();
1863-
1864-
expand(ax);
1865-
expect(ax._min).toBeUndefined();
1866-
expect(ax._max).toBeUndefined();
1863+
expect(function() { expand(ax); }).toThrow();
18671864
});
18681865

1869-
it('should return early if `autorange` is falsy', function() {
1866+
it('should return even if `autorange` is false', function() {
18701867
ax = getDefaultAx();
18711868
data = [2, 5];
18721869

18731870
ax.autorange = false;
18741871
ax.rangeslider = { autorange: false };
18751872

18761873
expand(ax, data, {});
1877-
expect(ax._min).toBeUndefined();
1878-
expect(ax._max).toBeUndefined();
1874+
expect(ax._min).toEqual([{val: 2, pad: 0, extrapad: false}]);
1875+
expect(ax._max).toEqual([{val: 5, pad: 0, extrapad: false}]);
18791876
});
18801877

18811878
it('should consider range slider `autorange`', function() {

test/jasmine/tests/gl2d_pointcloud_test.js

+4-7
Original file line numberDiff line numberDiff line change
@@ -181,21 +181,18 @@ describe('@gl pointcloud traces', function() {
181181

182182
return Plotly.relayout(gd, 'xaxis.range', [3, 6]);
183183
}).then(function() {
184-
185-
expect(scene2d.xaxis._min).toEqual([]);
186-
expect(scene2d.xaxis._max).toEqual([]);
184+
expect(scene2d.xaxis._min).toEqual(xBaselineMins);
185+
expect(scene2d.xaxis._max).toEqual(xBaselineMaxes);
187186

188187
return Plotly.relayout(gd, 'xaxis.autorange', true);
189188
}).then(function() {
190-
191189
expect(scene2d.xaxis._min).toEqual(xBaselineMins);
192190
expect(scene2d.xaxis._max).toEqual(xBaselineMaxes);
193191

194192
return Plotly.relayout(gd, 'yaxis.range', [8, 20]);
195193
}).then(function() {
196-
197-
expect(scene2d.yaxis._min).toEqual([]);
198-
expect(scene2d.yaxis._max).toEqual([]);
194+
expect(scene2d.yaxis._min).toEqual(yBaselineMins);
195+
expect(scene2d.yaxis._max).toEqual(yBaselineMaxes);
199196

200197
return Plotly.relayout(gd, 'yaxis.autorange', true);
201198
}).then(function() {

0 commit comments

Comments
 (0)