Skip to content
This repository has been archived by the owner on Jan 11, 2020. It is now read-only.

Commit

Permalink
Merge pull request #77 from okfde/60-freedom-index
Browse files Browse the repository at this point in the history
Anteil kritische Waffenexporte am GDP
  • Loading branch information
milafrerichs committed Dec 9, 2014
2 parents 6d98a01 + a247c92 commit c7d2cd0
Show file tree
Hide file tree
Showing 11 changed files with 369 additions and 6 deletions.
157 changes: 157 additions & 0 deletions source/data/exporte_2013.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
"","Country","X","year","gesamt","ruestung","country_code","status"
"7","Afghanistan",2326,"2013-01-01",965398,38520,"AFG","NF"
"17","Albania",2327,"2013-01-01",0,0,"ALB","PF"
"31","Algeria",2328,"2013-01-01",825726128,27639122,"DZA","NF"
"55","Angola",2329,"2013-01-01",968633,0,"AGO","NF"
"69","Argentina",2331,"2013-01-01",11485237,0,"ARG","F"
"75","Armenia",2332,"2013-01-01",654,0,"ARM","PF"
"96","Australia",2333,"2013-01-01",35328161,0,"AUS","F"
"109","Austria",2334,"2013-01-01",87167261,0,"AUT","F"
"121","Azerbaijan",2335,"2013-01-01",354800,0,"AZE","NF"
"135","Bahamas",2336,"2013-01-01",0,0,"BHS","F"
"145","Bahrain",2337,"2013-01-01",12857264,0,"BHR","NF"
"165","Bangladesh",2338,"2013-01-01",100468,0,"BGD","PF"
"180","Barbados",2339,"2013-01-01",51519,0,"BRB","F"
"194","Belarus",2340,"2013-01-01",1115,0,"BLR","NF"
"203","Belgium",2341,"2013-01-01",63055756,0,"BEL","F"
"220","Belize",2342,"2013-01-01",0,0,"BLZ","F"
"234","Benin",2343,"2013-01-01",0,0,"BEN","F"
"251","Bhutan",2344,"2013-01-01",0,0,"BTN","PF"
"266","Bolivia",2345,"2013-01-01",0,0,"BOL","PF"
"272","Botswana",2347,"2013-01-01",315136,0,"BWA","F"
"291","Brazil",2348,"2013-01-01",53333654,22054034,"BRA","F"
"304","Bulgaria",2350,"2013-01-01",407739,0,"BGR","F"
"319","Burkina Faso",2351,"2013-01-01",0,0,"BFA","PF"
"337","Burundi",2352,"2013-01-01",0,0,"BDI","PF"
"342","Cambodia",2353,"2013-01-01",27432,0,"KHM","NF"
"359","Cameroon",2354,"2013-01-01",66150,0,"CMR","NF"
"379","Canada",2355,"2013-01-01",133944212,0,"CAN","F"
"387","Cape Verde",2356,"2013-01-01",16410,0,"CPV","F"
"408","Central African Republic",2357,"2013-01-01",0,0,"CAF","NF"
"418","Chad",2358,"2013-01-01",0,0,"TCD","NF"
"430","Chile",2359,"2013-01-01",22425730,38127,"CHL","F"
"440","China",2360,"2013-01-01",16977662,0,"CHN","NF"
"457","Colombia",2361,"2013-01-01",50292687,7900000,"COL","PF"
"473","Costa Rica",2364,"2013-01-01",2950000,0,"CRI","F"
"494","Croatia",2366,"2013-01-01",561807,0,"HRV","F"
"500","Cuba",2367,"2013-01-01",0,0,"CUB","NF"
"521","Cyprus",2368,"2013-01-01",12790,0,"CYP","F"
"537","Czech Republic",2369,"2013-01-01",10413139,0,"CZE","F"
"547","Denmark",2370,"2013-01-01",27440044,0,"DNK","F"
"556","Djibouti",2371,"2013-01-01",0,0,"DJI","NF"
"571","Dominican Republic",2372,"2013-01-01",0,0,"DOM","F"
"591","Ecuador",2373,"2013-01-01",3417281,0,"ECU","PF"
"603","Egypt",2374,"2013-01-01",13192214,0,"EGY","NF"
"620","El Salvador",2375,"2013-01-01",0,0,"SLV","F"
"628","Equatorial Guinea",2376,"2013-01-01",0,0,"GNQ","NF"
"644","Eritrea",2377,"2013-01-01",0,0,"ERI","NF"
"662","Estonia",2378,"2013-01-01",2851880,0,"EST","F"
"671","Ethiopia",2379,"2013-01-01",195000,0,"ETH","NF"
"684","Fiji",2380,"2013-01-01",0,0,"FJI","PF"
"697","Finland",2381,"2013-01-01",23244674,0,"FIN","F"
"719","France",2382,"2013-01-01",146593634,0,"FRA","F"
"725","Gabon",2383,"2013-01-01",20900,0,"GAB","NF"
"744","Georgia",2385,"2013-01-01",7060,0,"GEO","PF"
"756","Germany",2386,"2013-01-01",0,0,"DEU","F"
"765","Ghana",2387,"2013-01-01",1258937,0,"GHA","F"
"786","Greece",2388,"2013-01-01",13695794,0,"GRC","F"
"796","Guatemala",2389,"2013-01-01",0,0,"GTM","PF"
"810","Guinea",2390,"2013-01-01",0,0,"GIN","PF"
"827","Guinea-Bissau",2391,"2013-01-01",0,0,"GNB","NF"
"841","Guyana",2392,"2013-01-01",0,0,"GUY","F"
"859","Haiti",2393,"2013-01-01",164070,125400,"HTI","PF"
"870","Honduras",2394,"2013-01-01",0,0,"HND","PF"
"884","Hungary",2395,"2013-01-01",20691586,0,"HUN","F"
"903","Iceland",2396,"2013-01-01",130898,0,"ISL","F"
"912","India",2397,"2013-01-01",107765686,24646629,"IND","F"
"928","Indonesia",2398,"2013-01-01",295707513,184097948,"IDN","PF"
"943","Iran",2399,"2013-01-01",0,0,"IRN","NF"
"949","Iraq",2400,"2013-01-01",21348625,5640,"IRQ","NF"
"967","Ireland",2401,"2013-01-01",3538913,0,"IRL","F"
"980","Israel",2402,"2013-01-01",266550442,57495665,"ISR","F"
"1002","Italy",2403,"2013-01-01",135806781,0,"ITA","F"
"1015","Jamaica",2404,"2013-01-01",0,0,"JAM","F"
"1022","Japan",2405,"2013-01-01",20965049,0,"JPN","F"
"1041","Jordan",2406,"2013-01-01",10101955,2543400,"JOR","NF"
"1060","Kazakhstan",2407,"2013-01-01",7976550,0,"KAZ","NF"
"1071","Kenya",2408,"2013-01-01",479560,0,"KEN","PF"
"1091","Kuwait",2411,"2013-01-01",3277553,890,"KWT","PF"
"1103","Kyrgyzstan",2412,"2013-01-01",0,0,"KGZ","PF"
"1118","Latvia",2414,"2013-01-01",7173127,0,"LVA","F"
"1133","Lebanon",2415,"2013-01-01",1764164,66500,"LBN","PF"
"1139","Lesotho",2416,"2013-01-01",3765150,0,"LSO","F"
"1162","Liberia",2417,"2013-01-01",0,0,"LBR","PF"
"1167","Libya",2418,"2013-01-01",5975478,0,"LBY","PF"
"1190","Lithuania",2419,"2013-01-01",2439669,0,"LTU","F"
"1207","Luxembourg",2420,"2013-01-01",6742689,0,"LUX","F"
"1218","Macedonia",2421,"2013-01-01",20005,0,"MKD","PF"
"1233","Madagascar",2422,"2013-01-01",0,0,"MDG","PF"
"1248","Malawi",2423,"2013-01-01",0,0,"MWI","PF"
"1257","Malaysia",2424,"2013-01-01",13471131,44700,"MYS","PF"
"1270","Maldives",2425,"2013-01-01",0,0,"MDV","PF"
"1287","Mali",2426,"2013-01-01",10564428,0,"MLI","PF"
"1298","Malta",2427,"2013-01-01",15606,0,"MLT","F"
"1315","Mauritania",2428,"2013-01-01",0,0,"MRT","NF"
"1330","Mauritius",2429,"2013-01-01",16972,0,"MUS","F"
"1340","Mexico",2430,"2013-01-01",3974784,0,"MEX","PF"
"1360","Moldova",2431,"2013-01-01",521864,0,"MDA","PF"
"1374","Mongolia",2432,"2013-01-01",42751,0,"MNG","F"
"1381","Montenegro",2433,"2013-01-01",0,0,"MNE","F"
"1407","Morocco",2434,"2013-01-01",6348243,0,"MAR","PF"
"1415","Mozambique",2435,"2013-01-01",770374,0,"MOZ","PF"
"1431","Namibia",2437,"2013-01-01",728411,0,"NAM","F"
"1450","Nepal",2438,"2013-01-01",0,0,"NPL","PF"
"1458","Netherlands",2439,"2013-01-01",95116216,0,"NLD","F"
"1469","New Zealand",2440,"2013-01-01",1467372,0,"NZL","F"
"1485","Nicaragua",2441,"2013-01-01",1640000,0,"NIC","PF"
"1499","Niger",2442,"2013-01-01",0,0,"NER","PF"
"1519","Nigeria",2443,"2013-01-01",2482769,0,"NGA","PF"
"1526","Norway",2444,"2013-01-01",79435998,0,"NOR","F"
"1545","Oman",2445,"2013-01-01",24563658,5015735,"OMN","NF"
"1554","Pakistan",2446,"2013-01-01",46666107,20109601,"PAK","PF"
"1572","Panama",2447,"2013-01-01",0,0,"PAN","F"
"1583","Papua New Guinea",2448,"2013-01-01",0,0,"PNG","PF"
"1601","Paraguay",2449,"2013-01-01",32590,0,"PRY","PF"
"1621","Peru",2450,"2013-01-01",12227093,4474000,"PER","F"
"1631","Philippines",2451,"2013-01-01",471378,0,"PHL","PF"
"1650","Poland",2452,"2013-01-01",42800602,0,"POL","F"
"1658","Portugal",2453,"2013-01-01",7732350,0,"PRT","F"
"1665","Qatar",2455,"2013-01-01",673377690,0,"QAT","NF"
"1679","Romania",2456,"2013-01-01",660115,0,"ROU","F"
"1698","Rwanda",2458,"2013-01-01",0,0,"RWA","NF"
"1715","Saudi Arabia",2459,"2013-01-01",361024681,46452100,"SAU","NF"
"1731","Senegal",2460,"2013-01-01",179000,0,"SEN","F"
"1750","Serbia",2461,"2013-01-01",228461,10300,"SRB","F"
"1758","Seychelles",2462,"2013-01-01",37540,0,"SYC","PF"
"1776","Sierra Leone",2463,"2013-01-01",47800,0,"SLE","PF"
"1789","Singapore",2464,"2013-01-01",205997631,52547964,"SGP","PF"
"1808","Slovakia",2465,"2013-01-01",327114,0,"SVK","F"
"1819","Slovenia",2466,"2013-01-01",91256,0,"SVN","F"
"1837","Somalia",2467,"2013-01-01",722478,0,"SOM","NF"
"1852","South Africa",2468,"2013-01-01",14088327,768750,"ZAF","F"
"1868","Spain",2469,"2013-01-01",120707255,0,"ESP","F"
"1872","Sri Lanka",2470,"2013-01-01",9843,0,"LKA","PF"
"1888","Sudan",2471,"2013-01-01",586071,0,"SDN","NF"
"1899","Suriname",2472,"2013-01-01",0,0,"SUR","F"
"1916","Swaziland",2473,"2013-01-01",0,0,"SWZ","NF"
"1927","Sweden",2474,"2013-01-01",91336087,0,"SWE","F"
"1943","Switzerland",2475,"2013-01-01",105167896,0,"CHE","F"
"1956","Taiwan",2477,"2013-01-01",14982725,0,"TWN","F"
"1982","Tajikistan",2478,"2013-01-01",575000,0,"TJK","NF"
"1995","Tanzania",2479,"2013-01-01",209151,0,"TZA","PF"
"2010","Thailand",2480,"2013-01-01",32497937,8e+05,"THA","PF"
"2015","Togo",2481,"2013-01-01",262800,0,"TGO","PF"
"2030","Tunisia",2483,"2013-01-01",362985,0,"TUN","PF"
"2043","Turkey",2484,"2013-01-01",84095484,0,"TUR","PF"
"2060","Turkmenistan",2485,"2013-01-01",39317453,0,"TKM","NF"
"2077","Uganda",2486,"2013-01-01",195000,0,"UGA","PF"
"2090","Ukraine",2487,"2013-01-01",4819412,0,"UKR","PF"
"2102","United Arab Emirates",2488,"2013-01-01",128650220,1448524,"ARE","NF"
"2126","United Kingdom",2489,"2013-01-01",257826013,0,"GBR","F"
"2129","United States",2490,"2013-01-01",610685905,0,"USA","F"
"2155","Uruguay",2491,"2013-01-01",45024,0,"URY","F"
"2166","Uzbekistan",2492,"2013-01-01",0,0,"UZB","NF"
"2185","Venezuela",2493,"2013-01-01",194846,0,"VEN","PF"
"2196","Yemen",2495,"2013-01-01",446077,0,"YEM","NF"
"2213","Zambia",2496,"2013-01-01",118376,0,"ZMB","PF"
"2224","Zimbabwe",2497,"2013-01-01",0,0,"ZWE","NF"
3 changes: 3 additions & 0 deletions source/data/freedom_index_exports.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"","time","sum","free","partial_free","not_free"
"1","all",13932419790,10154110270,2631664267,1146645253
"2","2013",458323549,109487505,265693003,83143041
11 changes: 7 additions & 4 deletions source/javascripts/components/d3graph.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@ class @D3Graph
.append("g")
.attr("transform", "translate(" + @options.margin.left + "," + @options.margin.top + ")")

