forked from plotly/plotly.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdefaults.js
44 lines (34 loc) · 1.2 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
/**
* 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 Lib = require('../../lib');
var attributes = require('./attributes');
module.exports = function handleDefaults(layoutIn, layoutOut, axName) {
if(!layoutIn[axName].rangeslider) return;
// not super proud of this (maybe store _ in axis object instead
if(!Lib.isPlainObject(layoutIn[axName].rangeslider)) {
layoutIn[axName].rangeslider = {};
}
var containerIn = layoutIn[axName].rangeslider,
axOut = layoutOut[axName],
containerOut = axOut.rangeslider = {};
function coerce(attr, dflt) {
return Lib.coerce(containerIn, containerOut, attributes, attr, dflt);
}
var visible = coerce('visible');
if(!visible) return;
coerce('bgcolor', layoutOut.plot_bgcolor);
coerce('bordercolor');
coerce('borderwidth');
coerce('thickness');
coerce('autorange', !axOut.isValidRange(containerIn.range));
coerce('range');
coerce('fixedyrange');
// to map back range slider (auto) range
containerOut._input = containerIn;
};