Skip to content

Commit 5bf1014

Browse files
committed
separate prefix & suffix defaults
1 parent 2bb40d5 commit 5bf1014

File tree

8 files changed

+34
-26
lines changed

8 files changed

+34
-26
lines changed

src/components/colorbar/defaults.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ var Template = require('../../plot_api/plot_template');
66
var handleTickValueDefaults = require('../../plots/cartesian/tick_value_defaults');
77
var handleTickMarkDefaults = require('../../plots/cartesian/tick_mark_defaults');
88
var handleTickLabelDefaults = require('../../plots/cartesian/tick_label_defaults');
9+
var handlePrefixSuffixDefaults = require('../../plots/cartesian/prefix_suffix_defaults');
910

1011
var attributes = require('./attributes');
1112

@@ -53,6 +54,7 @@ module.exports = function colorbarDefaults(containerIn, containerOut, layout) {
5354
if(ticklabelposition.indexOf('inside') !== -1) {
5455
opts.bgColor = 'black'; // could we instead use the average of colors in the scale?
5556
}
57+
handlePrefixSuffixDefaults(colorbarIn, colorbarOut, coerce, 'linear', opts);
5658
handleTickLabelDefaults(colorbarIn, colorbarOut, coerce, 'linear', opts);
5759
handleTickMarkDefaults(colorbarIn, colorbarOut, coerce, 'linear', opts);
5860

src/plots/cartesian/axis_defaults.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ var layoutAttributes = require('./layout_attributes');
1111
var handleTickValueDefaults = require('./tick_value_defaults');
1212
var handleTickMarkDefaults = require('./tick_mark_defaults');
1313
var handleTickLabelDefaults = require('./tick_label_defaults');
14+
var handlePrefixSuffixDefaults = require('./prefix_suffix_defaults');
1415
var handleCategoryOrderDefaults = require('./category_order_defaults');
1516
var handleLineGridDefaults = require('./line_grid_defaults');
1617
var setConvert = require('./set_convert');
@@ -110,7 +111,7 @@ module.exports = function handleAxisDefaults(containerIn, containerOut, coerce,
110111
// try to get default title from splom trace, fallback to graph-wide value
111112
var dfltTitle = splomStash.label || layoutOut._dfltTitle[letter];
112113

113-
handleTickLabelDefaults(containerIn, containerOut, coerce, axType, options, {pass: 1});
114+
handlePrefixSuffixDefaults(containerIn, containerOut, coerce, axType, options);
114115
if(!visible) return containerOut;
115116

116117
coerce('title.text', dfltTitle);
@@ -121,7 +122,7 @@ module.exports = function handleAxisDefaults(containerIn, containerOut, coerce,
121122
});
122123

123124
handleTickValueDefaults(containerIn, containerOut, coerce, axType);
124-
handleTickLabelDefaults(containerIn, containerOut, coerce, axType, options, {pass: 2});
125+
handleTickLabelDefaults(containerIn, containerOut, coerce, axType, options);
125126
handleTickMarkDefaults(containerIn, containerOut, coerce, options);
126127
handleLineGridDefaults(containerIn, containerOut, coerce, {
127128
dfltColor: dfltColor,
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
'use strict';
2+
3+
var getShowAttrDflt = require('./show_dflt');
4+
5+
module.exports = function handlePrefixSuffixDefaults(containerIn, containerOut, coerce, axType, options) {
6+
if(!options) options = {};
7+
var tickSuffixDflt = options.tickSuffixDflt;
8+
9+
var showAttrDflt = getShowAttrDflt(containerIn);
10+
11+
var tickPrefix = coerce('tickprefix');
12+
if(tickPrefix) coerce('showtickprefix', showAttrDflt);
13+
14+
var tickSuffix = coerce('ticksuffix', tickSuffixDflt);
15+
if(tickSuffix) coerce('showticksuffix', showAttrDflt);
16+
};

src/plots/cartesian/tick_label_defaults.js

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,8 @@ var layoutAttributes = require('./layout_attributes');
66
var getShowAttrDflt = require('./show_dflt');
77
var handleArrayContainerDefaults = require('../array_container_defaults');
88

9-
module.exports = function handleTickLabelDefaults(containerIn, containerOut, coerce, axType, options, config) {
10-
if(!config || config.pass === 1) {
11-
handlePrefixSuffix(containerIn, containerOut, coerce, axType, options);
12-
}
13-
14-
if(!config || config.pass === 2) {
15-
handleOtherDefaults(containerIn, containerOut, coerce, axType, options);
16-
}
17-
};
18-
19-
function handlePrefixSuffix(containerIn, containerOut, coerce, axType, options) {
20-
var showAttrDflt = getShowAttrDflt(containerIn);
21-
22-
var tickPrefix = coerce('tickprefix');
23-
if(tickPrefix) coerce('showtickprefix', showAttrDflt);
24-
25-
var tickSuffix = coerce('ticksuffix', options.tickSuffixDflt);
26-
if(tickSuffix) coerce('showticksuffix', showAttrDflt);
27-
}
28-
29-
function handleOtherDefaults(containerIn, containerOut, coerce, axType, options) {
9+
module.exports = function handleTickLabelDefaults(containerIn, containerOut, coerce, axType, options) {
10+
if(!options) options = {};
3011
var showAttrDflt = getShowAttrDflt(containerIn);
3112

3213
var showTickLabels = coerce('showticklabels');
@@ -68,7 +49,7 @@ function handleOtherDefaults(containerIn, containerOut, coerce, axType, options)
6849
}
6950
}
7051
}
71-
}
52+
};
7253

