-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
/
Copy pathdefaults.js
63 lines (49 loc) · 1.87 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
52
53
54
55
56
57
58
59
60
61
62
63
/**
* 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 handleTickValueDefaults = require('../../plots/cartesian/tick_value_defaults');
var handleTickMarkDefaults = require('../../plots/cartesian/tick_mark_defaults');
var handleTickLabelDefaults = require('../../plots/cartesian/tick_label_defaults');
var attributes = require('./attributes');
module.exports = function colorbarDefaults(containerIn, containerOut, layout) {
var colorbarOut = containerOut.colorbar = {},
colorbarIn = containerIn.colorbar || {};
function coerce(attr, dflt) {
return Lib.coerce(colorbarIn, colorbarOut, attributes, attr, dflt);
}
var thicknessmode = coerce('thicknessmode');
coerce('thickness', (thicknessmode === 'fraction') ?
30 / (layout.width - layout.margin.l - layout.margin.r) :
30
);
var lenmode = coerce('lenmode');
coerce('len', (lenmode === 'fraction') ?
1 :
layout.height - layout.margin.t - layout.margin.b
);
coerce('x');
coerce('xanchor');
coerce('xpad');
coerce('y');
coerce('yanchor');
coerce('ypad');
Lib.noneOrAll(colorbarIn, colorbarOut, ['x', 'y']);
coerce('outlinecolor');
coerce('outlinewidth');
coerce('bordercolor');
coerce('borderwidth');
coerce('bgcolor');
handleTickValueDefaults(colorbarIn, colorbarOut, coerce, 'linear');
var opts = {outerTicks: false, font: layout.font};
handleTickLabelDefaults(colorbarIn, colorbarOut, coerce, 'linear', opts);
handleTickMarkDefaults(colorbarIn, colorbarOut, coerce, 'linear', opts);
coerce('title', layout._dfltTitle.colorbar);
Lib.coerceFont(coerce, 'titlefont', layout.font);
coerce('titleside');
};