Skip to content

Instantly share code, notes, and snippets.

@ndarville
Last active December 29, 2015 13:49
Show Gist options
  • Save ndarville/7680028 to your computer and use it in GitHub Desktop.
Save ndarville/7680028 to your computer and use it in GitHub Desktop.
Finanslov 2014
name 2012 2013 2014 2015 2016 2017
01 Dronningen 76.1 72.1 72.3 72.3 72.3 72.3
02 Medlemmer af det kongelige hus mfl 25.8 24.7 24.8 24.8 24.8 24.8
03 Folketinget 1019.5 1023.5 1013.7 1014.3 1013.8 1013.8
05 Statsministeriet 141.8 141.0 141.4 140.3 139.3 138.2
06 Udenrigsministeriet 14821.6 15391.6 15715.6 15654.5 15604.5 15571.3
07 Finansministeriet 24346.8 21399.9 22163.5 21232.2 21728.7 20924.5
08 Erhvervs- og Vækstministeriet 5213.6 -499.6 -726.6 -232.4 -1397.6 -1780.2
09 Skatteministeriet 4339.2 4317.2 3928.7 3886.2 3753.0 3601.0
10 Økonomi- og Indenrigsministeriet 205766.1 195858.8 197516.2 200283.0 198311.4 198382.2
11 Justitsministeriet 15329.1 15289.6 15226.8 14860.0 14570.7 14201.8
12 Forsvarsministeriet 23108.2 23114.0 22481.7 21190.9 20984.2 20868.7
14 Ministeriet for By. Bolig og Landdistrikter 124.4 2048.7 2321.0 2232.6 1983.5 1966.4
15 Social- og Integrationsministeriet 136176.8 143841.2 148845.0 150350.5 152471.9 154189.5
16 Ministeriet for Sundhed og Forebyggelse 6509.5 5106.9 4766.6 2314.5 2093.5 2053.8
17 Beskæftigelsesministeriet 85360.9 57058.9 54861.6 52561.0 49461.9 46777.6
19 Udddannelsesministeriet 44631.9 46189.7 48711.5 49508.2 50187.2 49355.9
20 Ministeriet for Børn og Undervisning 29252.9 30068.2 30392.7 30192.0 29900.2 29272.6
21 Kulturministeriet 6422.9 6440.8 6455.3 6431.8 6347.2 6322.4
22 Ministeriet for Ligestilling og Kirke 605.7 611.3 607.3 574.4 572.4 571.5
23 Miljøministeriet 1940.5 1861.4 1882.3 1854.6 1804.9 1720.6
24 Fødevareministeriet 2859.0 2535.1 2883.4 2837.7 2718.2 2669.9
28 Transportministeriet 19005.0 21255.5 22250.9 18459.3 16311.0 17927.5
29 Klima-. Energi- og Bygningsministeriet -4248.0 -588.6 638.3 416.7 345.0 275.3
35 Generelle reserver 9676.4 11359.8 14928.5 14784.3 15489.4 16259.5
36 Pensionsvæsenet 21299.7 22057.8 22732.2 22918.0 23039.9 23097.3
37 Renter 20510.6 21785.7 23032.4 0.0 0.0 0.0
38 Skatter og afgifter -599104.6 -632151.8 -632652.8 0.0 0.0 0.0
40 Genudlån mv 7733.8 17823.4 -13002.4 0.0 0.0 0.0
41 Beholdningsbevægelser mv -1807.8 2622.9 4510.3 0.0 0.0 0.0
42 Afdrag på statsgælden (netto) -81620.1 -37954.7 -22659.6 0.0 0.0 0.0
<!DOCTYPE html>
<meta charset="utf-8">
<style>
svg {
display: block;
margin-left: auto;
margin-right: auto;
}
.bar.positive {
fill: steelblue;
}
.bar.negative {
fill: brown;
}
rect.bar:hover {
fill: orange;
}
.axis text {
font: 10px sans-serif;
}
.axis path,
.axis line {
fill: none;
stroke: #000;
shape-rendering: crispEdges;
}
.d3-tip {
line-height: 1;
font-weight: bold;
padding: 12px;
background: rgba(0, 0, 0, 0.8);
color: #fff;
border-radius: 2px;
}
/* Creates a small triangle extender for the tooltip */
.d3-tip:after {
box-sizing: border-box;
display: inline;
font-size: 10px;
width: 100%;
line-height: 1;
color: rgba(0, 0, 0, 0.8);
content: "\25BC";
position: absolute;
text-align: center;
}
/* Style northward tooltips differently */
.d3-tip.n:after {
margin: -1px 0 0 0;
top: 100%;
left: 0;
}
</style>
<body>
<script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script>
<script src="http://labratrevenge.com/d3-tip/javascripts/d3.tip.min.js"></script>
<script charset="utf-8">
// Config
var beforeValue = "2013",
afterValue = "2014";
var displayValue = "percent", // "percent", "absolute"
showLabels = true, // true, false
filterValue = 10; // 0-100
var margin = {top: 30, right: 10, bottom: 10, left: 10};
if (showLabels === true) { margin.left = 225; }
if (displayValue !== "percent") { margin.right = 35; }
width = 720 - margin.left - margin.right,
height = 500 - margin.top - margin.bottom;
var x = d3.scale.linear()
.range([0, width])
var y = d3.scale.ordinal()
.rangeRoundBands([0, height], .2);
var xAxis = d3.svg.axis()
.scale(x)
.tickFormat(function(d) {
return (displayValue === "percent") ? d+"%" : d;
})
.orient("top");
if (showLabels === true) {
var yAxis = d3.svg.axis()
.scale(y)
.orient("left");
}
var tip = d3.tip()
.attr('class', 'd3-tip')
.offset([-10, 0])
.html(function(d) {
return "<strong>" + d.name + ":</strong> <span style='color:red'>" + Math.round(d.value) + ((displayValue === "percent") ? "%" : "") + "</span>";
})
var svg = d3.select("body").append("svg")
.attr("width", width + margin.left + margin.right)
.attr("height", height + margin.top + margin.bottom)
.append("g")
.attr("transform", "translate(" + margin.left + "," + margin.top + ")");
svg.call(tip);
d3.csv("data.csv", type, function(error, data) {
x.domain(d3.extent(data, function(d) { return d.value; })).nice();
y.domain(data.filter(function(d) { return d.value > filterValue || d.value < -filterValue; }).map(function(d) { return d.name; }));
svg.selectAll(".bar")
.data(data.filter(function(d) { return d.value > filterValue || d.value < -filterValue; }))
.enter().append("rect")
.attr("class", function(d) { return d.value < 0 ? "bar negative" : "bar positive"; })
.attr("x", function(d) { return x(Math.min(0, d.value)); })
.attr("y", function(d) { return y(d.name); })
.attr("width", function(d) { return Math.abs(x(d.value) - x(0)); })
.attr("height", y.rangeBand())
.on('mouseover', tip.show)
.on('mouseout', tip.hide);
svg.append("g")
.attr("class", "x axis")
.call(xAxis);
svg.append("g")
.attr("class", "y axis")
.append("line")
.attr("x1", x(0))
.attr("x2", x(0))
.attr("y2", height);
if (showLabels === true) {
svg.append("g")
.attr("class", "y axis")
.call(yAxis)
.append("text")
.attr({
"transform": "rotate(-90)",
"y": 6,
"dy": ".71em"
})
.style("text-anchor", "end")
.text("");
}
});
function type(d) {
if (displayValue === "percent") {
d.value = (parseFloat(d[beforeValue]) - parseFloat(d[afterValue]));
d.value = d.value/parseFloat(d[beforeValue])*100;
} else {
d.value = (parseFloat(d[beforeValue]) - parseFloat(d[afterValue]));
}
return d;
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment