fully working csv download
parent
76e178176d
commit
f8d4f85858
|
@ -1,4 +1,4 @@
|
||||||
function saveCsv(csvStr) {
|
function saveData(csvStr, filename) {
|
||||||
// string rep
|
// string rep
|
||||||
// var csvStr = "";
|
// var csvStr = "";
|
||||||
// for (let r = 0; r < csvData.length; r++) {
|
// for (let r = 0; r < csvData.length; r++) {
|
||||||
|
@ -17,5 +17,12 @@ function saveCsv(csvStr) {
|
||||||
var data = new Blob([csvStr]);
|
var data = new Blob([csvStr]);
|
||||||
|
|
||||||
// create & click temp link
|
// create & click temp link
|
||||||
window.open(URL.createObjectURL(data));
|
// slightly modded https://stackoverflow.com/a/15832662
|
||||||
|
var link = document.createElement("a");
|
||||||
|
link.download = filename;
|
||||||
|
link.href = URL.createObjectURL(data);
|
||||||
|
document.body.appendChild(link);
|
||||||
|
link.click();
|
||||||
|
document.body.removeChild(link);
|
||||||
|
delete link;
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,7 +46,7 @@
|
||||||
<strong>Temperature Distribution</strong>
|
<strong>Temperature Distribution</strong>
|
||||||
<button
|
<button
|
||||||
style="width: 10rem; height: 2rem; margin-left: 1rem;"
|
style="width: 10rem; height: 2rem; margin-left: 1rem;"
|
||||||
download="temperature-data.csv" type="text/csv" onclick="saveCsv(`{{csv_data}}`)">Download Data as CSV</button>
|
onclick="saveData(`{{csv_data}}`, 'temperature-data.csv')">Download Data as CSV</button>
|
||||||
</div>
|
</div>
|
||||||
{{ freq_plot | safe }}
|
{{ freq_plot | safe }}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue