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

12 files changed

+34
-56
lines changed

src/plots/smith/constants.js

+4-1
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

+5-11
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

+11-1
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

+6-1
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
}

test/jasmine/tests/smith_test.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -141,19 +141,19 @@ describe('Test relayout on smith subplots:', function() {
141141
return Plotly.relayout(gd, 'smith.realaxis', {ticks: 'top'});
142142
})
143143
.then(function() {
144-
check(12, 'M0,-0.5v-5');
144+
check(5, 'M0,-0.5v-5');
145145
return Plotly.relayout(gd, 'smith.realaxis', {ticks: 'bottom'});
146146
})
147147
.then(function() {
148-
check(12, 'M0,0.5v5');
148+
check(5, 'M0,0.5v5');
149149
return Plotly.relayout(gd, 'smith.realaxis', {ticks: ''});
150150
})
151151
.then(function() {
152152
check(0);
153153
return Plotly.relayout(gd, 'smith.realaxis', {ticks: 'top'});
154154
})
155155
.then(function() {
156-
check(12, 'M0,-0.5v-5');
156+
check(5, 'M0,-0.5v-5');
157157
})
158158
.then(done, done.fail);
159159
});

test/plot-schema.json

+5-39
Original file line numberDiff line numberDiff line change
@@ -7510,34 +7510,7 @@
75107510
"valType": "string"
75117511
},
75127512
"tickvals": {
7513-
"description": "Sets the values at which ticks on this axis appear.",
7514-
"dflt": [
7515-
-20,
7516-
-10,
7517-
-5,
7518-
-4,
7519-
-3,
7520-
-2,
7521-
-1.5,
7522-
-1,
7523-
-0.8,
7524-
-0.6,
7525-
-0.4,
7526-
-0.2,
7527-
0,
7528-
0.2,
7529-
0.4,
7530-
0.6,
7531-
0.8,
7532-
1,
7533-
1.5,
7534-
2,
7535-
3,
7536-
4,
7537-
5,
7538-
10,
7539-
20
7540-
],
7513+
"description": "Sets the values at which ticks on this axis appear. Defaults to `realaxis.tickvals` plus the same as negatives and zero.",
75417514
"editType": "plot",
75427515
"valType": "data_array"
75437516
},
@@ -7735,17 +7708,10 @@
77357708
"description": "Sets the values at which ticks on this axis appear.",
77367709
"dflt": [
77377710
0.2,
7738-
0.4,
7739-
0.6,
7740-
0.8,
7711+
0.5,
77417712
1,
7742-
1.5,
77437713
2,
7744-
3,
7745-
4,
7746-
5,
7747-
10,
7748-
20
7714+
5
77497715
],
77507716
"editType": "plot",
77517717
"valType": "data_array"
@@ -56451,7 +56417,7 @@
5645156417
"valType": "string"
5645256418
},
5645356419
"imag": {
56454-
"description": "Sets the imaginary coordinates",
56420+
"description": "Sets the imaginary component of the data, in units of normalized impedance such that real=1, imag=0 is the center of the chart.",
5645556421
"editType": "calc+clearAxisTypes",
5645656422
"valType": "data_array"
5645756423
},
@@ -57806,7 +57772,7 @@
5780657772
"valType": "number"
5780757773
},
5780857774
"real": {
57809-
"description": "Sets the real coordinates",
57775+
"description": "Sets the real component of the data, in units of normalized impedance such that real=1, imag=0 is the center of the chart.",
5781057776
"editType": "calc+clearAxisTypes",
5781157777
"valType": "data_array"
5781257778
},

0 commit comments

Comments
 (0)