Skip to content

Commit

Permalink
fix: improved second graph handling
Browse files Browse the repository at this point in the history
  • Loading branch information
zleyyij committed Jun 2, 2024
1 parent a317a71 commit 41b29ba
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/scripts/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,17 +188,28 @@ export function drawGraph(srs = [], divName) {
console.error("tried to draw graph with no items in list.");
}
}

console.log(document.getElementById("uploadedFile").files);
export async function parseCSV(
file = document.getElementById("uploadedFile").files[0]
) {
//hide the welcome message
document.getElementById("welcomeMessage").style.display = "none";
// show the loading icon
document.getElementById("loadingIcon").style.display = "";
// Clear the searchbar
document.getElementById("graphSearch").value = "";
document.getElementById("searchResults").replaceChildren();
console.time("CSV parsing time");
// wipe the results, in case a new file is being rendered
for (const chart of charts) {
chart.destroy();
}
for (const key in parsedData) {
// Directly modify every array to wipe them in case the garbage collector doesn't behave like we want it to
parsedData[key].length = 0;
}
parsedData = {};
charts = [];
// just delete *all of the charts*
document.getElementById("chartDiv").replaceChildren();
const fileAsBuffer = await file.arrayBuffer();
Expand All @@ -222,7 +233,7 @@ if (urlParams.get("url") == null) {
upCheck.onchange = function () {
document.getElementById("loadingIcon").style.display = "";
document.getElementById("welcomeMessage").style.display = "none";
parseCSV();
parseCSV(document.getElementById("uploadedFile").files[0]);
};
} else {
// TODO: make it so that this whole schtick isn't hardcoded
Expand Down

0 comments on commit 41b29ba

Please sign in to comment.