Skip to content

Commit f9a1328

Browse files
committed
fixing unit label saving in downloaded json
1 parent 7e81ea1 commit f9a1328

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

smith_chart/js/smith_tool.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,15 @@ function drawMakerTable() {
120120
table.innerHTML = inner + "</table>";
121121
}
122122

123+
function freqUnitToText(multiplier) {
124+
if (multiplier == 1) return 'Hz';
125+
else if (multiplier == 1e3) return 'KHz' ;
126+
else if (multiplier == 1e6) return 'MHz' ;
127+
else if (multiplier == 1e9) return 'GHz' ;
128+
else if (multiplier == 1e12) return 'THz' ;
129+
else return 'Hz'
130+
}
131+
123132
fileDom = document.getElementById('file');
124133
domFreq = document.getElementById('freq');
125134
domFreqSel = document.getElementById('freq_sel');
@@ -150,14 +159,14 @@ function readFile() {
150159
//update freq units
151160
var opts = domFreqSel.options;
152161
for (var opt, j = 0; opt = opts[j]; j++) {
153-
if (opt.value == schematic[0].freq_unit.unit) {
162+
if (opt.value == freqUnitToText(schematic[0].freq_unit.multiplier)) {
154163
domFreqSel.selectedIndex = j;
155164
break;
156165
}
157166
}
158167
opts = domSpanSel.options;
159168
for (opt, j = 0; opt = opts[j]; j++) {
160-
if (opt.value == schematic[0].span_unit.unit) {
169+
if (opt.value == freqUnitToText(schematic[0].span_unit.multiplier)) {
161170
domSpanSel.selectedIndex = j;
162171
break;
163172
}
@@ -228,7 +237,7 @@ function updatespan(sch_num, obj, unitIndex=0) {
228237
//Add custom markers from the user, to help matching to exact impedances
229238
var customMarkers = [];
230239

231-
schematic.push({type:'raw', zo : 50, freq:2440, er : 1, freq_unit:{unit:'MHz',multiplier:1e6}, span:0.0, span_unit:{unit:'MHz',multiplier:1e6}});
240+
schematic.push({type:'raw', zo : 50, freq:2440, er : 1, freq_unit:{multiplier:1e6}, span:0.0, span_unit:{multiplier:1e6}});
232241
schematic.push({type:'bb',real:1,imaginary:0,abs:[50,0],unit:'null',tol:0});
233242

234243
function one_over_complex(real, imaginary) {

0 commit comments

Comments
 (0)