csv export for waveform

Former-commit-id: 1cead5d424985fe266d8963e1967603b42df4b9a
master
Ondřej Hruška 9 years ago
parent 2ad7e059f7
commit 2357472b4c
  1. 4
      html/js/all.js
  2. 4
      html/pages/fft.html
  3. 7
      html/pages/wfm.html
  4. 15
      html_src/js-src/page_waveform.js
  5. 4
      html_src/js/all.js
  6. 4
      html_src/page_fft.php
  7. 7
      html_src/page_waveform.php

File diff suppressed because one or more lines are too long

@ -84,8 +84,8 @@
<a data-sep="space">1·2·3</a> <a data-sep="space">1·2·3</a>
<a data-sep="comma">1,2,3</a> <a data-sep="comma">1,2,3</a>
<a data-sep="newline">1↵2↵3</a> <a data-sep="newline">1↵2↵3</a>
<a data-sep="fft-csv">CSV</a> <a data-sep="csv">CSV</a>
<a data-sep="fft-json">JSON</a><br> <br>
<textarea id="copybox" class="hidden" readonly onfocus="this.select();" onmouseup="return false"></textarea> <textarea id="copybox" class="hidden" readonly onfocus="this.select();" onmouseup="return false"></textarea>
</div> </div>

@ -69,7 +69,12 @@
</div> </div>
<div class="Box chartexport hidden"> <div class="Box chartexport hidden">
Copy: <a data-sep="space">1·2·3</a> <a data-sep="comma">1,2,3</a> <a data-sep="newline">1↵2↵3</a><br> Copy:
<a data-sep="space">1·2·3</a>
<a data-sep="comma">1,2,3</a>
<a data-sep="newline">1↵2↵3</a>
<a data-sep="csv">CSV</a>
<br>
<textarea id="copybox" class="hidden" readonly onfocus="this.select();" onmouseup="return false"></textarea> <textarea id="copybox" class="hidden" readonly onfocus="this.select();" onmouseup="return false"></textarea>
</div> </div>

@ -219,25 +219,20 @@ var page_waveform = (function () {
var sep = $(this).data('sep'); var sep = $(this).data('sep');
var str = ''; var str = '';
// for fft var isFft = (dataFormat == 'fft');
var fftStep = (lastObj.stats.freq/lastObj.stats.count); var csvStep = isFft ? (lastObj.stats.freq/lastObj.stats.count) : (1000/lastObj.stats.freq);
var csvPlaces = isFft ? 3 : 2;
switch (sep) { switch (sep) {
case 'space': str = lastObj.samples.join(' '); break; case 'space': str = lastObj.samples.join(' '); break;
case 'comma': str = lastObj.samples.join(','); break; case 'comma': str = lastObj.samples.join(','); break;
case 'newline': str = lastObj.samples.join('\n'); break; case 'newline': str = lastObj.samples.join('\n'); break;
case 'fft-csv': case 'csv':
str = _.map(lastObj.samples, function (a, i) { str = _.map(lastObj.samples, function (a, i) {
return numfmt(i * fftStep,3) + "," + a; return numfmt(i * csvStep, csvPlaces) + "," + a;
}).join('\n'); }).join('\n');
break; break;
case 'fft-json':
str = JSON.stringify(_.map(lastObj.samples, function (a, i) {
return {f: +numfmt(i * fftStep, 3), m: a}
}));
break;
} }
if (!copyToClipboard(str)) { if (!copyToClipboard(str)) {

File diff suppressed because one or more lines are too long

@ -61,8 +61,8 @@
<a data-sep="space">1·2·3</a> <a data-sep="space">1·2·3</a>
<a data-sep="comma">1,2,3</a> <a data-sep="comma">1,2,3</a>
<a data-sep="newline">1↵2↵3</a> <a data-sep="newline">1↵2↵3</a>
<a data-sep="fft-csv">CSV</a> <a data-sep="csv">CSV</a>
<a data-sep="fft-json">JSON</a><br> <br>
<textarea id="copybox" class="hidden" readonly onfocus="this.select();" onmouseup="return false"></textarea> <textarea id="copybox" class="hidden" readonly onfocus="this.select();" onmouseup="return false"></textarea>
</div> </div>

@ -46,7 +46,12 @@
</div> </div>
<div class="Box chartexport hidden"> <div class="Box chartexport hidden">
Copy: <a data-sep="space">1·2·3</a> <a data-sep="comma">1,2,3</a> <a data-sep="newline">1↵2↵3</a><br> Copy:
<a data-sep="space">1·2·3</a>
<a data-sep="comma">1,2,3</a>
<a data-sep="newline">1↵2↵3</a>
<a data-sep="csv">CSV</a>
<br>
<textarea id="copybox" class="hidden" readonly onfocus="this.select();" onmouseup="return false"></textarea> <textarea id="copybox" class="hidden" readonly onfocus="this.select();" onmouseup="return false"></textarea>
</div> </div>

Loading…
Cancel
Save