-
Notifications
You must be signed in to change notification settings - Fork 31
/
indexSalaries.html
50 lines (48 loc) · 1.68 KB
/
indexSalaries.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" href="./mystyles.css">
</head>
<script src="https://www.gstatic.com/charts/loader.js"></script>
<script type="text/javascript" src="./drawChart.js"></script>
<script>
// Load the Visualization API and the corechart package.
google.charts.load('current', {'packages':['corechart']});
// Set a callback to run when the Google Visualization API is loaded.
google.charts.setOnLoadCallback(drawChart);
// get data from url
let data = null;
let url = "https://pollysnips.s3.amazonaws.com/bostonEmployeeSalaries.json"
fetch(url).then((response) => response.json())
.then(json => {
data = json;
//writeData(JSON.stringify(data.data[0]));
})
.catch(error => {
throw(error);
})
function analyzeData(){
// get salaries above target value
let targetSalary = Number(document.getElementById("input").value);
let rows = data.data;
let salaries = rows.filter((item)=>Number(item[18])>targetSalary);
drawChart(salaries)
}
function writeData(data){
document.getElementById("data").innerHTML += "<h1>"+JSON.stringify(data)+"</h1> <br>";
}
</script>
<body>
<h1>Boston City Valued Workers</h1>
<label>Enter Cutoff Salary</label>
<input id= "input" type = "number" value="300000">
<button onclick="analyzeData()" >Analyze Boston Data</button>
<div id="data">
</div>
<div id = "chart">
</div>
</body>
</html>