Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@jcdcodes
Last active February 6, 2016 17:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jcdcodes/744254f3f07c03034b9a to your computer and use it in GitHub Desktop.
Save jcdcodes/744254f3f07c03034b9a to your computer and use it in GitHub Desktop.
CPI
year cpi
1774 7.82
1775 7.41
1776 8.46
1777 10.31
1778 13.38
1779 11.84
1780 13.29
1781 10.72
1782 11.76
1783 10.31
1784 9.91
1785 9.43
1786 9.19
1787 9.02
1788 8.62
1789 8.54
1790 8.86
1791 9.10
1792 9.27
1793 9.59
1794 10.64
1795 12.17
1796 12.81
1797 12.33
1798 11.92
1799 11.92
1800 12.17
1801 12.33
1802 10.39
1803 10.96
1804 11.44
1805 11.36
1806 11.84
1807 11.20
1808 12.17
1809 11.92
1810 11.92
1811 12.73
1812 12.89
1813 15.47
1814 17.00
1815 14.91
1816 13.62
1817 12.89
1818 12.33
1819 12.33
1820 11.36
1821 10.96
1822 11.36
1823 10.15
1824 9.35
1825 9.59
1826 9.59
1827 9.67
1828 9.19
1829 9.02
1830 8.94
1831 8.38
1832 8.30
1833 8.14
1834 8.30
1835 8.54
1836 9.02
1837 9.27
1838 9.02
1839 9.02
1840 8.38
1841 8.46
1842 7.90
1843 7.17
1844 7.25
1845 7.33
1846 7.41
1847 7.98
1848 7.65
1849 7.41
1850 7.57
1851 7.41
1852 7.49
1853 7.49
1854 8.14
1855 8.38
1856 8.22
1857 8.46
1858 7.98
1859 8.06
1860 8.06
1861 8.54
1862 9.75
1863 12.17
1864 15.23
1865 15.79
1866 15.39
1867 14.34
1868 13.78
1869 13.21
1870 12.65
1871 11.84
1872 11.84
1873 11.60
1874 11.04
1875 10.64
1876 10.39
1877 10.15
1878 9.67
1879 9.67
1880 9.91
1881 9.91
1882 9.91
1883 9.71
1884 9.51
1885 9.32
1886 9.12
1887 9.22
1888 9.22
1889 8.92
1890 8.82
1891 8.82
1892 8.82
1893 8.72
1894 8.34
1895 8.14
1896 8.14
1897 8.04
1898 8.04
1899 8.04
1900 8.14
1901 8.24
1902 8.34
1903 8.53
1904 8.63
1905 8.53
1906 8.72
1907 9.11
1908 8.92
1909 8.82
1910 9.21
1911 9.21
1912 9.40
1913 9.60
1914 9.69
1915 9.74
1916 10.64
1917 12.82
1918 15.06
1919 17.30
1920 20.04
1921 17.90
1922 16.77
1923 17.07
1924 17.10
1925 17.53
1926 17.70
1927 17.37
1928 17.13
1929 17.13
1930 16.70
1931 15.23
1932 13.66
1933 12.96
1934 13.39
1935 13.73
1936 13.86
1937 14.36
1938 14.09
1939 13.89
1940 14.03
1941 14.73
1942 16.30
1943 17.30
1944 17.60
1945 18.00
1946 19.54
1947 22.34
1948 24.08
1949 23.85
1950 24.08
1951 25.98
1952 26.55
1953 26.75
1954 26.88
1955 26.78
1956 27.18
1957 28.15
1958 28.92
1959 29.16
1960 29.62
1961 29.92
1962 30.26
1963 30.62
1964 31.03
1965 31.56
1966 32.46
1967 33.40
1968 34.80
1969 36.67
1970 38.84
1971 40.51
1972 41.85
1973 44.45
1974 49.33
1975 53.84
1976 56.94
1977 60.61
1978 65.22
1979 72.57
1980 82.38
1981 90.93
1982 96.50
1983 99.60
1984 103.90
1985 107.60
1986 109.60
1987 113.60
1988 118.30
1989 124.00
1990 130.70
1991 136.20
1992 140.30
1993 144.50
1994 148.20
1995 152.40
1996 156.90
1997 160.50
1998 163.00
1999 166.60
2000 172.20
2001 177.10
2002 179.90
2003 184.00
2004 188.90
2005 195.30
2006 201.60
2007 207.34
2008 215.30
2009 214.537
2010 218.056
2011 224.939
2012 228.850
2013 232.366
2014 236.384
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/html">
<meta charset="utf-8">
<style>
svg {
font: 12px "Gill Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
}
.axis path, .axis line{
fill:none;
stroke:black;
stroke-width:1px;
}
.dot {
fill:black;
stroke:none;
}
.line {
fill:none;
stroke:steelBlue;
stroke-width:1.5px;
}
</style>
<script src="//d3js.org/d3.v3.min.js"></script>
<body>
<p>CPI for 1775 through 2014 from <a href="http://www.bls.gov/cpi/">The Bureau of Labor Statistics</a>.</p>
<script>
var margin = {top: 20, right: 50, bottom: 30, left: 50},
width = 900 - margin.left - margin.right,
height = 450 - margin.top - margin.bottom;
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 + ")");
var x = d3.scale.linear().domain([1770,2015]).range([0,width]);
var y = d3.scale.log().domain([5,250]).range([height,0]);
var xAxis = d3.svg.axis().scale(x)
.orient("bottom")
.tickFormat(d3.format("d"))
.ticks(30)
;
var yAxis = d3.svg.axis().scale(y)
.orient("left")
.tickFormat(d3.format("d"))
;
var line = d3.svg.line()
.x(function(d) { return x(d.year); })
.y(function(d) { return y(d.cpi); });
d3.tsv("cpi.txt", function(data) {
data.forEach(function(d) {
d.year = +d.year;
d.cpi = +d.cpi;
});
svg.append("path")
.attr("class", "line")
.attr("d", function(d) { return line(data); });
svg.append("g")
.attr("class", "axis")
.attr("transform", "translate(0,"+height+")")
.call(xAxis);
svg.append("g").attr("class", "axis").call(yAxis);
});
svg.append("text")
.attr("transform", "rotate(-90)")
.attr("text-anchor", "end")
.attr("y", 12)
.text("Consumer Price Index")
;
svg.append("text")
.attr("transform", "translate("+width+","+(height-4)+")")
.attr("text-anchor", "end")
.text("Year")
;
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment