// make an API call to Chicago crime data 
var baseURL = "https://data.cityofchicago.org/resource/6zsd-86xi.json"
var basicQuery = encodeURI("?$select=ward,COUNT(ward)&$group=ward&$limit=10&$order=COUNT(ward) DESC ")
var appToken = "&$$app_token=XTzcaicIeaM3s1GDqbUAaUVS5"

$(document).ready(function(){
	//test click on dead link to get top ten crime wards
	$("a").on("click", function(e){
		e.preventDefault()
		console.log(baseURL+basicQuery+appToken)
		$.getJSON( baseURL+basicQuery+appToken, function (data) {
			console.log(data)
			var table = "<table> <tr> <th> Number of Crimes </th> <th> Ward </th> </tr>"
			var tableItems = []
			// turn each ward with count into table row
			for (var i = 0; i < data.length; i++) {
				tableItems.push("<tr><td>"+data[i].COUNT_ward+"</td> <td>"+data[i].ward+"</td></tr>")
			}

			tableItemsString = tableItems.join("")
			table += tableItemsString+"</table>"
			$("#table-container").html(table)
		})
	})
})
@@ -148,36 +148,66 @@
 ect=
-ward,COUNT(ward)&$group=ward
+community_area,COUNT(community_area)&$group=community_area
 &$li
@@ -226,20 +226,30 @@
 r=COUNT(
-ward
+community_area
 ) DESC %22
@@ -385,20 +385,30 @@
 n crime 
-ward
+community_area
 s%0A%09$(%22a%22
@@ -645,12 +645,22 @@
 th%3E 
-Ward
+Community Area
  %3C/t
@@ -708,20 +708,30 @@
 rn each 
-ward
+community_area
  with co
@@ -837,20 +837,30 @@
 %5D.COUNT_
-ward
+community_area
 +%22%3C/td%3E 
@@ -877,12 +877,22 @@
 %5Bi%5D.
-ward
+community_area
 +%22%3C/

change grouping by ward to community area for better comparison with chi datasets