Last active
April 21, 2017 10:49
-
-
Save lukeisontheroad/ac2ade55585ff53ea661075494f21b82 to your computer and use it in GitHub Desktop.
Week 7 Makeover
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var raw_data = [ | |
{ | |
"2013": 157, | |
"2014": 143, | |
"2015": 173, | |
"Name": "Gleitschirm / Delta", | |
"2013_l": "157 (2013)", | |
"2014_l": "143 (2014)", | |
"2015_l": "173 (2015)" | |
}, | |
{ | |
"2013": 196, | |
"2014": 194, | |
"2015": 205, | |
"Name": "Andere Bergsportarten", | |
"2013_l": "196 (2013)", | |
"2014_l": "194 (2014)", | |
"2015_l": "205 (2015)" | |
}, | |
{ | |
"2013": 155, | |
"2014": 176, | |
"2015": 162, | |
"Name": "Mountainbike", | |
"2013_l": "155 (2013)", | |
"2014_l": "176 (2014)", | |
"2015_l": "162 (2015)" | |
}, | |
{ | |
"2013": 117, | |
"2014": 113, | |
"2015": 122, | |
"Name": "Klettern (Fels)", | |
"2013_l": "117 (2013)", | |
"2014_l": "113 (2014)", | |
"2015_l": "122 (2015)" | |
}, | |
{ | |
"2013": 222, | |
"2014": 161, | |
"2015": 172, | |
"Name": "Variantenabfahrten", | |
"2013_l": "222 (2013)", | |
"2014_l": "161 (2014)", | |
"2015_l": "172 (2015)" | |
}, | |
{ | |
"2013": 348, | |
"2014": 314, | |
"2015": 321, | |
"Name": "Skitouren", | |
"2013_l": "348 (2013)", | |
"2014_l": "314 (2014)", | |
"2015_l": "321 (2015)" | |
}, | |
{ | |
"2013": 362, | |
"2014": 348, | |
"2015": 402, | |
"Name": "Hochtouren", | |
"2013_l": "362 (2013)", | |
"2014_l": "348 (2014)", | |
"2015_l": "402 (2015)" | |
}, | |
{ | |
"2013": 996, | |
"2014": 1007, | |
"2015": 1193, | |
"Name": "Bergwandern", | |
"2013_l": "996 (2013)", | |
"2014_l": "1007 (2014)", | |
"2015_l": "1193 (2015)" | |
} | |
]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script> | |
<script type="text/javascript" src="data.js"></script> | |
</head> | |
<body> | |
<div id="chart_div"></div> | |
<script> | |
google.charts.load('current', {packages: ['corechart', 'bar']}); | |
google.charts.setOnLoadCallback(drawAxisTickColors); | |
function drawAxisTickColors() { | |
var data_prepared = [ | |
['Name', '2015', { role: 'annotation' }, { role: 'style' }, '2014', { role: 'annotation' }, { role: 'style' }, '2013', { role: 'annotation' }, { role: 'style' }] | |
]; | |
var data_sorted = raw_data.sort( (x, y) => y['2015'] - x['2015'] ); | |
for(var i = 0; i < data_sorted.length; i++){ | |
data_prepared.push([data_sorted[i].Name, | |
data_sorted[i]['2015'], | |
data_sorted[i]['2015_l'], | |
'#03A9F4', | |
data_sorted[i]['2014'], | |
data_sorted[i]['2014_l'], | |
'#8BC34A', | |
data_sorted[i]['2013'], | |
data_sorted[i]['2013_l'], | |
'#f44336']); | |
} | |
var data = google.visualization.arrayToDataTable(data_prepared); | |
var options = { | |
title: 'Anzahl Bergnotf\u00E4lle', | |
chartArea: {left: 300, width: '100%', height:800}, | |
height:850, | |
legend: {position: 'none'}, | |
hAxis: { | |
title: 'Anzahl Personen', | |
textPosition: 'in', | |
minValue: 0, | |
gridlines: {color: '#dadbdb', count: 8}, | |
minorGridlines: {color: '#f5f5f5', count: 2} | |
}, | |
vAxis: { | |
title: '' | |
} | |
}; | |
var chart = new google.visualization.BarChart(document.getElementById('chart_div')); | |
chart.draw(data, options); | |
} | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment