-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
/
Copy pathaxis_defaults.js
73 lines (56 loc) · 2.22 KB
/
axis_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
64
65
66
67
68
69
70
71
72
73
/**
* 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 colorMix = require('tinycolor2').mix;
var Lib = require('../../../lib');
var Template = require('../../../plot_api/plot_template');
var layoutAttributes = require('./axis_attributes');
var handleTypeDefaults = require('../../cartesian/type_defaults');
var handleAxisDefaults = require('../../cartesian/axis_defaults');
var axesNames = ['xaxis', 'yaxis', 'zaxis'];
// TODO: hard-coded lightness fraction based on gridline default colors
// that differ from other subplot types.
var gridLightness = 100 * (204 - 0x44) / (255 - 0x44);
module.exports = function supplyLayoutDefaults(layoutIn, layoutOut, options) {
var containerIn, containerOut;
function coerce(attr, dflt) {
return Lib.coerce(containerIn, containerOut, layoutAttributes, attr, dflt);
}
for(var j = 0; j < axesNames.length; j++) {
var axName = axesNames[j];
containerIn = layoutIn[axName] || {};
containerOut = Template.newContainer(layoutOut, axName);
containerOut._id = axName[0] + options.scene;
containerOut._name = axName;
handleTypeDefaults(containerIn, containerOut, coerce, options);
handleAxisDefaults(
containerIn,
containerOut,
coerce,
{
font: options.font,
letter: axName[0],
data: options.data,
showGrid: true,
noTickson: true,
bgColor: options.bgColor,
calendar: options.calendar
},
options.fullLayout);
coerce('gridcolor', colorMix(containerOut.color, options.bgColor, gridLightness).toRgbString());
coerce('title', axName[0]); // shouldn't this be on-par with 2D?
containerOut.setScale = Lib.noop;
if(coerce('showspikes')) {
coerce('spikesides');
coerce('spikethickness');
coerce('spikecolor', containerOut.color);
}
coerce('showaxeslabels');
if(coerce('showbackground')) coerce('backgroundcolor');
}
};