Update script.js
fixed normalisation for data labels
This commit is contained in:
parent
430a81be94
commit
f1ed754b3d
1 changed files with 14 additions and 3 deletions
|
|
@ -12,9 +12,9 @@ const y = d3.scaleLinear().rangeRound([height, 0]);
|
|||
|
||||
// Education levels for legend and grouped charts
|
||||
const educationLevels = [
|
||||
"Primary education",
|
||||
"Secondary education",
|
||||
"Tertiary education"
|
||||
"Primary Education",
|
||||
"Secondary Education",
|
||||
"Tertiary Education"
|
||||
];
|
||||
|
||||
// Color scale for education levels
|
||||
|
|
@ -82,8 +82,19 @@ darkModeToggle.addEventListener('click', () => {
|
|||
g.selectAll(".lowest-box").attr("fill", darkMode ? "#222" : "#fff").attr("stroke", darkMode ? "#aaa" : "#999");
|
||||
});
|
||||
|
||||
|
||||
// Load data
|
||||
d3.csv("PHSwithContinent.csv").then(function(data) {
|
||||
// Normalize Socio-economic status values to match educationLevels
|
||||
data.forEach(d => {
|
||||
if (d["Socio-economic status"] === "Pre-primary, primary and lower secondary education") {
|
||||
d["Socio-economic status"] = "Primary Education";
|
||||
} else if (d["Socio-economic status"] === "Upper secondary and post-secondary non-tertiary, all programmes") {
|
||||
d["Socio-economic status"] = "Secondary Education";
|
||||
} else if (d["Socio-economic status"] === "Tertiary education") {
|
||||
d["Socio-economic status"] = "Tertiary Education";
|
||||
}
|
||||
});
|
||||
const allData = data;
|
||||
|
||||
// Populate continent and education dropdowns
|
||||
|
|
|
|||
Loading…
Reference in a new issue