7354
function tickformatstopDefaults(valueIn, valueOut) {
7455
function coerce(attr, dflt) {

src/plots/polar/layout_defaults.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ var getSubplotData = require('../get_data').getSubplotData;
1010
var handleTickValueDefaults = require('../cartesian/tick_value_defaults');
1111
var handleTickMarkDefaults = require('../cartesian/tick_mark_defaults');
1212
var handleTickLabelDefaults = require('../cartesian/tick_label_defaults');
13+
var handlePrefixSuffixDefaults = require('../cartesian/prefix_suffix_defaults');
1314
var handleCategoryOrderDefaults = require('../cartesian/category_order_defaults');
1415
var handleLineGridDefaults = require('../cartesian/line_grid_defaults');
1516
var autoType = require('../cartesian/axis_autotype');
@@ -138,9 +139,10 @@ function handleDefaults(contIn, contOut, coerce, opts) {
138139

139140
if(visible) {
140141
handleTickValueDefaults(axIn, axOut, coerceAxis, axOut.type);
141-
handleTickLabelDefaults(axIn, axOut, coerceAxis, axOut.type, {
142+
handlePrefixSuffixDefaults(axIn, axOut, coerceAxis, axOut.type, {
142143
tickSuffixDflt: axOut.thetaunit === 'degrees' ? '°' : undefined
143144
});
145+
handleTickLabelDefaults(axIn, axOut, coerceAxis, axOut.type);
144146
handleTickMarkDefaults(axIn, axOut, coerceAxis, {outerTicks: true});
145147

146148
var showTickLabels = coerceAxis('showticklabels');

src/plots/ternary/layout_defaults.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ var Lib = require('../../lib');
66

77
var handleSubplotDefaults = require('../subplot_defaults');
88
var handleTickLabelDefaults = require('../cartesian/tick_label_defaults');
9+
var handlePrefixSuffixDefaults = require('../cartesian/prefix_suffix_defaults');
910
var handleTickMarkDefaults = require('../cartesian/tick_mark_defaults');
1011
var handleTickValueDefaults = require('../cartesian/tick_value_defaults');
1112
var handleLineGridDefaults = require('../cartesian/line_grid_defaults');
@@ -90,7 +91,8 @@ function handleAxisDefaults(containerIn, containerOut, options, ternaryLayoutOut
9091
coerce('min');
9192

9293
handleTickValueDefaults(containerIn, containerOut, coerce, 'linear');
93-
handleTickLabelDefaults(containerIn, containerOut, coerce, 'linear', {});
94+
handlePrefixSuffixDefaults(containerIn, containerOut, coerce, 'linear');
95+
handleTickLabelDefaults(containerIn, containerOut, coerce, 'linear');
9496
handleTickMarkDefaults(containerIn, containerOut, coerce,
9597
{ outerTicks: true });
9698

src/traces/carpet/axis_defaults.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ var Registry = require('../../registry');
77
var Lib = require('../../lib');
88
var handleTickValueDefaults = require('../../plots/cartesian/tick_value_defaults');
99
var handleTickLabelDefaults = require('../../plots/cartesian/tick_label_defaults');
10+
var handlePrefixSuffixDefaults = require('../../plots/cartesian/prefix_suffix_defaults');
1011
var handleCategoryOrderDefaults = require('../../plots/cartesian/category_order_defaults');
1112
var setConvert = require('../../plots/cartesian/set_convert');
1213
var autoType = require('../../plots/cartesian/axis_autotype');
@@ -128,6 +129,7 @@ module.exports = function handleAxisDefaults(containerIn, containerOut, options)
128129
coerce('fixedrange');
129130

130131
handleTickValueDefaults(containerIn, containerOut, coerce, axType);
132+
handlePrefixSuffixDefaults(containerIn, containerOut, coerce, axType, options);
131133
handleTickLabelDefaults(containerIn, containerOut, coerce, axType, options);
132134
handleCategoryOrderDefaults(containerIn, containerOut, coerce, {
133135
data: options.data,

src/traces/indicator/defaults.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ var cn = require('./constants.js');
1010
var handleTickValueDefaults = require('../../plots/cartesian/tick_value_defaults');
1111
var handleTickMarkDefaults = require('../../plots/cartesian/tick_mark_defaults');
1212
var handleTickLabelDefaults = require('../../plots/cartesian/tick_label_defaults');
13+
var handlePrefixSuffixDefaults = require('../../plots/cartesian/prefix_suffix_defaults');
1314

1415
function supplyDefaults(traceIn, traceOut, defaultColor, layout) {
1516
function coerce(attr, dflt) {
@@ -128,6 +129,7 @@ function supplyDefaults(traceIn, traceOut, defaultColor, layout) {
128129

129130
var opts = {outerTicks: true};
130131
handleTickValueDefaults(axisIn, axisOut, coerceGaugeAxis, 'linear');
132+
handlePrefixSuffixDefaults(axisIn, axisOut, coerceGaugeAxis, 'linear', opts);
131133
handleTickLabelDefaults(axisIn, axisOut, coerceGaugeAxis, 'linear', opts);
132134
handleTickMarkDefaults(axisIn, axisOut, coerceGaugeAxis, opts);
133135
} else {

0 commit comments

Comments
 (0)