Skip to content

Instantly share code, notes, and snippets.

@trinary
Created August 29, 2013 21:38
Show Gist options
  • Save trinary/6383750 to your computer and use it in GitHub Desktop.
Save trinary/6383750 to your computer and use it in GitHub Desktop.
Helping torrenza
{"description":"Helping torrenza","endpoint":"","display":"svg","public":true,"require":[],"fileconfigs":{"inlet.js":{"default":true,"vim":false,"emacs":false,"fontSize":12},"Trade.csv":{"default":true,"vim":false,"emacs":false,"fontSize":12},"_.md":{"default":true,"vim":false,"emacs":false,"fontSize":12},"config.json":{"default":true,"vim":false,"emacs":false,"fontSize":12}},"fullscreen":false,"play":false,"loop":false,"restart":false,"autoinit":true,"pause":true,"loop_type":"period","bv":false,"nclones":15,"clone_opacity":0.4,"duration":3000,"ease":"linear","dt":0.01,"thumbnail":"http://i.imgur.com/vF5A6NV.png"}
var margin = {top: 20, right: 20, bottom: 30, left: 50},
width = 960 - margin.left - margin.right,
height = 500 - margin.top - margin.bottom;
var parseDate = d3.time.format("%Y").parse;
var x = d3.time.scale()
.range([0, 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)
.orient("left");
var line = d3.svg.area()
.interpolate("basis")
.x(function(d) { return x(d.date); })
.y(function(d) { return y(d["IYR"]); });
var area = d3.svg.area()
.interpolate("basis")
.x(function(d) { return x(d.date); })
.y1(function(d) { return y(d["IYR"]); });
var svg = d3.select("svg")
.attr("width", width + margin.left + margin.right)
.attr("height", height + margin.top + margin.bottom)
.append("g")
.attr("transform", "translate(" + margin.left + "," + margin.top + ")");
var data = tributary.Trade;
console.log(data);
//d3.csv("Trade.csv", function (data){
x.domain(d3.extent(data, function(d) { return d.date; }));
y.domain([
d3.min(data, function(d) { return Math.min(d["IYR"], d["EYR"]); }),
d3.max(data, function(d) { return Math.max(d["IYR"], d["EYR"]); })
]);
svg.datum(data);
svg.append("clipPath")
.attr("id", "clip-below")
.append("path")
.attr("d", area.y0(height));
svg.append("clipPath")
.attr("id", "clip-above")
.append("path")
.attr("d", area.y0(0));
svg.append("path")
.attr("class", "area above")
.attr("clip-path", "url(#clip-above)")
.attr("d", area.y0(function(d) { return y(d["EYR"]); }));
svg.append("path")
.attr("class", "area below")
.attr("clip-path", "url(#clip-below)")
.attr("d", area);
svg.append("path")
.attr("class", "line")
.attr("d", line);
svg.append("g")
.attr("class", "x axis")
.attr("transform", "translate(0," + height + ")")
.call(xAxis);
svg.append("g")
.attr("class", "y axis")
.call(yAxis)
.append("text")
.attr("transform", "rotate(-90)")
.attr("y", 6)
.attr("dy", ".71em")
.style("text-anchor", "end")
.text("Temperature (ºF)");
year CTY_CODE CTYNAME IJAN IFEB IMAR IAPR IMAY IJUN IJUL IAUG ISEP IOCT INOV IDEC IYR EJAN EFEB EMAR EAPR EMAY EJUN EJUL EAUG ESEP EOCT ENOV EDEC EYR
1985 3310 Ecuador 188.9 111.1 158.4 99.9 137.4 120.2 170.4 147.9 184.6 155.5 213.8 148.4 1836.5 35.2 51.7 63 43.9 42.6 51.8 55.2 45.2 47.4 47.3 58.7 49.1 591.1
1986 3310 Ecuador 161.3 130.3 110.6 89.5 153 103.1 109.6 93.3 148 140.3 129.1 96.5 1464.6 44.5 60.3 49 50.6 50.8 62.1 50.3 52.6 47.3 43.9 46.9 42.4 600.7
1987 3310 Ecuador 103.6 121.9 101.6 84.9 79.4 75.1 65 81.6 135.9 176.2 134.5 106 1265.7 45.1 45.7 44.9 49 63.4 64.5 55.1 50.6 46.5 51.6 45.9 58.4 620.7
1988 3310 Ecuador 104.9 90.2 110.2 111.1 91.5 84.7 112.5 104 86.3 103.8 101.7 126.9 1227.8 46.1 42.2 67.1 39.7 66.9 47.2 71.8 70.6 52.7 62.6 47.5 67.1 681.5
1989 3310 Ecuador 126.5 96.1 141.3 118 162.1 115.7 136.7 126.3 131.5 133.5 111.8 74.8 1474.3 60.1 55.7 70.3 42.8 53.2 62.5 51.5 44.7 54.2 49.5 56.6 41.5 642.6
1990 3310 Ecuador 115.9 107.9 105.5 84.2 95.2 109.6 134.7 149.2 128.4 140.7 91.5 112.9 1375.7 45.7 44.2 53.7 52.7 57.4 63.3 60.9 59.6 62.2 61.5 58.4 58.6 678.2
1991 3310 Ecuador 97 93.4 107.2 107.3 130.9 132.8 102.6 132.7 124.1 116.1 92 91.1 1327.2 70.1 65.2 81.4 84.9 83.7 73 71.5 75.2 82.7 88.7 84.9 86.4 947.7
1992 3310 Ecuador 99.8 105 94 104.8 94.6 136.2 128.6 127.5 132 106.6 98.2 116.7 1344 69 65.4 75.1 86.2 83.2 94.9 113.1 89.3 79.2 96.7 66.6 80.2 998.9
1993 3310 Ecuador 106.5 90.7 108.6 102.1 121 104.8 130.4 135.8 98.1 139.2 142.5 119.7 1399.4 74.6 83.7 83.9 91.9 99.5 108.1 93 99.6 89.3 88.3 93.3 94.8 1100
1994 3310 Ecuador 131.1 113.4 128.6 128.8 137.2 135.1 154.6 185.7 168.3 162.3 121.3 159.7 1726.1 91.1 78 96.3 93.6 112.4 102.8 109.1 93.8 114 89.7 92.6 121.2 1194.6
1995 3310 Ecuador 159.9 149.8 174.6 152.4 203.7 167.6 187.5 159.9 141.6 148.9 146.5 147.3 1939.7 110.2 129.6 180.3 108.5 119.2 115.1 130.4 117.1 114 129.3 122.9 161.7 1538.3
1996 3310 Ecuador 166.4 127.6 170.5 214.6 174.8 165.4 159.1 154.6 149.7 158 135 182.4 1958.1 115.5 121.3 94.6 104.9 99 94.3 104.4 101.6 89.7 94.4 104.2 134.6 1258.5
1997 3310 Ecuador 121.6 181.7 201.1 165.6 172.7 192.5 177.9 172 181.6 209.6 126.6 152 2054.9 136.7 111.2 107.9 107.6 132.2 130.7 136.9 128.9 130.1 151.4 133.4 119 1526
1998 3310 Ecuador 147.8 149.6 157.5 148.7 154.7 137 141 154.2 163.2 154.1 118.2 126.2 1752.2 122.8 132.3 147.1 134.6 122.9 130.9 176.9 225.2 122.8 134.1 95.9 137.6 1683.1
1999 3310 Ecuador 131.4 125.1 150.4 155.9 174.3 168.9 154.9 178.5 131.6 159.2 138 153 1821.2 107.8 104.5 69.8 67.9 60.5 59.8 60.1 68.7 82.9 87.6 62.6 77.8 910
2000 3310 Ecuador 150.7 167.2 165.3 143 195.6 198.8 144.8 241.8 232.4 204.1 218.5 175.7 2237.9 81.2 84.2 95.5 78.9 76.3 85.2 99.7 78.1 81.3 86.2 100.2 90.9 1037.7
2001 3310 Ecuador 190.1 165.2 155.4 192.8 215.3 165.2 177.8 160.7 146.4 185.5 113.9 141.2 2009.5 113.1 100.5 126 109.7 125.8 127 110.8 95.1 103.5 126 137.4 137.2 1412.1
2002 3310 Ecuador 140.2 153.6 147.8 174.6 219.4 164.1 163.6 193.6 171 229 180.5 206 2143.4 122.9 147.2 151.9 163.3 132.6 109.2 133.7 122.9 113.4 157.9 135.2 115.4 1605.6
2003 3310 Ecuador 198.877398 239.900671 189.540786 210.909683 202.776387 228.369267 241.027107 243.929711 236.9421 256.809898 211.174232 261.728179 2721.985419 119.742547 111.505859 125.567521 125.072825 121.549752 119.44674 122.782714 110.614222 105.848119 136.346711 131.256117 116.955926 1446.689053
2004 3310 Ecuador 311.633636 294.222196 254.95687 346.166973 368.765358 265.802249 358.255394 427.709866 431.331363 445.510879 383.348106 395.696669 4283.399559 116.257909 133.374138 143.299335 121.949651 115.494367 123.76641 144.941176 121.090062 138.96671 169.337991 158.11937 182.015998 1668.613117
2005 3310 Ecuador 432.379516 459.515039 458.532652 501.92491 415.716108 478.745009 461.820355 571.241563 371.599973 562.917638 468.505494 575.781089 5758.679346 123.632652 119.187661 178.566949 158.348506 185.997576 193.390784 146.616531 215.697818 157.845358 161.360128 155.058523 168.123386 1963.825872
2006 3310 Ecuador 655.142581 477.279222 580.622737 537.629122 661.243599 580.416629 491.719081 763.227968 628.141585 638.472299 526.615145 553.340798 7093.850766 205.580619 172.270699 241.167895 216.415995 217.587509 204.910129 260.877719 206.981158 267.959524 206.900517 276.685096 249.858927 2727.195787
2007 3310 Ecuador 564.564445 397.197632 428.69601 425.701546 512.904717 428.852853 491.391201 568.537315 672.958357 602.607349 513.939878 527.648193 6134.999496 238.401497 284.429199 240.23711 260.427945 239.484955 226.187225 190.498234 231.518092 205.445649 281.012685 301.686907 236.319159 2935.648657
2008 3310 Ecuador 918.490253 645.9327 835.992936 743.715933 537.427133 843.365155 1111.152181 1070.301747 859.132171 580.486297 497.795085 404.619369 9048.41096 245.286468 228.902283 265.789659 292.554328 279.549953 314.828073 294.102091 347.762453 294.299326 339.849646 270.098788 276.99428 3450.017348
2009 3310 Ecuador 374.755456 346.714733 400.55592 472.010532 414.716108 443.529038 502.959483 412.967747 507.130151 551.619688 449.310072 396.297373 5272.566301 274.349311 246.816892 268.682768 268.56051 297.294857 292.61598 245.110748 315.392685 279.633483 402.756572 438.130282 608.545094 3937.889182
2010 3310 Ecuador 639.411541 413.129223 533.409341 751.589237 490.379508 632.253376 772.693697 725.127752 663.476452 595.030553 656.143533 578.405213 7451.049426 511.514919 307.099942 427.783545 393.189999 439.637981 517.345609 431.716345 536.150878 399.358808 507.646229 490.633973 447.360893 5409.439121
2011 3310 Ecuador 702.447103 897.893038 812.578296 612.96128 766.71558 943.860138 709.262979 1092.414269 890.556737 778.362036 825.006689 590.232606 9622.290751 506.501749 384.143066 532.144995 460.933205 508.006916 431.050766 426.480278 503.38817 553.304483 554.372837 601.713097 603.647199 6065.686761
2012 3310 Ecuador 584.118984 739.221917 797.901007 1143.063775 928.558291 927.084159 697.643629 799.131809 920.584014 617.870395 573.238208 756.35911 9484.775298 526.890118 431.571053 558.499423 675.892723 574.31701 466.434265 484.153567 620.90892 567.198305 577.630386 562.899073 645.992429 6692.387272
2013 3310 Ecuador 1017.149404 808.900962 958.058586 1007.452362 953.961456 746.16571 0 0 0 0 0 0 5491.68848 635.751693 777.313461 689.850853 454.949856 401.962563 600.202571 0 0 0 0 0 0 3560.030997
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment