|
3 | 3 | var Lib = require('../../lib'); |
4 | 4 | var contrast = require('../../components/color').contrast; |
5 | 5 | var layoutAttributes = require('./layout_attributes'); |
| 6 | +var getShowAttrDflt = require('./show_dflt'); |
6 | 7 | var handleArrayContainerDefaults = require('../array_container_defaults'); |
7 | 8 |
|
8 | | -module.exports = function handleTickLabelDefaults(containerIn, containerOut, coerce, axType, options, config) { |
9 | | - if(!config || config.pass === 1) { |
10 | | - handlePrefixSuffix(containerIn, containerOut, coerce, axType, options); |
11 | | - } |
12 | | - |
13 | | - if(!config || config.pass === 2) { |
14 | | - handleOtherDefaults(containerIn, containerOut, coerce, axType, options); |
15 | | - } |
16 | | -}; |
17 | | - |
18 | | -function handlePrefixSuffix(containerIn, containerOut, coerce, axType, options) { |
19 | | - var showAttrDflt = getShowAttrDflt(containerIn); |
20 | | - |
21 | | - var tickPrefix = coerce('tickprefix'); |
22 | | - if(tickPrefix) coerce('showtickprefix', showAttrDflt); |
23 | | - |
24 | | - var tickSuffix = coerce('ticksuffix', options.tickSuffixDflt); |
25 | | - if(tickSuffix) coerce('showticksuffix', showAttrDflt); |
26 | | -} |
27 | | - |
28 | | -function handleOtherDefaults(containerIn, containerOut, coerce, axType, options) { |
| 9 | +module.exports = function handleTickLabelDefaults(containerIn, containerOut, coerce, axType, options) { |
| 10 | + if(!options) options = {}; |
29 | 11 | var showAttrDflt = getShowAttrDflt(containerIn); |
30 | 12 |
|
31 | 13 | var showTickLabels = coerce('showticklabels'); |
@@ -67,35 +49,7 @@ function handleOtherDefaults(containerIn, containerOut, coerce, axType, options) |
67 | 49 | } |
68 | 50 | } |
69 | 51 | } |
70 | | -} |
71 | | - |
72 | | -/* |
73 | | - * Attributes 'showexponent', 'showtickprefix' and 'showticksuffix' |
74 | | - * share values. |
75 | | - * |
76 | | - * If only 1 attribute is set, |
77 | | - * the remaining attributes inherit that value. |
78 | | - * |
79 | | - * If 2 attributes are set to the same value, |
80 | | - * the remaining attribute inherits that value. |
81 | | - * |
82 | | - * If 2 attributes are set to different values, |
83 | | - * the remaining is set to its dflt value. |
84 | | - * |
85 | | - */ |
86 | | -function getShowAttrDflt(containerIn) { |
87 | | - var showAttrsAll = ['showexponent', 'showtickprefix', 'showticksuffix']; |
88 | | - var showAttrs = showAttrsAll.filter(function(a) { |
89 | | - return containerIn[a] !== undefined; |
90 | | - }); |
91 | | - var sameVal = function(a) { |
92 | | - return containerIn[a] === containerIn[showAttrs[0]]; |
93 | | - }; |
94 | | - |
95 | | - if(showAttrs.every(sameVal) || showAttrs.length === 1) { |
96 | | - return containerIn[showAttrs[0]]; |
97 | | - } |
98 | | -} |
| 52 | +}; |
99 | 53 |
|
100 | 54 | function tickformatstopDefaults(valueIn, valueOut) { |
101 | 55 | function coerce(attr, dflt) { |
|
0 commit comments