@svgSelection.append("g")
.attr("class", "x axis")
.attr("transform", "translate(0," + @options.height + ")")
.call(@xAxis)

createAxisAndScales: (data) ->
@yScale = d3.scale.linear()
Expand All @@ -28,6 +24,12 @@ class @D3Graph
.scale(@xAxisScale)
.orient("bottom")

appendAxis: ->
@svgSelection.append("g")
.attr("class", "x axis")
.attr("transform", "translate(0," + @options.height + ")")
.call(@xAxis)

setXDomain: (domain) ->
@xScaleDomain = domain

Expand All @@ -42,6 +44,7 @@ class @D3Graph
render: (@element) ->
@createAxisAndScales(@data)
@createSvg()
@appendAxis()
@draw(@data)

update: (@data) ->
Expand Down
60 changes: 60 additions & 0 deletions source/javascripts/components/large_multiples.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
class @LargeMultiples extends @D3Graph
constructor: (@data, @options = {}) ->
@options = _.defaults(@options, {
width: 900
height: 350
margin:
{
top: 40
right: 30
bottom: 10
left: 40
}
circles: {
radius: 12
padding: 10
}
})
@value1Key = "key1"
@value2Key = "key2"
@valueClass1 = "value-1"
@valueClass2 = "value-2"

setValueKeys: (value1, value2) ->
@value1Key = value1
@value2Key = value2

setValueClasses: (valueClasses) ->
@valueClasses = valueClasses

valueClasss: (d,i) =>
for value in @valueClasses
if i in value.range
className = value.className
className

draw: (data) ->
data = (data[0] for num in [data[0][@value1Key]..1])
teiler = Math.floor(@options.width/(2*@options.circles.radius + @options.circles.padding))
graphGroup = @svgSelection.selectAll('g.multiples').data(data)
graphGroup.enter().append("g")
graphGroup
.attr("class", "multiples")
.attr("transform", (d,i) =>
translateX = (i % teiler)*(2*@options.circles.radius+@options.circles.padding)
translateY = @options.height - (Math.ceil((i+1) / teiler)*(@options.circles.padding+2*@options.circles.radius))
"translate(#{translateX},#{translateY})"
)
graphGroup.selectAll("circle").remove()
graphGroup
.append("circle")
.attr("r",@options.circles.radius)
.attr("class",@valueClasss)
graphGroup.exit().remove()

render: (@element) ->
@createSvg()
@draw(@data)

update: (@data) ->
@draw(@data)
3 changes: 3 additions & 0 deletions source/javascripts/helpers.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@magnitude = (n) ->
order = Math.floor(Math.log(n) / Math.LN10)
Math.pow(10,order)
61 changes: 61 additions & 0 deletions source/javascripts/sicherheit/freedom-export.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
formatCurrency = d3.numberFormat(",")

