forked from plotly/plotly.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathab_defaults.js
58 lines (47 loc) · 1.63 KB
/
ab_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
'use strict';
var handleAxisDefaults = require('./axis_defaults');
var Template = require('../../plot_api/plot_template');
module.exports = function handleABDefaults(traceIn, traceOut, fullLayout, coerce, dfltColor) {
var a = coerce('a');
if(!a) {
coerce('da');
coerce('a0');
}
var b = coerce('b');
if(!b) {
coerce('db');
coerce('b0');
}
mimickAxisDefaults(traceIn, traceOut, fullLayout, dfltColor);
};
function mimickAxisDefaults(traceIn, traceOut, fullLayout, dfltColor) {
var axesList = ['aaxis', 'baxis'];
axesList.forEach(function(axName) {
var axLetter = axName.charAt(0);
var axIn = traceIn[axName] || {};
var axOut = Template.newContainer(traceOut, axName);
var defaultOptions = {
noAutotickangles: true,
noTicklabelrunoffstandoff: true,
noTicklabelstep: true,
tickfont: 'x',
id: axLetter + 'axis',
letter: axLetter,
font: traceOut.font,
name: axName,
data: traceIn[axLetter],
calendar: traceOut.calendar,
dfltColor: dfltColor,
bgColor: fullLayout.paper_bgcolor,
autotypenumbersDflt: fullLayout.autotypenumbers,
fullLayout: fullLayout
};
handleAxisDefaults(axIn, axOut, defaultOptions);
axOut._categories = axOut._categories || [];
// so we don't have to repeat autotype unnecessarily,
// copy an autotype back to traceIn
if(!traceIn[axName] && axIn.type !== '-') {
traceIn[axName] = {type: axIn.type};
}
});
}