-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
/
Copy pathtick_label_defaults.js
80 lines (67 loc) · 2.6 KB
/
tick_label_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
74
75
76
77
78
79
80
'use strict';
var Lib = require('../../lib');
var contrast = require('../../components/color').contrast;
var layoutAttributes = require('./layout_attributes');
var getShowAttrDflt = require('./show_dflt');
var handleArrayContainerDefaults = require('../array_container_defaults');
module.exports = function handleTickLabelDefaults(containerIn, containerOut, coerce, axType, options) {
if(!options) options = {};
var labelalias = coerce('labelalias');
if(!Lib.isPlainObject(labelalias)) delete containerOut.labelalias;
var showAttrDflt = getShowAttrDflt(containerIn);
var showTickLabels = coerce('showticklabels');
if(showTickLabels) {
var font = options.font || {};
var contColor = containerOut.color;
var position = containerOut.ticklabelposition || '';
var dfltFontColor = position.indexOf('inside') !== -1 ?
contrast(options.bgColor) :
// as with titlefont.color, inherit axis.color only if one was
// explicitly provided
(contColor && contColor !== layoutAttributes.color.dflt) ?
contColor : font.color;
Lib.coerceFont(coerce, 'tickfont', font, { overrideDflt: {
color: dfltFontColor
}});
if(
!options.noTicklabelstep &&
axType !== 'multicategory' &&
axType !== 'log'
) {
coerce('ticklabelstep');
}
if(!options.noAng) {
var tickAngle = coerce('tickangle');
if(!options.noAutotickangles && tickAngle === 'auto') {
coerce('autotickangles');
}
}
if(axType !== 'category') {
var tickFormat = coerce('tickformat');
handleArrayContainerDefaults(containerIn, containerOut, {
name: 'tickformatstops',
inclusionAttr: 'enabled',
handleItemDefaults: tickformatstopDefaults
});
if(!containerOut.tickformatstops.length) {
delete containerOut.tickformatstops;
}
if(!options.noExp && !tickFormat && axType !== 'date') {
coerce('showexponent', showAttrDflt);
coerce('exponentformat');
coerce('minexponent');
coerce('separatethousands');
}
}
}
};
function tickformatstopDefaults(valueIn, valueOut) {
function coerce(attr, dflt) {
return Lib.coerce(valueIn, valueOut, layoutAttributes.tickformatstops, attr, dflt);
}
var enabled = coerce('enabled');
if(enabled) {
coerce('dtickrange');
coerce('value');
}
}