Skip to content
Snippets Groups Projects
Commit 1c017e15 authored by Lillian Gray's avatar Lillian Gray
Browse files

Simplify data fetching #9

parent 96c7b7ca
Branches main
No related merge requests found
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
<script src="js/loader.js"></script> <script src="js/loader.js"></script>
<script> <script>
google.charts.load('45.2', {packages:['corechart', 'controls']}); google.charts.load('45.2', {packages:['corechart', 'controls']});
google.charts.setOnLoadCallback(onAPILoad); google.charts.setOnLoadCallback(getData);
</script> </script>
</head> </head>
<body> <body>
......
...@@ -28,19 +28,15 @@ var startDate ...@@ -28,19 +28,15 @@ var startDate
var URLComponents = document.URL.split('?') var URLComponents = document.URL.split('?')
/*called when GoogleAPI finishes loading in index.html /*called when GoogleAPI finishes loading in index.html
calls getData and then passes the data into initializeLineChart when finished*/ fetches column data from config.json
function onAPILoad(){ fetches data for chart from text file generated by data_gen.py
getData().done(initializeLineChart) passes the data into initializeLineChart when finished*/
}
//fetches data for chart from text file generated by data_gen.py
function getData(){ function getData(){
$.getJSON("config.json", function(data){ $.getJSON("config.json", function(data){
buildings = data.building buildings = data.building
}) })
return $.ajax({ $.getJSON("raw_line_chart.txt", function(data){
url: "raw_line_chart.txt", //location of data file initializeLineChart(data)
dataType: "json",
}) })
} }
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment