forked from daviku2000/daviku2000.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
plot.js
67 lines (57 loc) · 1.92 KB
/
plot.js
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
google.load("visualization", "1", {packages:["corechart"]});
function drawChart(city, openings) {
let data = google.visualization.arrayToDataTable([['Team', 'Openings'], ...openings]);
let chart = new google.visualization.PieChart(document.getElementById(city));
chart.draw(data, {title: city, is3D: true});
}
function drawChart0() {
let total = 10900;
let given = 3365 + 750 + 661 + 524 + 393 + 344 + 246 + 226 + 217 + 201;
let data = google.visualization.arrayToDataTable([
['City', 'Number of Openings'],
['Seattle', 3365],
['New York', 750],
['Arlington', 661],
['Austin', 524],
['Bellevue', 393],
['Sunnyvale', 344],
['Boston', 246],
['San Francisco', 226],
['East Palo Alto', 217],
['Dallas', 201],
['Other', total - given]
]);
let options = {
title: '10 Largest Cities',
is3D: 'true'
};
// https://www.amazon.jobs/en/search.json?category%5B%5D=software-development&schedule_type_id%5B%5D=Full-Time&normalized_country_code%5B%5D=USA&normalized_city_name%5B%5D=Brisbane&facets%5B%5D=business_category
let chart = new google.visualization.PieChart(document.getElementById('chart0'));
chart.draw(data, options);
}
fetch('openings.json')
.then(response => response.json())
.then(openings => {
let cities = Object.keys(openings);
let htmlElements = "";
for (let i = 0; i < cities.length; i += 2) {
htmlElements += `
<div class="row">
<div class="clearfix"></div>
<div class="col-lg-6">
<div id="${cities[i]}" class="chart"></div>
</div>
<div class="col-lg-6">
<div id="${cities[i+1]}" class="chart"></div>
</div>
</div>`;
}
document.body.innerHTML += htmlElements;
google.setOnLoadCallback(drawChart0);
for (let city in openings) {
google.setOnLoadCallback(() => drawChart(city, openings[city]));
}
});
$(window).resize(function(){
drawChart;
});