Skip to content

Instantly share code, notes, and snippets.

@widmerin
Last active April 10, 2017 08:58
Show Gist options
  • Save widmerin/2c60b9e35785565c453f2083b541439a to your computer and use it in GitHub Desktop.
Save widmerin/2c60b9e35785565c453f2083b541439a to your computer and use it in GitHub Desktop.
Highchart - Life expectancy
license: apache-2.0
border: no
height: 400
Country Difference life expectancy male and female
Russian Federation 11.6
Belarus 11.5
Lithuania 11
Rwanda 10.2
Syrian Arab Republic 10
Ukraine 9.8
Latvia 9.6
Viet Nam 9.4
Estonia 9.3
El Salvador 9.1
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title></title>
<link rel="stylesheet" href="">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.0/jquery.min.js"></script>
<script src="http://code.highcharts.com/highcharts.js"></script>
</head>
<body>
<div id="container" style="width:100%; height:400px;"></div>
<script>
$(document).ready(function() {
var options = {
chart: {
renderTo: 'container',
type: 'bar'
},
title: {
text: 'Grösster Unterschied der Lebenserwartung zwischen Männer und Frauen'
},
xAxis: {
categories: []
},
yAxis: {
title: {
text: 'Difference(Years)'
},
min: 8,
max: 12
},
series: []
};
$.get("data_lifeexpectancy.csv", function(data) {
var lines = data.split('\n');
var series = {
data: []
};
series.name='Difference (Years)'
$.each(lines, function(lineNo, line) {
if(lineNo>0){
var items = line.split(',');
items[1] = parseFloat(items[1]);
options.xAxis.categories.push(items[0])
series.data.push(items);
}
});
options.series.push(series);
var chart = new Highcharts.Chart(options);
});
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment