-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathchoro_maps.js
61 lines (52 loc) · 1.57 KB
/
choro_maps.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
// US Choropleth Map
Plotly.d3.csv('Assets/Data/state_data.csv', function(err, rows){
function unpack(rows, key) {
return rows.map(function(row) { return row[key]; });
}
var data = [{
type: 'choropleth',
locationmode: 'USA-states',
locations: unpack(rows, 'Abbreviation'),
z: unpack(rows, 'Games Owned'),
text: 'games sold',
colorscale: 'Electric',
colorbar: {
title: 'Number Games Sold'
}, }];
var layout = {
title: 'Number of Steam Games Sold per US State',
geo:{
scope: 'usa',
showlakes: true,
lakecolor: '#e6ffff',
}, };
var config = {responsive: true}
Plotly.newPlot("usmap", data, layout, config, {showLink: false});
});
// World Choropleth Map
Plotly.d3.csv('Assets/Data/steam_sales_by_country.csv', function(err, rows){
function unpack(rows, key) {
return rows.map(function(row) { return row[key]; });
}
var data = [{
type: 'choropleth',
locationmode: 'country names',
locations: unpack(rows, 'Country'),
z: unpack(rows, 'Games Owned'),
text: 'games sold',
colorscale: 'Electric',
colorbar: {
title: 'Number Games Sold'
}, }];
var layout = {
title: 'Number of Steam Games Sold Worldwide',
geo:{
scope: 'worldwide',
showocean: true,
oceancolor: '#e6ffff',
projection: {
type: 'robinson'}
}, };
var config = {responsive: true}
Plotly.newPlot("worldmap", data, layout, config, {showLink: false});
});