window.onload = function() {
   const xmlhttp = new XMLHttpRequest();
   const formats = ["Accueil", "Espace 1", "Espace 2"]

   // Get JSON File
   xmlhttp.onreadystatechange = function() {
      if (this.readyState == 4 && this.status == 200) {
         var myObj = JSON.parse(this.responseText); // Parse JSON file
         var dataInFile = myObj.usagers; // JSON data

         const freqBySpaceData = freqBySpace(dataInFile);
         

         displayfileData(dataInFile);
         createChartToDOM(freqBySpaceData.title, freqBySpaceData.espaceFormat, freqBySpaceData.key, freqBySpaceData.avePrice);
         var objReturn = avePriceByKey(dataInFile, "espace");
         console.log(objReturn);
      }
   };
   xmlhttp.open("GET", "js/usagers.json", true);
   xmlhttp.send();
}
