index.js 786 B

12345678910111213141516171819202122
  1. window.onload = function() {
  2. const xmlhttp = new XMLHttpRequest();
  3. const formats = ["Accueil", "Espace 1", "Espace 2"]
  4. // Get JSON File
  5. xmlhttp.onreadystatechange = function() {
  6. if (this.readyState == 4 && this.status == 200) {
  7. var myObj = JSON.parse(this.responseText); // Parse JSON file
  8. var dataInFile = myObj.usagers; // JSON data
  9. const freqBySpaceData = freqBySpace(dataInFile);
  10. displayfileData(dataInFile);
  11. createChartToDOM(freqBySpaceData.title, freqBySpaceData.espaceFormat, freqBySpaceData.key, freqBySpaceData.avePrice);
  12. var objReturn = avePriceByKey(dataInFile, "espace");
  13. console.log(objReturn);
  14. }
  15. };
  16. xmlhttp.open("GET", "js/usagers.json", true);
  17. xmlhttp.send();
  18. }