getNumberReducedByMagnitude = (number, magnitude) ->
Math.round(number/magnitude)

generateDataForLargeMultipleFreeNotFreeRuestung = (data, year, multiplokator=15) ->
freedomIndexObject = _.findWhere(data, { time: year })
freeNotFreeArray = [parseInt(freedomIndexObject.not_free), parseInt(freedomIndexObject.sum), parseInt(freedomIndexObject.partial_free), parseInt(freedomIndexObject.free)]
magnitudeFreeNotFree = magnitude(d3.min(freeNotFreeArray))
freedomIndexObject.not_free = getNumberReducedByMagnitude(freedomIndexObject.not_free, magnitudeFreeNotFree)*multiplokator
freedomIndexObject.sum = getNumberReducedByMagnitude(freedomIndexObject.sum, magnitudeFreeNotFree)*multiplokator
freedomIndexObject.free = getNumberReducedByMagnitude(freedomIndexObject.free, magnitudeFreeNotFree)*multiplokator
freedomIndexObject.partial_free = getNumberReducedByMagnitude(freedomIndexObject.partial_free, magnitudeFreeNotFree)*multiplokator
freedomIndexObject

valueClassesForData = (data) ->
[
{
range: [0...data.free]
className: "free"
},
{
range: [data.free...(data.free+data.partial_free)]
className: "partial-free"
},
{
range: [(data.free+data.partial_free)...data.sum]
className: "not-free"
}
]

@drawFreedomIndexPointVisualization = (data) ->
sumAllTime= _.findWhere(data, { time: "all" }).sum
sum2013 = _.findWhere(data, { time: "2013" }).sum
generateDataForLargeMultipleFreeNotFreeRuestung(data, "all", 15)
multiplesData = generateDataForLargeMultipleFreeNotFreeRuestung(data, "2013", 5)
multipleOptions = { height: 100, circles: { radius: 8, padding: 5 } }
largeMultiple = new @LargeMultiples([multiplesData], multipleOptions)
largeMultiple.setValueKeys("sum","free")

largeMultiple.setValueClasses(valueClassesForData(multiplesData))
largeMultiple.render("#multiples #multiple-exports")
$('.export-volumes h2').text("$#{formatCurrency(sum2013)}")

$('#multiples form input').change (e) ->
if(this.value == 'all')
multiplesData = _.findWhere(data, { time: 'all' })
largeMultiple.setValueClasses(valueClassesForData(multiplesData))
largeMultiple.update([multiplesData])
$('.export-volumes h2').text("$#{formatCurrency(sumAllTime)}")
else
multiplesData = _.findWhere(data, { time: '2013' })
largeMultiple.setValueClasses(valueClassesForData(multiplesData))
largeMultiple.update([multiplesData])
$('.export-volumes h2').text("$#{formatCurrency(sum2013)}")

