-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
/
Copy pathdefaults.js
51 lines (41 loc) · 1.43 KB
/
defaults.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
/**
* Copyright 2012-2016, 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 Lib = require('../../lib');
var attributes = require('./attributes');
module.exports = function handleDefaults(layoutIn, layoutOut, axName, counterAxes) {
if(!layoutIn[axName].rangeslider) return;
var containerIn = Lib.isPlainObject(layoutIn[axName].rangeslider) ?
layoutIn[axName].rangeslider : {},
containerOut = layoutOut[axName].rangeslider = {};
function coerce(attr, dflt) {
return Lib.coerce(containerIn, containerOut, attributes, attr, dflt);
}
coerce('bgcolor');
coerce('bordercolor');
coerce('borderwidth');
coerce('thickness');
coerce('visible');
coerce('range');
// Expand slider range to the axis range
if(containerOut.range && !layoutOut[axName].autorange) {
var outRange = containerOut.range,
axRange = layoutOut[axName].range;
outRange[0] = Math.min(outRange[0], axRange[0]);
outRange[1] = Math.max(outRange[1], axRange[1]);
} else {
layoutOut[axName]._needsExpand = true;
}
if(containerOut.visible) {
counterAxes.forEach(function(ax) {
var opposing = layoutOut[ax] || {};
opposing.fixedrange = true;
layoutOut[ax] = opposing;
});
}
};