fetch('./js/stats.json') .then(response => response.json()) .then(stats => { // import * as stats from './stats.json' assert { type: 'json' }; console.log(stats); document.getElementById('countStationsOSM').textContent = formatSpaceSeparator(stats.countStationsOSM); document.getElementById('countStationsOpenData').textContent = formatSpaceSeparator(stats.countStationsOpenData); document.getElementById('countStationsAVERE').textContent = formatSpaceSeparator(40000); document.getElementById('countPointsDeChargeAVERE').textContent = formatSpaceSeparator(stats.countStationsAVERE); document.getElementById('countPointsDeChargeOSM').textContent = formatSpaceSeparator(stats.countPointsDeChargeOSM); document.getElementById('countPointsDeChargeOpenData').textContent = formatSpaceSeparator(stats.countPointsDeChargeOpenData); document.getElementById('dateGeneration').textContent = stats.dateGeneration; france_twh = 500 irve_monthly_consumption_gwh = 69 annual_consumption_gwh = compute_annual_consumption_gwh(irve_monthly_consumption_gwh, france_twh) proportion_annual_consumption_gwh = compute_proportion_annual_consumption_gwh(annual_consumption_gwh, stats.countStationsAVERE) console.log('estimation de la consommation annuelle des stations de recharge en France', annual_consumption_gwh, 'GWh sur ', france_twh * 1000, 'GWh') console.log('proportion de la consommation annuelle par borne', proportion_annual_consumption_gwh) }) .catch(error => { console.error('Erreur lors du chargement du fichier stats.json:', error); }); function compute_annual_consumption_gwh(irve_monthly_consumption_gwh, france_twh) { return irve_monthly_consumption_gwh * 12 * france_twh; } function compute_proportion_annual_consumption_gwh(annual_consumption_gwh, countStationsAVERE) { return (annual_consumption_gwh / countStationsAVERE).toFixed(2); } function formatSpaceSeparator(number) { return number.toString().replace(/\B(?=(\d{3})+(?!\d))/g, " "); }