fixed export png function

This commit is contained in:
dlawler489 2025-04-27 18:21:39 +10:00
parent e10e838745
commit 93ecc88ade
2 changed files with 5 additions and 4 deletions

View file

@ -43,7 +43,7 @@
<div id="loading">Loading chart, please wait...</div>
<svg width="1400" height="600"></svg>
<svg id="chart" width="1400" height="600"></svg>
<div class="legend" id="legend"></div>

View file

@ -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);
});
});