Skip to content

Commit cfa96e5

Browse files
committed
inherit imaginary tickvals default from real axis
- and use 0.2, 0.5, 1, 2, 5 set for tickvals
1 parent d30416d commit cfa96e5

File tree

12 files changed

+34
-56
lines changed

12 files changed

+34
-56
lines changed

src/plots/smith/constants.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ module.exports = {
44
attr: 'subplot',
55
name: 'smith',
66

7-
axisNames: ['imaginaryaxis', 'realaxis'],
7+
axisNames: [
8+
'realaxis',
9+
'imaginaryaxis' // imaginary axis should be second here so that the `tickvals` defaults could be inherited from realaxis
10+
],
811
axisName2dataArray: {imaginaryaxis: 'imag', realaxis: 'real'},
912
};

src/plots/smith/layout_attributes.js

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,7 @@ var realAxisAttrs = extendFlat({
3535
visible: extendFlat({}, axesAttrs.visible, {dflt: true}),
3636

3737
tickvals: {
38-
dflt: [
39-
0.2, 0.4, 0.6, 0.8,
40-
1, 1.5, 2, 3, 4, 5, 10, 20
41-
],
38+
dflt: [0.2, 0.5, 1, 2, 5],
4239
valType: 'data_array',
4340
editType: 'plot',
4441
description: 'Sets the values at which ticks on this axis appear.'
@@ -76,15 +73,12 @@ var imaginaryAxisAttrs = extendFlat({
7673
visible: extendFlat({}, axesAttrs.visible, {dflt: true}),
7774

7875
tickvals: {
79-
dflt: [
80-
-20, -10, -5, -4, -3, -2, -1.5, -1,
81-
-0.8, -0.6, -0.4, -0.2,
82-
0, 0.2, 0.4, 0.6, 0.8,
83-
1, 1.5, 2, 3, 4, 5, 10, 20
84-
],
8576
valType: 'data_array',
8677
editType: 'plot',
87-
description: 'Sets the values at which ticks on this axis appear.'
78+
description: [
79+
'Sets the values at which ticks on this axis appear.',
80+
'Defaults to `realaxis.tickvals` plus the same as negatives and zero.'
81+
].join(' ')
8882
},
8983

9084
ticks: axesAttrs.ticks,

src/plots/smith/layout_defaults.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,17 @@ function handleDefaults(contIn, contOut, coerce, opts) {
5252
var isRealAxis = axName === 'realaxis';
5353
if(isRealAxis) coerceAxis('side');
5454

55-
coerceAxis('tickvals');
55+
if(isRealAxis) {
56+
coerceAxis('tickvals');
57+
} else {
58+
var realTickvals = contOut.realaxis.tickvals || layoutAttributes.realaxis.tickvals.dflt;
59+
var imagTickvalsDflt =
60+
realTickvals.slice().reverse().map(function(x) { return -x; })
61+
.concat([0])
62+
.concat(realTickvals);
63+
64+
coerceAxis('tickvals', imagTickvalsDflt);
65+
}
5666

5767
var dfltColor;
5868
var dfltFontColor;

test/image/baselines/smith_blank.png

-19.3 KB
Loading

test/image/baselines/smith_fills.png

-33.9 KB
Loading

test/image/baselines/smith_gaps.png

-18.2 KB
Loading

test/image/baselines/smith_modes.png

-39.5 KB
Loading
-18.3 KB
Loading
-13.6 KB
Loading

test/image/mocks/smith_basic.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@
2121
"l": 40
2222
},
2323
"width": 800,
24-
"height": 800
24+
"height": 800,
25+
"smith": {
26+
"realaxis": {
27+
"tickvals": [0.2, 0.4, 0.6, 0.8, 1, 1.5, 2, 3, 4, 5, 10, 20]
28+
}
29+
}
2530
}
2631
}

0 commit comments

Comments
 (0)