From 93ecc88adea650ef41cd3989c6224b71674e6121 Mon Sep 17 00:00:00 2001 From: dlawler489 <104159223@student.swin.edu.au> Date: Sun, 27 Apr 2025 18:21:39 +1000 Subject: [PATCH] fixed export png function --- index.html | 2 +- script/script.js | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/index.html b/index.html index 84acc3b..d31d7c6 100644 --- a/index.html +++ b/index.html @@ -43,7 +43,7 @@
Loading chart, please wait...
- +
diff --git a/script/script.js b/script/script.js index 38c724b..8edb336 100644 --- a/script/script.js +++ b/script/script.js @@ -170,16 +170,17 @@ d3.csv("PHSwithContinent.csv").then(function(data) { const c = d3.select("#continentSelect").property("value"); const s = d3.select("#sexSelect").property("value"); const e = d3.select("#incomeSelect").property("value"); - + const parts = [ "education_health", c !== "All" ? c : null, s !== "All" ? s : null, e !== "All" ? e.replace(/[^a-zA-Z0-9]+/g, "_").toLowerCase() : null ].filter(Boolean); - + const filename = parts.join("_") + ".png"; - saveSvgAsPng.saveSvgAsPng(document.querySelector("svg"), filename); + + saveSvgAsPng(document.getElementById("chart"), filename); }); });