Skip to content

Commit

Permalink
graphiques en historique lorsqu'il y a des zéros #73
Browse files Browse the repository at this point in the history
  • Loading branch information
jerem1508 committed Dec 20, 2024
1 parent a91bba0 commit 66eb283
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 7 deletions.
6 changes: 0 additions & 6 deletions client/src/pages/atlas/components/main/tabs/sectors.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,6 @@ export function Sectors() {
return <div>Loading...</div>;
}

console.log("data", data,
"dataByYear", dataByYear,
"dataSimilar", dataSimilar,
"dataSectorsMap", dataSectorsMap,
"polygonsData", polygonsData);

const toggleView = () => {
if (chartView === "basic") {
setChartView("percentage");
Expand Down
29 changes: 28 additions & 1 deletion server/src/routes/tableaux/atlas/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -781,6 +781,7 @@ router.route("/atlas/number-of-students").get((req, res) => {
});

router.route("/atlas/number-of-students-by-year").get((req, res) => {
const startYear = 2001;
const filters = {};
if (req.query.geo_id) {
filters.geo_id = req.query.geo_id;
Expand Down Expand Up @@ -835,7 +836,33 @@ router.route("/atlas/number-of-students-by-year").get((req, res) => {
return 0;
});

res.json(dataByYear);
// ajout des années manquantes (à zéro) const startYear = "2001";
const range = [];
for (let year = startYear; year <= dataByYear[dataByYear.length -1].annee_universitaire.substring(0,4); year++) {
range.push(year);
}

const dataByYearFull = [];
for (let i = 0; i < range.length; i++) {
const currentYear = `${range[i]}-${(range[i] + 1).toString().slice(-2)}`;
if (!dataByYear.find((el) => el.annee_universitaire === currentYear)) {
dataByYearFull.push({
annee_universitaire: currentYear,
effectif_total: 0,
effectif_pr: 0,
effectif_pu: 0,
effectif_masculin: 0,
effectif_feminin: 0,
effectif_dut: 0,
effectif_form_ens: 0,
effectif_ing: 0,
});
} else {
dataByYearFull.push(dataByYear.find((el) => el.annee_universitaire === currentYear));
}
}

res.json(dataByYearFull);
});
});

Expand Down

0 comments on commit 66eb283

Please sign in to comment.