Skip to content

Commit 743d06c

Browse files
committed
drop unused attributes from smith
- avoid coercing twice of attributes e.g. tickangle and tickfont - refactor polar defaults - add options to handleTickLabelDefaults
1 parent ef90f13 commit 743d06c

File tree

5 files changed

+58
-122
lines changed

5 files changed

+58
-122
lines changed

src/plots/cartesian/tick_label_defaults.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ module.exports = function handleTickLabelDefaults(containerIn, containerOut, coe
2727
size: font.size,
2828
color: dfltFontColor
2929
});
30-
coerce('tickangle');
30+
31+
if(!options.noAng) coerce('tickangle');
3132

3233
if(axType !== 'category') {
3334
var tickFormat = coerce('tickformat');
@@ -41,7 +42,7 @@ module.exports = function handleTickLabelDefaults(containerIn, containerOut, coe
4142
delete containerOut.tickformatstops;
4243
}
4344

44-
if(!tickFormat && axType !== 'date') {
45+
if(!options.noExp && !tickFormat && axType !== 'date') {
4546
coerce('showexponent', showAttrDflt);
4647
coerce('exponentformat');
4748
coerce('minexponent');

src/plots/polar/layout_defaults.js

Lines changed: 31 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,6 @@ function handleDefaults(contIn, contOut, coerce, opts) {
6262

6363
coerceAxis('uirevision', contOut.uirevision);
6464

65-
var dfltColor;
66-
var dfltFontColor;
67-
68-
if(visible) {
69-
dfltColor = coerceAxis('color');
70-
dfltFontColor = (dfltColor === axIn.color) ? dfltColor : opts.font.color;
71-
}
72-
7365
// We don't want to make downstream code call ax.setScale,
7466
// as both radial and angular axes don't have a set domain.
7567
// Furthermore, angular axes don't have a set range.
@@ -91,18 +83,6 @@ function handleDefaults(contIn, contOut, coerce, opts) {
9183

9284
coerceAxis('range');
9385
axOut.cleanRange('range', {dfltRange: [0, 1]});
94-
95-
if(visible) {
96-
coerceAxis('side');
97-
coerceAxis('angle', sector[0]);
98-
99-
coerceAxis('title.text');
100-
Lib.coerceFont(coerceAxis, 'title.font', {
101-
family: opts.font.family,
102-
size: Lib.bigFont(opts.font.size),
103-
color: dfltFontColor
104-
});
105-
}
10686
break;
10787

10888
case 'angularaxis':
@@ -142,20 +122,27 @@ function handleDefaults(contIn, contOut, coerce, opts) {
142122
});
143123

144124
if(visible) {
125+
var dfltColor;
126+
var dfltFontColor;
127+
var dfltFontSize;
128+
var dfltFontFamily;
129+
var font = opts.font || {};
130+
131+
dfltColor = coerceAxis('color');
132+
dfltFontColor = (dfltColor === axIn.color) ? dfltColor : font.color;
133+
dfltFontSize = font.size;
134+
dfltFontFamily = font.family;
135+
145136
handleTickValueDefaults(axIn, axOut, coerceAxis, axOut.type);
146-
handleTickLabelDefaults(axIn, axOut, coerceAxis, axOut.type);
147-
handleTickMarkDefaults(axIn, axOut, coerceAxis, {outerTicks: true});
137+
handleTickLabelDefaults(axIn, axOut, coerceAxis, axOut.type, {
138+
font: {
139+
color: dfltFontColor,
140+
size: dfltFontSize,
141+
family: dfltFontFamily
142+
}
143+
});
148144

149-
var showTickLabels = coerceAxis('showticklabels');
150-
if(showTickLabels) {
151-
Lib.coerceFont(coerceAxis, 'tickfont', {
152-
family: opts.font.family,
153-
size: opts.font.size,
154-
color: dfltFontColor
155-
});
156-
coerceAxis('tickangle');
157-
coerceAxis('tickformat');
158-
}
145+
handleTickMarkDefaults(axIn, axOut, coerceAxis, {outerTicks: true});
159146

160147
handleLineGridDefaults(axIn, axOut, coerceAxis, {
161148
dfltColor: dfltColor,
@@ -170,6 +157,18 @@ function handleDefaults(contIn, contOut, coerce, opts) {
170157
});
171158

172159
coerceAxis('layer');
160+
161+
if(axName === 'radialaxis') {
162+
coerceAxis('side');
163+
coerceAxis('angle', sector[0]);
164+
165+
coerceAxis('title.text');
166+
Lib.coerceFont(coerceAxis, 'title.font', {
167+
color: dfltFontColor,
168+
size: Lib.bigFont(dfltFontSize),
169+
family: dfltFontFamily
170+
});
171+
}
173172
}
174173

175174
if(axType !== 'category') coerceAxis('hoverformat');

src/plots/smith/layout_attributes.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,6 @@ var axisTickAttrs = overrideAll({
2626
showticksuffix: axesAttrs.showticksuffix,
2727
ticksuffix: axesAttrs.ticksuffix,
2828
showexponent: axesAttrs.showexponent,
29-
exponentformat: axesAttrs.exponentformat,
30-
minexponent: axesAttrs.minexponent,
31-
separatethousands: axesAttrs.separatethousands,
3229
tickfont: axesAttrs.tickfont,
3330
tickformat: axesAttrs.tickformat,
3431
hoverformat: axesAttrs.hoverformat,
@@ -97,8 +94,6 @@ var imaginaryAxisAttrs = {
9794
description: 'Sets the values at which ticks on this axis appear.'
9895
},
9996

100-
tickangle: axesAttrs.tickangle,
101-
10297
ticks: axesAttrs.ticks,
10398

10499
editType: 'calc'

src/plots/smith/layout_defaults.js

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,6 @@ function handleDefaults(contIn, contOut, coerce, opts) {
4747
axOut.type = 'linear';
4848
setConvert(axOut, contOut, layoutOut);
4949

50-
var dfltColor;
51-
var dfltFontColor;
52-
53-
if(visible) {
54-
dfltColor = coerceAxis('color');
55-
dfltFontColor = (dfltColor === axIn.color) ? dfltColor : opts.font.color;
56-
}
57-
5850
// We don't want to make downstream code call ax.setScale,
5951
// as both real and imaginary axes don't have a set domain.
6052
// Furthermore, imaginary axes don't have a set range.
@@ -70,13 +62,33 @@ function handleDefaults(contIn, contOut, coerce, opts) {
7062
handlePrefixSuffixDefaults(axIn, axOut, coerceAxis, axOut.type);
7163

7264
if(visible) {
73-
if(axName === 'realaxis') {
74-
coerceAxis('side');
75-
}
65+
var isRealAxis = axName === 'realaxis';
66+
if(isRealAxis) coerceAxis('side');
7667

7768
coerceAxis('tickvals');
7869

79-
handleTickLabelDefaults(axIn, axOut, coerceAxis, axOut.type);
70+
var dfltColor;
71+
var dfltFontColor;
72+
var dfltFontSize;
73+
var dfltFontFamily;
74+
var font = opts.font || {};
75+
76+
if(visible) {
77+
dfltColor = coerceAxis('color');
78+
dfltFontColor = (dfltColor === axIn.color) ? dfltColor : font.color;
79+
dfltFontSize = font.size;
80+
dfltFontFamily = font.family;
81+
}
82+
83+
handleTickLabelDefaults(axIn, axOut, coerceAxis, axOut.type, {
84+
noAng: !isRealAxis,
85+
noExp: true,
86+
font: {
87+
color: dfltFontColor,
88+
size: dfltFontSize,
89+
family: dfltFontFamily
90+
}
91+
});
8092

8193
Lib.coerce2(contIn, contOut, layoutAttributes, axName + '.ticklen');
8294
Lib.coerce2(contIn, contOut, layoutAttributes, axName + '.tickwidth');
@@ -88,17 +100,6 @@ function handleDefaults(contIn, contOut, coerce, opts) {
88100
delete contOut[axName].tickcolor;
89101
}
90102

91-
var showTickLabels = coerceAxis('showticklabels');
92-
if(showTickLabels) {
93-
Lib.coerceFont(coerceAxis, 'tickfont', {
94-
family: opts.font.family,
95-
size: opts.font.size,
96-
color: dfltFontColor
97-
});
98-
coerceAxis('tickangle');
99-
coerceAxis('tickformat');
100-
}
101-
102103
handleLineGridDefaults(axIn, axOut, coerceAxis, {
103104
dfltColor: dfltColor,
104105
bgColor: opts.bgColor,

test/plot-schema.json

Lines changed: 0 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -7362,20 +7362,6 @@
73627362
"valType": "color"
73637363
},
73647364
"editType": "plot",
7365-
"exponentformat": {
7366-
"description": "Determines a formatting rule for the tick exponents. For example, consider the number 1,000,000,000. If *none*, it appears as 1,000,000,000. If *e*, 1e+9. If *E*, 1E+9. If *power*, 1x10^9 (with 9 in a super script). If *SI*, 1G. If *B*, 1B.",
7367-
"dflt": "B",
7368-
"editType": "plot",
7369-
"valType": "enumerated",
7370-
"values": [
7371-
"none",
7372-
"e",
7373-
"E",
7374-
"power",
7375-
"SI",
7376-
"B"
7377-
]
7378-
},
73797365
"gridcolor": {
73807366
"description": "Sets the color of the grid lines.",
73817367
"dflt": "#eee",
@@ -7418,20 +7404,7 @@
74187404
"min": 0,
74197405
"valType": "number"
74207406
},
7421-
"minexponent": {
7422-
"description": "Hide SI prefix for 10^n if |n| is below this number. This only has an effect when `tickformat` is *SI* or *B*.",
7423-
"dflt": 3,
7424-
"editType": "plot",
7425-
"min": 0,
7426-
"valType": "number"
7427-
},
74287407
"role": "object",
7429-
"separatethousands": {
7430-
"description": "If \"true\", even 4-digit integers are separated",
7431-
"dflt": false,
7432-
"editType": "plot",
7433-
"valType": "boolean"
7434-
},
74357408
"showexponent": {
74367409
"description": "If *all*, all exponents are shown besides their significands. If *first*, only the exponent of the first tick is shown. If *last*, only the exponent of the last tick is shown. If *none*, no exponents appear.",
74377410
"dflt": "all",
@@ -7486,12 +7459,6 @@
74867459
"none"
74877460
]
74887461
},
7489-
"tickangle": {
7490-
"description": "Sets the angle of the tick labels with respect to the horizontal. For example, a `tickangle` of -90 draws the tick labels vertically.",
7491-
"dflt": "auto",
7492-
"editType": "ticks",
7493-
"valType": "angle"
7494-
},
74957462
"tickcolor": {
74967463
"description": "Sets the tick color.",
74977464
"dflt": "#444",
@@ -7613,20 +7580,6 @@
76137580
"valType": "color"
76147581
},
76157582
"editType": "plot",
7616-
"exponentformat": {
7617-
"description": "Determines a formatting rule for the tick exponents. For example, consider the number 1,000,000,000. If *none*, it appears as 1,000,000,000. If *e*, 1e+9. If *E*, 1E+9. If *power*, 1x10^9 (with 9 in a super script). If *SI*, 1G. If *B*, 1B.",
7618-
"dflt": "B",
7619-
"editType": "plot",
7620-
"valType": "enumerated",
7621-
"values": [
7622-
"none",
7623-
"e",
7624-
"E",
7625-
"power",
7626-
"SI",
7627-
"B"
7628-
]
7629-
},
76307583
"gridcolor": {
76317584
"description": "Sets the color of the grid lines.",
76327585
"dflt": "#eee",
@@ -7669,20 +7622,7 @@
76697622
"min": 0,
76707623
"valType": "number"
76717624
},
7672-
"minexponent": {
7673-
"description": "Hide SI prefix for 10^n if |n| is below this number. This only has an effect when `tickformat` is *SI* or *B*.",
7674-
"dflt": 3,
7675-
"editType": "plot",
7676-
"min": 0,
7677-
"valType": "number"
7678-
},
76797625
"role": "object",
7680-
"separatethousands": {
7681-
"description": "If \"true\", even 4-digit integers are separated",
7682-
"dflt": false,
7683-
"editType": "plot",
7684-
"valType": "boolean"
7685-
},
76867626
"showexponent": {
76877627
"description": "If *all*, all exponents are shown besides their significands. If *first*, only the exponent of the first tick is shown. If *last*, only the exponent of the last tick is shown. If *none*, no exponents appear.",
76887628
"dflt": "all",

0 commit comments

Comments
 (0)