Skip to content

Instantly share code, notes, and snippets.

@borgar
Last active February 24, 2017 12:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save borgar/77211dead0b912d5dded1dfef5d81a3a to your computer and use it in GitHub Desktop.
Save borgar/77211dead0b912d5dded1dfef5d81a3a to your computer and use it in GitHub Desktop.
Decreed salaries
license: mit
height: 500
border: no

Every so often the President of Iceland's salary needs reviewing. This elected official doesn't get a salary interview with his boss, the nation, nor does he have the legal refuge to go on strike. Instead there is an independent institution that decrees the fate of the President's personal bank account.

Because inflation is high in Iceland, pay-rises are frequently needed to adjust for this. So it seems to many that the fine folk who govern the land keep rising in pay while the little people stay in place. But, if we adjust for inflation, are they really ascending disproportionally?

The chart shows the salaries of the President of Iceland, the members of Parliament, the Prime Minister, and other Cabinet minsters. Adjusting for inflation and after tax.

date Þingmenn Ráðherrar Forsætisráðherra Forseti Íslands Vísitala Neysluverðs
2006-07 485570 871441 966182 1619700 263.1
2006-10 503051 902813 1000965 1678025 266.2
2007-01 517639 928994 1029993 1727002 266.9
2007-07 531098 953148 1021036 1771501 273
2008-01 541720 972211 1077908 1806843 282.3
2008-05 562020 992511 1098208 1827143 304.4
2009-01 520000 855000 935000 1827143 334.8
2011-06 545480 896895 980815 1916673 379.9
2011-10 589559 1041144 1152020 1916673 384.6
2012-03 610193 1077584 1192341 1983757 395.1
2013-03 630024 1112606 1231092 2048229 410.7
2014-02 651445 1150434 1272949 2117868 418.7
2015-03 712030 1257425 1391333 2314830 426.4
2016-06 766500 1347456 1490952 2480340 433.7
2016-10 1101194 1826273 2021825 2985000 436.4
<!DOCTYPE html>
<meta charset="utf-8">
<style>
body {
font: 12px sans-serif;
}
.axis path {
shape-rendering: crispEdges;
}
.axis path {
fill: none;
}
.axis line {
stroke: #aaa;
}
.y.axis line {
stroke-dasharray: 2 2;
}
.axis .tick text {
font: 12px sans-serif;
}
.x.axis path {
display: none;
}
.dot {
stroke : white;
stroke-width: 1.2px;
}
.line {
fill: none;
stroke: steelblue;
stroke-width: 2px;
}
</style>
<body>
<script src="//d3js.org/d3.v3.min.js"></script>
<script src="taxes.js"></script>
<script>
var series = [
{ 'color':"#60BD68", 'name':"Þingmenn", 'values':[] },
{ 'color':"#FAA43A", 'name':"Ráðherrar", 'values':[] },
{ 'color':"#5DA5DA", 'name':"Forsætisráðherra", 'values':[] },
{ 'color':"#4D4D4D", 'name':"Forseti Íslands", 'values':[] }
];
var inflation = "Vísitala Neysluverðs";
var numfmt = d3.format(",.0f");
var margin = {top: 20, right: 120, bottom: 30, left: 95},
width = 960 - margin.left - margin.right,
height = 500 - margin.top - margin.bottom;
var x = d3.time.scale()
.range([5, width]);
var y = d3.scale.linear()
.range([height, 0]);
var xAxis = d3.svg.axis()
.scale(x)
.orient("bottom");
var yAxis = d3.svg.axis()
.scale(y)
.tickSize(-width)
.tickFormat(d => numfmt(d).replace(/,/g, '.'))
.orient("left");
var line = d3.svg.line()
.x(d => x(d.date))
.y(d => y(d.value));
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]+")");
d3.csv("data.csv", ( err, data ) => {
if (err) throw err;
// parse and convert to series
data.forEach(function ( d ) {
var date = new Date(Date.parse(d.date)),
inflation_l = +data[data.length - 1][inflation],
inflation_c = +d[inflation],
devalue = inflation_c / inflation_l;
series.forEach(s => {
var brutto = ~~(+d[s.name] / devalue);
s.values.push({
'date': date,
'amount': +d[s.name],
'value': pay_taxes(brutto, date),
'series': s,
});
});
});
x.domain(d3.extent(series[0].values, d => d.date));
y.domain([
d3.min(series, c => d3.min(c.values, v => v.value)),
d3.max(series, c => d3.max(c.values, v => v.value))
]).nice();
svg.append("g")
.attr("class", "x axis")
.attr("transform", "translate(0," + height + ")")
.call(xAxis);
svg.append("g")
.attr("class", "y axis")
.call(yAxis)
.selectAll('.tick text')
.attr('x', -8)
svg.append("text")
.attr("transform", `translate(-85,${height / 2}) rotate(-90)`)
.attr("dy", ".71em")
.style("text-anchor", "middle")
.text("Laun eftir skatt á verðlagi ársins "+
x.domain()[1].getUTCFullYear() +" (kr.)");
var job = svg.selectAll(".job")
.data(series)
.enter().append("g")
.attr("class", "job");
job.append("path")
.attr("class", "line")
.attr("d", d => line(d.values))
.style("stroke", d => d.color);
job.selectAll(".dot")
.data(p => p.values).enter()
.append('path')
.attr("class", "dot")
.attr("transform", d => "translate("+[x(d.date), y(d.value)]+")")
.attr("d", d3.svg.symbol().size(32))
.style("fill", d => d.series.color);
job.append("text")
.datum(d => d.values[d.values.length - 1])
.attr("transform", d => "translate("+[x(d.date), y(d.value)]+")")
.style('font', '12px sans-serif')
.attr("x", 10)
.attr("dy", ".35em")
.text(d => d.series.name);
});
</script>
function percent ( n ) { return n / 100; }
function Dt ( y, m, d ) {
return new Date(Date.UTC(y, m, d));
}
var tax_history = [
{ timebase: Dt( 2006, 0, 1 )
, steps: [ [ Infinity, 36.72 ] ]
, discount: 29029
},
{ timebase: Dt( 2007, 0, 1 )
, steps: [ [ Infinity, 35.72 ] ]
, discount: 32150
},
{ timebase: Dt( 2008, 0, 1 )
, steps: [ [ Infinity, 35.72 ] ]
, discount: 34034
},
{ timebase: Dt( 2009, 0, 1 )
, steps: [ [ Infinity, 37.2 ] ]
, discount: 42205
},
{ timebase: Dt( 2010, 0, 1 )
, steps: [
[ 200000, 37.22 ],
[ 650000, 40.12 ],
[ Infinity, 46.12 ]]
, discount: 44205
},
{ timebase: Dt( 2011, 0, 1 )
, steps: [
[ 209400, 37.31 ],
[ 680550, 40.21 ],
[ Infinity, 46.21 ]]
, discount: 44205
},
{ timebase: Dt( 2012, 0, 1 )
, steps: [
[ 230000, 37.34 ],
[ 704366, 40.24 ],
[ Infinity, 46.24 ]]
, discount: 46532
},
{ timebase: Dt( 2013, 0, 1 )
, steps: [
[ 241475, 37.32 ],
[ 739509, 40.22 ],
[ Infinity, 46.22 ]]
, discount: 48485
},
{ timebase: Dt( 2014, 0, 1 )
, steps: [
[ 290000, 37.30 ],
[ 784619, 39.74 ],
[ Infinity, 46.24 ]]
, discount: 50498
},
{ timebase: Dt( 2015, 0, 1 )
, steps: [
[ 309140, 37.30 ],
[ 527264, 39.74 ],
[ Infinity, 46.24 ]]
, discount: 50902
},
{ timebase: Dt( 2016, 0, 1 )
, steps: [
[ 336035, 37.13 ],
[ 836990, 38.35 ],
[ Infinity, 46.25 ]]
, discount: 51920
}
];
function calc_taxes ( brutto, date, _debug ) {
if ( !date ) { date = new Date(); }
if ( typeof date === 'number' ) { date = Dt( date, 0, 1 ); }
// tax_year
var tax_year = date.getUTCFullYear();
var tax_settings = tax_history.filter(function ( d ) {
return d.timebase.getUTCFullYear() === tax_year;
})[ 0 ];
if ( !tax_settings ) {
throw new Error( 'No tax-rules for year ' + tax_year );
}
// finna tekjustofn:
var pension_amt = brutto * percent(4);
var taxable_amt = brutto - pension_amt;
_debug && console.info( 'tekjuskattsstofn', taxable_amt );
var taxed = 0;
var taxes_due = 0;
var steps = tax_settings.steps;
var tax_discount = tax_settings.discount;
var row = {
brutto: brutto
, taxable: taxable_amt
, taxes: 0
, netto: 0
, steps: 0
, discount: tax_discount
};
row.steps = steps.map(function ( r, i ) {
var step_high = r[0]
, step_tax = percent( r[1] )
, step_amt = 0
, step_base = 0
;
if ( taxed < taxable_amt ) {
var remainder = taxable_amt - taxed;
step_base = ( remainder > step_high )
? step_high
: remainder
;
step_amt = Math.round( step_base * step_tax ); // rounding?
taxed += step_base;
taxes_due += step_amt;
}
_debug && console.info( 'step', i+1, step_amt, 'from a tax base of', step_base );
return [ step_base, step_amt, step_tax ];
});
row.year = tax_year;
row.taxes = taxes_due - tax_discount;
row.netto = taxable_amt - row.taxes;
_debug && console.info( 'total taxes', taxes_due );
_debug && console.info( 'discounted', -tax_discount );
_debug && console.info( 'taxes due', taxes_due - tax_discount );
return row;
}
function pay_taxes ( /* dynamic */ ) {
var r = calc_taxes.apply( null, arguments );
return Math.round( r.netto );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment