Created
July 8, 2013 08:23
d3 streamgraph
This file contains 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
Jahr | Braunkohle | Steinkohle | Mineralöl | Erdgas | Kernenergie | Erneuerbare | Sonstige | |
---|---|---|---|---|---|---|---|---|
1950 | 66.943 | 103.267 | 6.302 | 0.086 | 0.000 | 6.427 | 3.594 | |
1951 | 70.869 | 116.207 | 7.194 | 0.106 | 0.000 | 6.289 | 3.319 | |
1952 | 74.245 | 123.606 | 8.018 | 0.132 | 0.000 | 6.485 | 3.019 | |
1953 | 77.897 | 119.466 | 9.769 | 0.166 | 0.000 | 5.787 | 2.783 | |
1954 | 82.505 | 125.942 | 12.711 | 0.231 | 0.000 | 6.373 | 2.830 | |
1955 | 86.482 | 137.506 | 16.389 | 0.423 | 0.000 | 6.502 | 2.569 | |
1956 | 89.947 | 144.192 | 21.008 | 0.614 | 0.000 | 6.659 | 2.346 | |
1957 | 93.149 | 143.643 | 22.998 | 0.639 | 0.000 | 6.026 | 2.316 | |
1958 | 95.467 | 131.548 | 29.776 | 0.669 | 0.000 | 6.850 | 2.094 | |
1959 | 97.393 | 128.954 | 37.388 | 0.786 | 0.000 | 5.995 | 2.250 | |
1960 | 100.802 | 135.799 | 46.791 | 0.920 | 0.000 | 7.216 | 1.796 | |
1961 | 101.697 | 131.168 | 57.012 | 1.074 | 0.027 | 7.055 | 1.554 | |
1962 | 103.817 | 133.273 | 70.939 | 1.338 | 0.073 | 6.208 | 1.600 | |
1963 | 106.294 | 135.268 | 85.963 | 1.809 | 0.075 | 5.730 | 1.700 | |
1964 | 107.472 | 130.537 | 99.629 | 2.627 | 0.111 | 4.932 | 1.825 | |
1965 | 105.244 | 123.510 | 115.220 | 3.604 | 0.135 | 7.134 | 1.794 | |
1966 | 104.033 | 111.619 | 130.255 | 4.344 | 0.207 | 8.604 | 1.777 | |
1967 | 103.662 | 106.402 | 136.761 | 5.754 | 0.564 | 8.164 | 1.647 | |
1968 | 105.491 | 108.160 | 153.125 | 9.463 | 0.767 | 8.044 | 1.658 | |
1969 | 107.137 | 112.167 | 172.386 | 13.373 | 1.878 | 6.781 | 1.555 | |
1970 | 108.840 | 107.188 | 192.858 | 18.773 | 2.312 | 8.748 | 2.110 | |
1971 | 106.085 | 100.227 | 200.805 | 24.945 | 2.190 | 6.744 | 2.289 | |
1972 | 106.316 | 93.287 | 213.459 | 32.410 | 3.275 | 8.627 | 2.365 | |
1973 | 107.820 | 93.970 | 227.780 | 42.040 | 4.050 | 8.860 | 2.310 | |
1974 | 107.600 | 91.700 | 208.170 | 52.790 | 5.030 | 8.010 | 2.330 | |
1975 | 108.450 | 74.751 | 202.243 | 56.008 | 8.201 | 8.148 | 2.299 | |
1976 | 112.850 | 78.790 | 218.610 | 59.100 | 10.070 | 4.710 | 2.430 | |
1977 | 111.590 | 75.030 | 218.110 | 62.390 | 13.980 | 7.600 | 2.420 | |
1978 | 112.590 | 77.310 | 228.550 | 68.030 | 15.090 | 7.010 | 2.550 | |
1979 | 114.290 | 84.890 | 231.720 | 74.150 | 17.980 | 6.450 | 2.590 | |
1980 | 115.640 | 85.221 | 206.715 | 73.903 | 19.228 | 8.253 | 2.902 | |
1981 | 118.910 | 84.480 | 187.735 | 70.600 | 22.547 | 9.367 | 3.262 | |
1982 | 118.488 | 82.615 | 177.067 | 65.542 | 25.303 | 8.631 | 3.529 | |
1983 | 119.916 | 82.617 | 174.352 | 68.124 | 26.485 | 9.608 | 3.884 | |
1984 | 125.084 | 84.180 | 171.497 | 71.150 | 35.035 | 6.998 | 4.443 | |
1985 | 125.814 | 85.685 | 174.518 | 70.306 | 46.194 | 6.018 | 4.484 | |
1986 | 123.526 | 83.870 | 181.943 | 71.236 | 43.020 | 7.578 | 4.357 | |
1987 | 121.737 | 82.562 | 180.748 | 77.137 | 46.538 | 8.725 | 4.486 | |
1988 | 120.676 | 80.591 | 180.696 | 74.798 | 51.570 | 6.729 | 4.878 | |
1989 | 120.211 | 78.699 | 171.075 | 77.491 | 53.010 | 5.792 | 4.824 | |
1990 | 109.208 | 78.686 | 178.002 | 78.231 | 56.897 | 6.692 | 0.852 | |
1991 | 85.539 | 79.499 | 188.504 | 82.199 | 54.888 | 6.728 | 1.134 | |
1992 | 74.255 | 74.923 | 191.482 | 81.271 | 59.132 | 7.065 | 0.460 | |
1993 | 67.649 | 72.971 | 195.558 | 85.996 | 57.148 | 7.769 | 1.140 | |
1994 | 63.506 | 73.013 | 193.836 | 87.571 | 56.304 | 8.619 | 1.153 | |
1995 | 59.181 | 70.275 | 194.111 | 95.487 | 57.387 | 9.373 | 1.053 | |
1996 | 57.591 | 71.308 | 198.184 | 106.853 | 60.189 | 9.206 | -0.192 | |
1997 | 54.436 | 70.460 | 196.301 | 102.078 | 63.431 | 11.753 | 0.174 | |
1998 | 51.658 | 70.253 | 197.053 | 103.014 | 60.201 | 12.938 | 0.331 | |
1999 | 50.252 | 67.124 | 191.027 | 102.712 | 63.310 | 13.764 | 0.530 | |
2000 | 52.889 | 68.970 | 187.616 | 101.860 | 63.162 | 14.214 | 2.654 | |
2001 | 55.719 | 66.489 | 190.292 | 107.416 | 63.746 | 14.748 | 2.432 | |
2002 | 56.741 | 65.741 | 183.617 | 107.250 | 61.353 | 15.541 | 2.034 | |
2003 | 55.932 | 68.573 | 180.373 | 108.550 | 61.439 | 19.136 | 4.154 | |
2004 | 56.228 | 65.141 | 177.908 | 109.101 | 62.183 | 22.182 | 5.126 | |
2005 | 54.448 | 61.675 | 176.257 | 110.169 | 60.686 | 26.251 | 6.531 | |
2006 | 53.759 | 67.022 | 174.724 | 111.273 | 62.293 | 32.027 | 3.414 | |
2007 | 55.029 | 68.823 | 157.840 | 106.510 | 52.310 | 38.097 | 3.433 | |
2008 | 53.035 | 61.422 | 167.312 | 104.352 | 55.378 | 39.136 | 4.430 | |
2009 | 51.423 | 51.056 | 158.160 | 100.206 | 50.224 | 40.979 | 6.137 | |
2010 | 51.522 | 57.800 | 161.287 | 104.511 | 52.272 | 45.039 | 7.199 | |
2011 | 53.300 | 55.300 | 154.800 | 95.800 | 40.200 | 50.000 | 8.200 | |
2012 | 56.000 | 57.000 | 154.000 | 96.700 | 36.900 | 53.800 | 6.600 |
This file contains 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 width = 960, | |
height = 500; | |
var svg = d3.select("body").append("svg") | |
.attr("width", width) | |
.attr("height", height); | |
d3.tsv('energymix.tsv', function(err, data) { | |
var keys = d3.keys(data[0]).slice(1), | |
layers = []; | |
keys.forEach(function(key) { | |
var layer = []; | |
layers.push(layer); | |
data.forEach(function(row) { | |
layer.push({ | |
x: new Date(Number(row.Jahr), 0, 1), | |
y: Number(row[key]) | |
}); | |
}); | |
}); | |
var stack = d3.layout.stack().offset("wiggle"); | |
layers = stack(layers); | |
var x = d3.time.scale() | |
.domain([layers[0][0].x, layers[0][data.length-1].x]) | |
.range([20, width]); | |
var y = d3.scale.linear() | |
.domain([0, d3.max(layers, function(layer) { | |
return d3.max(layer, function(d) { | |
return d.y0 + d.y; | |
}); | |
})]).range([height-30, 0]); | |
var area = d3.svg.area() | |
.x(function(d) { return x(d.x); }) | |
.y0(function(d) { return y(d.y0); }) | |
.y1(function(d) { return y(d.y0 + d.y); }) | |
.interpolate('basis'); | |
svg.selectAll("path") | |
.data(layers) | |
.enter().append("path") | |
.attr("d", area) | |
.attr("class", function(d, i) { return keys[i]; }); | |
var labels = [ | |
{ text: 'Steinkohle', x: 50, y: 315, size: 24 }, | |
{ text: 'Braunkohle', x: 150, y: 410, size: 24 }, | |
{ text: 'Mineralöl', x: 280, y: 230, size: 24 }, | |
{ text: 'Erdgas', x: 580, y: 130, size: 20 }, | |
{ text: 'Kernenergie', x: 670, y: 60, size: 18 }, | |
{ text: 'Erneuerbare', x: 880, y: 35, size: 13 } | |
]; | |
svg.selectAll("text") | |
.data(labels) | |
.enter().append("text") | |
.attr('x', function(d) { return d.x; }) | |
.attr('y', function(d) { return d.y; }) | |
.attr('class', function(d) { return 'label '+d.text; }) | |
.attr('style', function(d) { return 'font-size:'+d.size+'px'; }) | |
.text(function(d) { return d.text; }); | |
var xAxis = d3.svg.axis().scale(x); | |
svg.append('svg:g') | |
.attr('class', 'axis') | |
.attr('transform', 'translate(0, '+(height-20)+')') | |
.call(xAxis); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment