From 1c017e155892f7e20e24eac190050a201cd6171a Mon Sep 17 00:00:00 2001 From: Lillian Gray <lmgray16@earlham.edu> Date: Thu, 9 Jan 2020 17:53:46 -0500 Subject: [PATCH] Simplify data fetching #9 --- index.html | 2 +- js/main.js | 14 +++++--------- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/index.html b/index.html index 71309ce..7ca19d6 100755 --- a/index.html +++ b/index.html @@ -20,7 +20,7 @@ <script src="js/loader.js"></script> <script> google.charts.load('45.2', {packages:['corechart', 'controls']}); - google.charts.setOnLoadCallback(onAPILoad); + google.charts.setOnLoadCallback(getData); </script> </head> <body> diff --git a/js/main.js b/js/main.js index 9fabf79..753987c 100755 --- a/js/main.js +++ b/js/main.js @@ -28,19 +28,15 @@ var startDate var URLComponents = document.URL.split('?') /*called when GoogleAPI finishes loading in index.html - calls getData and then passes the data into initializeLineChart when finished*/ -function onAPILoad(){ - getData().done(initializeLineChart) -} - -//fetches data for chart from text file generated by data_gen.py + fetches column data from config.json + fetches data for chart from text file generated by data_gen.py + passes the data into initializeLineChart when finished*/ function getData(){ $.getJSON("config.json", function(data){ buildings = data.building }) - return $.ajax({ - url: "raw_line_chart.txt", //location of data file - dataType: "json", + $.getJSON("raw_line_chart.txt", function(data){ + initializeLineChart(data) }) } -- GitLab