$ ->
if $('#freedom-index').length > 0
freedomIndexExportsPath = rootPath+"/data/freedom_index_exports.csv"
d3.csv freedomIndexExportsPath, (data) ->
@drawFreedomIndexPointVisualization(data)
44 changes: 44 additions & 0 deletions source/sicherheit/ruestung/freedom-index.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
---
title: Entwicklungsbarometer - Freedom Index
---
#sicherheit.indikator.sub-indikator
= link_to "/sicherheit/index.html" do
%h1.sicherheit Sicherheit
#freedom-index
.navbar
%ul.nav
%li
= link_to "/sicherheit/ruestung/index.html" do
%h4 Schädliche Waffenexporte
%li
%h4 Deutsche Waffenexporte im Detail
%li
%h4 Anteil Waffenhandel am GDP
%li.active
= link_to "/sicherheit/ruestung/freedom-index.html" do
%h4 Anteil kritische Waffenexporte am GDP
#multiples
.multiple
#multiple-exports
.legend
%svg
%g(transform="translate(0,8)")
%circle.free(r=8 cx=8 cy=0)
%text(dx=24 dy=5) Exporte in Freie Länder
%g(transform="translate(0,32)")
%circle.partial-free(r=8 cy=0 cx=8)
%text(dx=24 dy=5) Exporte in Halb-Länder
%g(transform="translate(0,56)")
%circle.not-free(r=8 cx=8 cy=0)
%text(dx=24 dy=5) Exporte in Nicht-Freie Länder
.export-volumes
%h2
%h6 Zeitraum
%form
%input(type="radio" name="ruestung-chart" value="2013" checked="checked") 2013
%input(type="radio" name="ruestung-chart" value="all") 1999-2013
%h2 Anteil kritische Waffenexporte am GDP
.explanation
%p Waffenexporte deutscher Unternehmen sind immer wieder Gegenstand öffentlicher Diskussionen. Insbesondere die Exporte von Waffen in Krisenländer oder in Länder mit autoritären Regimen wird in der Öffentlichkeit kritisiert. Überlegungen der Bundesregierung zu einer restriktiveren Lizenzpraxis bei Waffenexporten werden in der Wirtschaft oft mit dem Hinweis auf Arbeitsplätze und den Wirtschaftsstandort Deutschland zurückgewiesen. Diese Visualisierung zeigt, dass eine Einschränkung der Waffenexporte auf unkritische Länder nur einen geringen Einfluss auf die Waffenexporte der deutschen Wirtschaft insgesamt hat.
.explanation
%p Die Daten zu den Waffenexporten deutscher Unternehmen stammen vom Bonn International Center for Conversion. Die Einteilung der Empfängerländer nach frei, halb-frei und nicht-frei wurde vom Freedom in the World Index vom Freedom House übernommen. dieser Index bewertet die Einhaltung von politischen und bürgerlichen Rechten in Anlehnung an die Menschenrechtserklärung der Vereinten Nationen von 1948.
6 changes: 5 additions & 1 deletion source/sicherheit/ruestung/index.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,15 @@ title: Entwicklungsbarometer - Rüstung
.navbar
%ul.nav
%li.active
%h4 Schädliche Waffenexporte
= link_to "/sicherheit/ruestung/index.html" do
%h4 Schädliche Waffenexporte
%li
%h4 Deutsche Waffenexporte im Detail
%li
%h4 Anteil Waffenhandel am GDP
%li
= link_to "/sicherheit/ruestung/freedom-index.html" do
%h4 Anteil kritische Waffenexporte am GDP
.exports-percent-gdp.barchart
%h2 Schädliche Waffenexporte
.explanation
Expand Down
2 changes: 1 addition & 1 deletion source/stylesheets/components/_sub-indikator.sass
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
li
float: left
padding: 0.5em
margin: 0 0.5em
margin: 0.5em
background: $light-blue
&.active
background: none
Expand Down
Loading

0 comments on commit c7d2cd0

Please sign in to comment.