-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
/
Copy pathcalc_autorange.js
35 lines (28 loc) · 1.09 KB
/
calc_autorange.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/**
* Copyright 2012-2018, Plotly, Inc.
* All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
'use strict';
var listAxes = require('../../plots/cartesian/axis_ids').list;
var getAutoRange = require('../../plots/cartesian/autorange').getAutoRange;
var constants = require('./constants');
module.exports = function calcAutorange(gd) {
var axes = listAxes(gd, 'x', true);
// Compute new slider range using axis autorange if necessary.
//
// Copy back range to input range slider container to skip
// this step in subsequent draw calls.
for(var i = 0; i < axes.length; i++) {
var ax = axes[i],
opts = ax[constants.name];
// Don't try calling getAutoRange if _min and _max are filled in.
// This happens on updates where the calc step is skipped.
if(opts && opts.visible && opts.autorange && ax._min.length && ax._max.length) {
opts._input.autorange = true;
opts._input.range = opts.range = getAutoRange(ax);
}
}
};