-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
/
Copy pathhelpers.js
56 lines (47 loc) · 1.5 KB
/
helpers.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/**
* Copyright 2012-2019, 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 axisIDs = require('../../plots/cartesian/axis_ids');
var constants = require('./constants');
var name = constants.name;
function isVisible(ax) {
var rangeSlider = ax && ax[name];
return rangeSlider && rangeSlider.visible;
}
exports.isVisible = isVisible;
exports.makeData = function(fullLayout) {
var axes = axisIDs.list({ _fullLayout: fullLayout }, 'x', true);
var margin = fullLayout.margin;
var rangeSliderData = [];
if(!fullLayout._has('gl2d')) {
for(var i = 0; i < axes.length; i++) {
var ax = axes[i];
if(isVisible(ax)) {
rangeSliderData.push(ax);
var opts = ax[name];
opts._id = name + ax._id;
opts._height = (fullLayout.height - margin.b - margin.t) * opts.thickness;
opts._offsetShift = Math.floor(opts.borderwidth / 2);
}
}
}
fullLayout._rangeSliderData = rangeSliderData;
};
exports.autoMarginOpts = function(gd, ax) {
var opts = ax[name];
var bottomDepth = ax.side === 'bottom' ? ax._depth : 0;
return {
x: 0,
y: ax._counterDomainMin,
l: 0,
r: 0,
t: 0,
b: opts._height + gd._fullLayout.margin.b + bottomDepth,
pad: constants.extraPad + opts._offsetShift * 2
};
};