fixed download function
This commit is contained in:
parent
b578c53594
commit
b4642ce57a
1 changed files with 4 additions and 7 deletions
|
|
@ -171,29 +171,26 @@ d3.csv("PHSwithContinent.csv").then(function(data) {
|
|||
updateChart();
|
||||
});
|
||||
|
||||
// Download chart as PNG
|
||||
d3.select("#downloadButton").on("click", function() {
|
||||
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(document.getElementById("chart"), {
|
||||
filename: filename,
|
||||
|
||||
saveSvgAsPng(document.getElementById("chart"), filename, { // <-- filename second, options third
|
||||
scale: 2,
|
||||
backgroundColor: darkMode ? "#121212" : "#ffffff"
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// Update legend depending on chart type
|
||||
function updateLegend(chartType) {
|
||||
const legend = d3.select("#legend");
|
||||
|
|
|
|||
Loading…
Reference in a new issue