movingAverageData = nbJ_temp_max
.map((d, i) => {
if (i < 4) return null;
const subset = nbJ_temp_max.slice(i - 4, i + 1);
const avg =
subset.reduce((sum, row) => sum + row.nbjour, 0) / subset.length;
return { annee: d.annee, nbjour: d.nbjour, movingAverage: avg };
})
.filter((d) => d !== null)