Skip to content

Instantly share code, notes, and snippets.

@dougdowson
Last active August 29, 2015 14:00
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 dougdowson/2094093d2c0853c595d3 to your computer and use it in GitHub Desktop.
Save dougdowson/2094093d2c0853c595d3 to your computer and use it in GitHub Desktop.
Line Chart: Season of Birth
var margin = {top: 20, right: 75, bottom: 30, left: 30},
width = 700 - margin.left - margin.right,
height = 400 - margin.top - margin.bottom,
xScale = d3.time.scale().range([0, width]),
yScale = d3.scale.linear().range([height, 0]),
parseDate = d3.time.format("%Y").parse,
formatPercent = d3.format(".0%");
var birthData,
filtered,
transpose;
var line = d3.svg.line()
.interpolate("basis")
.x(function(d) { return xScale(d.year); })
.y(function(d) { return yScale(d.stat); });
var svg = d3.select("#chart").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 xAxis = d3.svg.axis()
.scale(xScale)
.orient("bottom")
svg.append("g")
.attr("class", "x axis");
var yAxis = d3.svg.axis()
.scale(yScale)
.orient("left")
.ticks(8)
.tickFormat(formatPercent)
.tickSize(-width - margin.left - margin.right)
svg.append("g")
.attr("class", "y axis");
var menu = d3.select("#menu")
.on("change", change);
d3.csv("data.csv", function(csv) {
birthData = csv;
update();
});
function change() {
d3.transition()
.duration(500)
.each(update);
}
function update() {
var nested = d3.nest()
.key(function(d) { return d.variablecode; })
.map(birthData)
var series = menu.property("value");
var data = nested[series];
var variables = d3.keys(data[0]).filter(function(key) {
return (key !== "variable" && key !== "variablecode" && key !== "year");
});
var transpose = variables.map(function(name) {
return {
name: name,
values: data.map(function(d) {
return {year: parseDate(d.year), stat: +d[name]};
})
};
});
var ymin = d3.min(transpose, function(c) { return d3.min(c.values, function(v) { return v.stat; }); });
var ymax = d3.max(transpose, function(c) { return d3.max(c.values, function(v) { return v.stat; }); });
xScale.domain([
d3.min(transpose, function(c) { return d3.min(c.values, function(v) { return v.year; }); }),
d3.max(transpose, function(c) { return d3.max(c.values, function(v) { return v.year; }); })
]);
yScale.domain([0.95*ymin,1.1*ymax]);
var months = svg.selectAll(".month")
.data(transpose);
var monthsEnter = months.enter().append("g")
.attr("class", "month")
.attr("id", function(d) { return d.name; });
monthsEnter.append("path")
.attr("class", "line")
.style("stroke", "#aaa")
.attr("d", function(d) { return line(d.values); });
monthsEnter.append("text")
.datum(function(d) { return {name: d.name, value: d.values[d.values.length - 1]}; })
.attr("x", 4)
.attr("dy", ".35em")
.text(function(d) { return d.name; });
var monthsUpdate = d3.transition(months);
monthsUpdate.select("path")
.attr("d", function(d) { return line(d.values); });
monthsUpdate.select("text")
.attr("transform", function(d) { return "translate(" + xScale(d.values[d.values.length - 1].year) + "," + yScale(d.values[d.values.length - 1].stat) + ")"; });
d3.transition(svg).select(".y.axis")
.call(yAxis);
d3.transition(svg).select(".x.axis")
.attr("transform", "translate(0," + height + ")")
.call(xAxis);
svg.selectAll("g")
.classed("g-baseline", function(d) { return d == 0 });
d3.select("#Annualavg .line")
.style("stroke", "#2980B9")
.style("opacity", "1")
.style("stroke-width", "2px");
d3.select("#Annualavg text")
.text("Annual avg")
.style("display", "block");
d3.select("#January text")
.style("display", "block");
d3.select("#May text")
.style("display", "block");
d3.select("#January .line")
.style("opacity", "1")
.style("stroke", "#3498DB");
d3.select("#May .line")
.style("opacity", "1")
.style("stroke", "#3498DB");
}
d3.select(self.frameElement).style("height", "625px");
variable variablecode year February March April June July August October November December September May January Annualavg
Percent white mothers pct_white 1968 0.8277899 0.835096 0.8426401 0.8362535 0.8340121 0.8335643 0.8387251 0.8330704 0.8321992 0.8355268 0.8424643 0.8235497 0.8346179
Percent white mothers pct_white 1969 0.8344966 0.8395346 0.8461778 0.8383457 0.8314151 0.8306534 0.8313438 0.8293105 0.8302249 0.8292879 0.8467924 0.8304416 0.834655
Percent white mothers pct_white 1970 0.8321918 0.8408967 0.849831 0.8368306 0.8307227 0.8265817 0.8303937 0.8243111 0.8250778 0.8281302 0.8423828 0.8246912 0.8324206
Percent white mothers pct_white 1971 0.8253911 0.8322673 0.8354686 0.8336217 0.8240851 0.8177771 0.8244407 0.8212605 0.820537 0.8204755 0.8360767 0.8193117 0.8257675
Percent white mothers pct_white 1972 0.821003 0.8269671 0.8306725 0.8276598 0.8162155 0.8159729 0.8189405 0.8140613 0.8140659 0.816506 0.8300282 0.8145978 0.8204187
Percent white mothers pct_white 1973 0.8207645 0.8251914 0.8323928 0.827275 0.8216869 0.8220817 0.8266839 0.8187346 0.8185999 0.8213102 0.8326114 0.8146162 0.8234366
Percent white mothers pct_white 1974 0.818274 0.8289542 0.8368197 0.8321468 0.8246467 0.8200513 0.8271425 0.8232578 0.8241874 0.8235255 0.8353204 0.813926 0.8256167
Percent white mothers pct_white 1975 0.8171127 0.8211533 0.8270786 0.8206922 0.8146011 0.8106576 0.8143957 0.8102602 0.8116318 0.8121328 0.8260425 0.8109286 0.8163005
Percent white mothers pct_white 1976 0.8182102 0.8271216 0.8308772 0.8250583 0.8161692 0.8126136 0.8173811 0.8137391 0.8131302 0.8158037 0.8281872 0.810529 0.8188466
Percent white mothers pct_white 1977 0.8135838 0.8209686 0.8247634 0.8209216 0.8130999 0.8137311 0.8191612 0.8153814 0.8135473 0.8177564 0.8248919 0.8077356 0.8171049
Percent white mothers pct_white 1978 0.8158267 0.8222821 0.8279576 0.8172489 0.8110753 0.8094115 0.8167976 0.81344 0.8078462 0.8142698 0.8257598 0.8119498 0.8159593
Percent white mothers pct_white 1979 0.8101098 0.8173826 0.8236728 0.8159905 0.8081781 0.8077686 0.8143419 0.8095905 0.8060876 0.8085949 0.8203824 0.8036597 0.8120274
Percent white mothers pct_white 1980 0.8084501 0.8154197 0.8216099 0.8143849 0.8073606 0.8083847 0.8136859 0.8115835 0.8101814 0.8105296 0.8208673 0.8039099 0.8121225
Percent white mothers pct_white 1981 0.8099008 0.8176779 0.8245769 0.8161846 0.8078554 0.8086428 0.8110898 0.8068491 0.8037636 0.810065 0.8216711 0.8038906 0.8117464
Percent white mothers pct_white 1982 0.807946 0.8176482 0.8220695 0.8131114 0.8088734 0.8049312 0.8102378 0.8068694 0.8050768 0.8091065 0.819551 0.8028763 0.8106502
Percent white mothers pct_white 1983 0.8085291 0.8157367 0.820256 0.8135355 0.807201 0.8066998 0.8082082 0.807009 0.8042478 0.8071577 0.8181593 0.8008935 0.8097923
Percent white mothers pct_white 1984 0.8050634 0.8125866 0.8212191 0.8135522 0.8060478 0.8041599 0.8085924 0.8054058 0.8009459 0.8087885 0.8188195 0.7981594 0.8085443
Percent white mothers pct_white 1985 0.8058925 0.8113194 0.8151903 0.8095751 0.803223 0.8022426 0.8074229 0.8009062 0.7982304 0.8014532 0.8135467 0.797056 0.8054649
Percent white mothers pct_white 1986 0.801686 0.8048672 0.8101593 0.8077568 0.8015986 0.7999755 0.8000726 0.7947727 0.789853 0.8000795 0.8119177 0.795518 0.8015271
Percent white mothers pct_white 1987 0.7950226 0.8035534 0.8083365 0.8027614 0.7979734 0.7953076 0.7948117 0.7889988 0.7891955 0.7947284 0.8059548 0.7890834 0.7971707
Percent white mothers pct_white 1988 0.7915655 0.7976527 0.8030233 0.795849 0.7872509 0.788124 0.7894088 0.7848322 0.7831891 0.7910141 0.8032279 0.7857423 0.7916862
Percent white mothers pct_white 1989 0.786675 0.7945181 0.799869 0.7963507 0.7862269 0.7867869 0.7885338 0.7878725 0.7830837 0.7886659 0.8028138 0.7810138 0.7901843
Percent white mothers pct_white 1990 0.7885214 0.7960064 0.8010002 0.7968913 0.7899985 0.7897068 0.790601 0.7866113 0.783015 0.7895982 0.8014009 0.783363 0.7914494
Percent white mothers pct_white 1991 0.7854361 0.791705 0.7972386 0.793932 0.7880477 0.7855318 0.7888574 0.7834216 0.7801719 0.7893934 0.8001228 0.7788753 0.7886186
Percent white mothers pct_white 1992 0.7853286 0.7933248 0.7982234 0.7921475 0.7883237 0.787246 0.785251 0.7805275 0.7799028 0.786892 0.796038 0.7796433 0.7877883
Percent white mothers pct_white 1993 0.7821326 0.7897891 0.7970443 0.7949199 0.7864366 0.7871514 0.787365 0.7856108 0.7805911 0.7901946 0.7940886 0.7746893 0.7875857
Percent white mothers pct_white 1994 0.7821754 0.7914625 0.7979434 0.7955654 0.7899978 0.7905554 0.790265 0.7878136 0.7850506 0.7904953 0.799026 0.7756895 0.7897527
Percent white mothers pct_white 1995 0.7897103 0.7966202 0.8028711 0.799545 0.794862 0.7965797 0.7941213 0.7911902 0.7876805 0.7962593 0.8044744 0.7822515 0.7947944
Percent white mothers pct_white 1996 0.7922945 0.799072 0.8043851 0.8005672 0.7958062 0.7936157 0.7952093 0.7883163 0.7851647 0.7931036 0.8056797 0.7858989 0.7949523
Percent white mothers pct_white 1997 0.7893178 0.7947978 0.7987496 0.7971282 0.7936906 0.792792 0.7918656 0.7830969 0.7836027 0.793233 0.7990291 0.7840623 0.7918485
Percent white mothers pct_white 1998 0.7872595 0.7928604 0.7992851 0.7960639 0.7943965 0.790878 0.7926745 0.7846543 0.7841214 0.7928356 0.7998785 0.7806417 0.7913737
Percent white mothers pct_white 1999 0.7898681 0.7953286 0.799336 0.7970383 0.793442 0.7918812 0.7904821 0.7850931 0.7793508 0.7926409 0.7978778 0.7826595 0.791295
Percent white mothers pct_white 2000 0.7818195 0.7890489 0.7938765 0.7923567 0.7875105 0.787806 0.7868863 0.7807964 0.7795684 0.7882242 0.7963812 0.780638 0.7871093
Percent white mothers pct_white 2001 0.7878374 0.7905293 0.7948056 0.7949279 0.7909046 0.7907622 0.7905972 0.7848212 0.7811196 0.7893035 0.7971019 0.7806187 0.7895013
Percent white mothers pct_white 2002 0.7862583 0.7915178 0.795034 0.7923354 0.7918514 0.7910348 0.7905372 0.7820053 0.7815254 0.7932919 0.7975578 0.7816146 0.7896374
Percent white mothers pct_white 2003 0.7854334 0.7905121 0.7959581 0.7936759 0.7936047 0.7888451 0.7890254 0.7794627 0.7806632 0.7908345 0.7967831 0.7815619 0.7889771
Percent white mothers pct_white 2004 0.7845816 0.7882827 0.7916659 0.7892489 0.7872379 0.785416 0.7802125 0.7734256 0.770853 0.7857209 0.7927983 0.7790665 0.7840534
Percent white mothers pct_white 2005 0.7776818 0.7844524 0.7873536 0.786081 0.7827649 0.7838263 0.7775599 0.7732205 0.7720841 0.7819776 0.7889715 0.7705057 0.7806333
Percent white mothers pct_white 2006 0.7743188 0.7810667 0.7837346 0.7844396 0.7785006 0.7771371 0.7729854 0.7689829 0.7654536 0.7742049 0.786299 0.7692249 0.7763649
Percent white mothers pct_white 2007 0.7729158 0.7763482 0.779492 0.7793193 0.7772219 0.7768596 0.7707698 0.7627248 0.759944 0.7728385 0.782838 0.7685341 0.773367
Percent white mothers pct_white 2008 0.7695715 0.7728272 0.7765718 0.7792369 0.7764321 0.7737763 0.7684035 0.7617992 0.7600338 0.7729616 0.7795687 0.7612283 0.7711235
Percent white mothers pct_white 2009 0.7646018 0.7708735 0.775084 0.7752326 0.7735488 0.7699083 0.7666003 0.7613824 0.757676 0.7708313 0.775138 0.7600297 0.7685377
Percent white mothers pct_white 2010 0.7657188 0.7699863 0.7742627 0.7750522 0.7706831 0.7721936 0.7652136 0.7594656 0.7567574 0.7708194 0.7748328 0.7575877 0.767776
Percent white mothers pct_white 2011 0.7608772 0.7676054 0.7707368 0.769715 0.7657745 0.7668317 0.7638999 0.756959 0.7529651 0.7668012 0.7723398 0.7559856 0.764289
Percent white mothers pct_white 2012 0.7583164 0.7629561 0.766346 0.7641049 0.7636555 0.763085 0.7561769 0.7486449 0.7467073 0.7596399 0.7683045 0.7524633 0.7592487
Percent black mothers pct_black 1968 0.155516 0.1486362 0.1409761 0.1478889 0.1504689 0.1509773 0.145967 0.1506255 0.1515917 0.1485256 0.1414576 0.1593272 0.1493059
Percent black mothers pct_black 1969 0.1488334 0.1433148 0.1363652 0.1441926 0.1517798 0.1528499 0.1515136 0.1534469 0.1524536 0.1529525 0.1355474 0.1529292 0.1481971
Percent black mothers pct_black 1970 0.1500384 0.1413442 0.1327946 0.1456203 0.1526939 0.1566192 0.1519317 0.1584411 0.1579177 0.1547868 0.1390622 0.1555786 0.1500086
Percent black mothers pct_black 1971 0.1569009 0.1493292 0.1440846 0.1475424 0.1570758 0.1631185 0.1559318 0.1591343 0.1608044 0.1601944 0.1447744 0.1627614 0.1552683
Percent black mothers pct_black 1972 0.1598104 0.1532136 0.1489226 0.1521558 0.1635522 0.1644635 0.1608336 0.1655662 0.1666902 0.1643555 0.1503347 0.1665599 0.1598523
Percent black mothers pct_black 1973 0.1596853 0.1545857 0.1474839 0.1525536 0.1573285 0.1582049 0.153464 0.1597194 0.1603811 0.1584587 0.1468491 0.1653685 0.1562333
Percent black mothers pct_black 1974 0.1613124 0.1502489 0.1428301 0.1472404 0.1547392 0.1599454 0.1510213 0.1539734 0.1553758 0.1561082 0.1433253 0.1654153 0.1535342
Percent black mothers pct_black 1975 0.1627034 0.1584833 0.1523682 0.1577089 0.1643211 0.1679959 0.1633381 0.1672742 0.16582 0.1658439 0.152747 0.1684264 0.162332
Percent black mothers pct_black 1976 0.1599277 0.1511856 0.14702 0.1533938 0.1626829 0.1655971 0.1615499 0.1647995 0.1639172 0.162811 0.1492667 0.1680921 0.1594175
Percent black mothers pct_black 1977 0.1645681 0.1571771 0.1529522 0.15714 0.1653745 0.1647023 0.1590432 0.1629744 0.1646873 0.1604166 0.1531425 0.1699034 0.1610364
Percent black mothers pct_black 1978 0.1599111 0.1526781 0.1469845 0.15817 0.1648321 0.166165 0.1583968 0.1611217 0.1663668 0.1615064 0.1488644 0.1632711 0.1592243
Percent black mothers pct_black 1979 0.1618985 0.1545373 0.1486152 0.1562897 0.1652629 0.1651162 0.1582897 0.162224 0.164474 0.1636233 0.1510772 0.1678616 0.1600765
Percent black mothers pct_black 1980 0.1621331 0.1556107 0.1493494 0.1564104 0.1631573 0.1623212 0.1555663 0.1571118 0.1590343 0.1596234 0.1493584 0.166562 0.1580932
Percent black mothers pct_black 1981 0.1585074 0.1515481 0.1440128 0.1520039 0.1611128 0.1610014 0.1568914 0.1603173 0.163086 0.1587174 0.146357 0.1649946 0.1566636
Percent black mothers pct_black 1982 0.1591359 0.1492232 0.1432135 0.1530444 0.157985 0.1609756 0.1551944 0.1577692 0.1598027 0.156433 0.1466806 0.162841 0.1552348
Percent black mothers pct_black 1983 0.1568182 0.1499108 0.1447746 0.1517857 0.1592479 0.1587813 0.1566114 0.1576724 0.1593143 0.1580815 0.1466078 0.1642522 0.1553431
Percent black mothers pct_black 1984 0.1582941 0.1519512 0.1431126 0.1504533 0.1585423 0.1602917 0.1554887 0.1576391 0.1614816 0.155871 0.1454843 0.1651284 0.1553984
Percent black mothers pct_black 1985 0.1542895 0.1495709 0.1443698 0.150135 0.1562961 0.1579139 0.1523794 0.1579383 0.16008 0.1581217 0.1463099 0.1619018 0.1541514
Percent black mothers pct_black 1986 0.1571568 0.1536998 0.148586 0.1520887 0.1578086 0.1591975 0.1585058 0.1632717 0.1674839 0.1593566 0.1470288 0.1633585 0.1573007
Percent black mothers pct_black 1987 0.1617899 0.1532817 0.1492765 0.1548185 0.1600182 0.1628066 0.1619268 0.1676564 0.1668611 0.1630093 0.1511507 0.1672398 0.1599744
Percent black mothers pct_black 1988 0.1637082 0.1576264 0.1521797 0.1593089 0.167906 0.1675724 0.1633492 0.1669167 0.1687758 0.1640708 0.151581 0.1700225 0.1628149
Percent black mothers pct_black 1989 0.1694158 0.1628634 0.1574544 0.161327 0.1716944 0.1703672 0.1673318 0.1676157 0.1716973 0.1686251 0.1543428 0.1735718 0.1664024
Percent black mothers pct_black 1990 0.1676797 0.1604276 0.1557741 0.1597745 0.1664543 0.1666568 0.1644854 0.1674796 0.1710839 0.1662731 0.1547732 0.1726357 0.1644124
Percent black mothers pct_black 1991 0.1693959 0.1636116 0.1584989 0.1610198 0.1673093 0.1687054 0.1647061 0.1686913 0.1729643 0.1650601 0.1560403 0.1753069 0.165897
Percent black mothers pct_black 1992 0.1676585 0.1609265 0.1555215 0.1617294 0.1666857 0.1667678 0.1673048 0.1713917 0.1720162 0.1661853 0.1576547 0.173281 0.1655601
Percent black mothers pct_black 1993 0.1703575 0.1631885 0.1558655 0.1574964 0.166636 0.1646769 0.163987 0.165458 0.1698972 0.1619465 0.1585347 0.1775586 0.1645559
Percent black mothers pct_black 1994 0.1686614 0.1598839 0.1526818 0.1551081 0.1618832 0.1612769 0.1597563 0.1604486 0.1647401 0.1605795 0.1512613 0.1747181 0.1608545
Percent black mothers pct_black 1995 0.160375 0.1532846 0.1470095 0.1509767 0.1550062 0.1544519 0.1535038 0.1556777 0.1591151 0.1531436 0.146185 0.1670698 0.1545601
Percent black mothers pct_black 1996 0.1554935 0.1491233 0.1435694 0.1477402 0.1535925 0.1553414 0.1521702 0.1575761 0.161197 0.1543116 0.1418331 0.1608826 0.1527315
Percent black mothers pct_black 1997 0.1577889 0.1518743 0.147679 0.1500889 0.1532406 0.1541584 0.1540533 0.1608868 0.1608758 0.1530852 0.1480248 0.1626808 0.1544743
Percent black mothers pct_black 1998 0.1583872 0.1536471 0.1465327 0.1508055 0.1524448 0.1557809 0.1530387 0.1594243 0.1607489 0.1537864 0.1470142 0.1645477 0.1546221
Percent black mothers pct_black 1999 0.1548625 0.1491828 0.144739 0.1477583 0.1518991 0.1536399 0.1532619 0.1573462 0.1626281 0.1520483 0.1461743 0.1618434 0.152919
Percent black mothers pct_black 2000 0.1600612 0.1521535 0.1463249 0.1494328 0.1545922 0.1535012 0.1516977 0.1557979 0.157352 0.1516731 0.1448197 0.1618544 0.1532407
Percent black mothers pct_black 2001 0.151965 0.1493919 0.1457479 0.1462009 0.1503672 0.1503275 0.1486017 0.1535128 0.1575432 0.1500615 0.143643 0.1578609 0.1503955
Percent black mothers pct_black 2002 0.1522315 0.1460527 0.1419028 0.1451229 0.1475015 0.146553 0.1455342 0.1513749 0.152986 0.1441774 0.1405635 0.1562088 0.1474456
Percent black mothers pct_black 2003 0.1500445 0.1443936 0.1399321 0.1424141 0.1440817 0.1472235 0.1458558 0.1534791 0.1534285 0.1457754 0.1382216 0.153831 0.1464721
Percent black mothers pct_black 2004 0.1501691 0.1460672 0.1428601 0.145053 0.1483127 0.1486625 0.1515282 0.1579827 0.1610609 0.1487708 0.13996 0.1550623 0.1496164
Percent black mothers pct_black 2005 0.1552326 0.148339 0.1462014 0.1483158 0.1524546 0.1505979 0.1548743 0.1587558 0.160987 0.1522737 0.145172 0.1607746 0.152768
Percent black mothers pct_black 2006 0.1589895 0.151248 0.1480016 0.1486499 0.1550892 0.1561029 0.1588518 0.1620022 0.1657995 0.1586621 0.1459348 0.1628459 0.1560215
Percent black mothers pct_black 2007 0.1585704 0.1542763 0.1506309 0.1521331 0.1549916 0.1542965 0.1565897 0.1632503 0.1658216 0.1561432 0.1474107 0.1620008 0.156302
Percent black mothers pct_black 2008 0.1591729 0.1562722 0.1528716 0.1510172 0.1542442 0.1563386 0.1590174 0.1648392 0.1670165 0.1569495 0.1495604 0.1657219 0.1576917
Percent black mothers pct_black 2009 0.1627114 0.1563116 0.1534331 0.1545389 0.1564003 0.1584061 0.1587655 0.1641805 0.1681298 0.1567751 0.1528768 0.1664319 0.1589824
Percent black mothers pct_black 2010 0.1617909 0.1563975 0.1532855 0.1524106 0.1563368 0.1557695 0.1597472 0.1664127 0.1688546 0.1570998 0.151599 0.1677465 0.158898
Percent black mothers pct_black 2011 0.1633667 0.1567035 0.1521274 0.155009 0.1606738 0.1585708 0.1585727 0.1662874 0.1697481 0.1579159 0.1518387 0.1678802 0.1598402
Percent black mothers pct_black 2012 0.1633318 0.1573225 0.153029 0.1570326 0.1588479 0.1580262 0.1602479 0.1659802 0.1681869 0.1590755 0.1522285 0.1693342 0.1601726
Percent teen mothers pct_teen 1968 0.1771183 0.1760895 0.1722522 0.1686451 0.1709426 0.1712997 0.1654682 0.1699202 0.1713446 0.1718648 0.170986 0.1741575 0.171585
Percent teen mothers pct_teen 1969 0.1737313 0.1730231 0.1694252 0.1671411 0.1719584 0.1725674 0.1678292 0.1683061 0.1721978 0.1727593 0.1661571 0.1749881 0.1708574
Percent teen mothers pct_teen 1970 0.1753823 0.1762054 0.172782 0.1747655 0.1763403 0.1797927 0.1723064 0.175114 0.1751467 0.1796352 0.1732206 0.1787097 0.1758409
Percent teen mothers pct_teen 1971 0.1793052 0.1777485 0.1776992 0.1759749 0.1805364 0.1856529 0.1776038 0.1799959 0.1838413 0.180693 0.1777374 0.1796206 0.179736
Percent teen mothers pct_teen 1972 0.1957107 0.1938698 0.19163 0.1882748 0.1969077 0.1963343 0.1942641 0.194106 0.1997229 0.1949653 0.1908134 0.193387 0.1942264
Percent teen mothers pct_teen 1973 0.2022105 0.2008608 0.1967943 0.1958825 0.1949062 0.194682 0.1873339 0.1917337 0.1959259 0.192026 0.1935918 0.2007115 0.1955117
Percent teen mothers pct_teen 1974 0.1986154 0.1937471 0.1919445 0.1877392 0.1915985 0.1918268 0.18246 0.1852534 0.1886647 0.1902497 0.187712 0.2013211 0.1908183
Percent teen mothers pct_teen 1975 0.1960681 0.1946089 0.1901266 0.1885456 0.1920308 0.1907554 0.1842357 0.1866427 0.1865741 0.1895315 0.1899313 0.1994563 0.1906732
Percent teen mothers pct_teen 1976 0.1927102 0.1878922 0.1830761 0.1803902 0.1857011 0.1844897 0.1753502 0.1788863 0.1789864 0.1800492 0.1816248 0.1932399 0.1834006
Percent teen mothers pct_teen 1977 0.1786447 0.1789929 0.1759789 0.1704276 0.1745768 0.1716523 0.1639515 0.1654846 0.1690175 0.1669725 0.1745224 0.1837218 0.1727375
Percent teen mothers pct_teen 1978 0.1742728 0.1689983 0.1685699 0.1666316 0.1704777 0.1686645 0.1591368 0.1564288 0.1646572 0.1655325 0.1657415 0.174369 0.1668728
Percent teen mothers pct_teen 1979 0.1656405 0.1625982 0.157075 0.1579768 0.1615497 0.1605286 0.1535408 0.1557241 0.1608909 0.1580955 0.1566513 0.1705214 0.1600071
Percent teen mothers pct_teen 1980 0.1622305 0.1585439 0.1557585 0.1558815 0.1572758 0.1581238 0.1503686 0.1513035 0.1507559 0.1531668 0.1531341 0.164315 0.1558553
Percent teen mothers pct_teen 1981 0.1526994 0.1510475 0.1484906 0.1474667 0.1488299 0.1486233 0.1418269 0.1441225 0.1470602 0.1462557 0.1457994 0.1562476 0.1481564
Percent teen mothers pct_teen 1982 0.1459961 0.1442971 0.1410446 0.1411127 0.1432513 0.1432304 0.1381673 0.1395059 0.1423589 0.141969 0.1405018 0.1506677 0.1426404
Percent teen mothers pct_teen 1983 0.1439798 0.1394352 0.1352031 0.1354441 0.1381673 0.1385231 0.1352004 0.1348152 0.1361216 0.1362071 0.1355138 0.1444595 0.1377226
Percent teen mothers pct_teen 1984 0.1374113 0.1339436 0.1311123 0.1275805 0.132242 0.1312468 0.1267183 0.1270914 0.130777 0.1303987 0.1278568 0.1381237 0.1311484
Percent teen mothers pct_teen 1985 0.1296927 0.1278394 0.1254936 0.1243597 0.126965 0.1279809 0.1237534 0.1268845 0.1291863 0.127833 0.1232477 0.1306127 0.1269591
Percent teen mothers pct_teen 1986 0.1290621 0.127295 0.1244933 0.1218171 0.1255584 0.1263522 0.1209406 0.1251005 0.1286124 0.1242382 0.1216557 0.1327402 0.12561
Percent teen mothers pct_teen 1987 0.1276171 0.1256652 0.1227334 0.1197391 0.123201 0.1239056 0.1217963 0.1241257 0.1245586 0.1233812 0.1215266 0.1307224 0.1240124
Percent teen mothers pct_teen 1988 0.1272163 0.1233976 0.1212261 0.1209032 0.127676 0.1271041 0.1232899 0.1269473 0.1297068 0.1248715 0.1198813 0.1279452 0.1250168
Percent teen mothers pct_teen 1989 0.1293669 0.1285195 0.1269738 0.1247186 0.1284229 0.1293685 0.1271328 0.1270955 0.1315049 0.1292031 0.123662 0.1316174 0.1281274
Percent teen mothers pct_teen 1990 0.1304541 0.1287376 0.1255345 0.1233623 0.1285088 0.1292171 0.1268509 0.1295814 0.1322114 0.1281507 0.1233085 0.1335115 0.1282418
Percent teen mothers pct_teen 1991 0.1312766 0.1304381 0.1268944 0.1262185 0.1287133 0.1302462 0.1281556 0.1295415 0.1314402 0.1293941 0.1250071 0.1342462 0.1292716
Percent teen mothers pct_teen 1992 0.1304352 0.1280038 0.1245628 0.1224108 0.1263794 0.127262 0.1281081 0.1307142 0.1318472 0.1263382 0.1209898 0.1309992 0.1272884
Percent teen mothers pct_teen 1993 0.1291569 0.128367 0.1246228 0.1229599 0.127653 0.1287282 0.1295329 0.1306105 0.1336201 0.1282409 0.1233054 0.1337951 0.1283481
Percent teen mothers pct_teen 1994 0.1344272 0.1308729 0.1278607 0.1248523 0.1315878 0.1325033 0.1315238 0.133285 0.1356381 0.1310847 0.1239595 0.1357178 0.1310844
Percent teen mothers pct_teen 1995 0.1349724 0.1320269 0.1294863 0.1260831 0.1310452 0.1317097 0.130689 0.1311478 0.1353535 0.1304687 0.1250104 0.1381214 0.1312732
Percent teen mothers pct_teen 1996 0.1321142 0.1313656 0.12601 0.1254733 0.1283484 0.1298416 0.1274625 0.1297537 0.1328068 0.1280905 0.1227289 0.136052 0.1291343
Percent teen mothers pct_teen 1997 0.1310578 0.1281219 0.1254313 0.1221936 0.1251016 0.1268736 0.1245444 0.130255 0.1311248 0.1261949 0.1207895 0.1341579 0.1270786
Percent teen mothers pct_teen 1998 0.1294828 0.1256589 0.1234724 0.1206786 0.1233467 0.126175 0.1242008 0.1276204 0.1283807 0.1247513 0.1196745 0.1317352 0.1253734
Percent teen mothers pct_teen 1999 0.1272832 0.1236443 0.1214131 0.1183642 0.122735 0.122382 0.1205726 0.1208489 0.1236646 0.1219617 0.1172181 0.1300776 0.1224615
Percent teen mothers pct_teen 2000 0.1222414 0.118839 0.1157769 0.1153789 0.1184704 0.1180791 0.1167488 0.116126 0.1170131 0.1177637 0.1120596 0.1231117 0.1176095
Percent teen mothers pct_teen 2001 0.1160353 0.1143391 0.1126747 0.1092276 0.113062 0.1120006 0.1104617 0.1126509 0.1146314 0.1120943 0.1075464 0.1178295 0.1126669
Percent teen mothers pct_teen 2002 0.1120635 0.1098122 0.1056183 0.1056201 0.1073251 0.106633 0.1063109 0.108347 0.1074508 0.1064494 0.1020194 0.1141204 0.1075894
Percent teen mothers pct_teen 2003 0.1060384 0.1034474 0.1011165 0.0993715 0.101176 0.1038862 0.1012654 0.105927 0.1055573 0.1031849 0.0977032 0.1076766 0.1029674
Percent teen mothers pct_teen 2004 0.1057349 0.1025331 0.0999946 0.0990162 0.1014137 0.1019532 0.1023517 0.1045021 0.1057624 0.101042 0.098386 0.1091096 0.1026102
Percent teen mothers pct_teen 2005 0.1033519 0.1010629 0.0987938 0.0988943 0.1009058 0.1012499 0.1025535 0.1047073 0.1054069 0.1026299 0.0961595 0.1060326 0.1017819
Percent teen mothers pct_teen 2006 0.1056074 0.1025772 0.100165 0.0991538 0.1031514 0.1036447 0.1053687 0.1061991 0.107439 0.1042412 0.0975108 0.1076213 0.103548
Percent teen mothers pct_teen 2007 0.1072714 0.1041117 0.1025192 0.1011706 0.1034557 0.1047206 0.1042103 0.1052361 0.1078283 0.1062335 0.0986063 0.1086033 0.1044727
Percent teen mothers pct_teen 2008 0.1070796 0.1057457 0.1017424 0.1010609 0.1030856 0.1036714 0.1025401 0.1054231 0.1047059 0.103689 0.0983161 0.1071913 0.1036648
Percent teen mothers pct_teen 2009 0.1049188 0.1020299 0.0994657 0.0982054 0.1000713 0.1009089 0.0987054 0.0991798 0.1005834 0.0989396 0.0966685 0.1053516 0.1003812
Percent teen mothers pct_teen 2010 0.0990808 0.0959498 0.0913103 0.0892177 0.0910416 0.0931227 0.0905454 0.0919546 0.0921467 0.0919932 0.0889166 0.1015515 0.0930001
Percent teen mothers pct_teen 2011 0.0906889 0.0865392 0.0834186 0.0819645 0.084794 0.0833873 0.0818868 0.0819408 0.083903 0.0823297 0.0797972 0.0926304 0.0843654
Percent teen mothers pct_teen 2012 0.083518 0.0804846 0.0774616 0.0758669 0.0770543 0.0768937 0.0761991 0.0765446 0.0774741 0.077609 0.0749987 0.0845283 0.0781441
Percent unmarried mothers pct_unmarried 1968 0.1056095 0.1038318 0.0985154 0.0972879 0.0977235 0.0996964 0.0957742 0.0988225 0.1024497 0.0989224 0.0973779 0.1050366 0.100007
Percent unmarried mothers pct_unmarried 1969 0.1028541 0.1019378 0.0995966 0.0940118 0.0999753 0.1014997 0.1031019 0.1051473 0.1048511 0.1012252 0.0974243 0.1049921 0.1014286
Percent unmarried mothers pct_unmarried 1970 0.1086899 0.1068598 0.103899 0.1042211 0.1073876 0.1113596 0.10646 0.1105566 0.1084094 0.105769 0.104503 0.1117052 0.10753
Percent unmarried mothers pct_unmarried 1971 0.1162652 0.1130465 0.1112258 0.1121346 0.1146703 0.1183695 0.1133768 0.1167429 0.1220711 0.1146322 0.1120314 0.1175643 0.1152083
Percent unmarried mothers pct_unmarried 1972 0.1281008 0.1258705 0.1232145 0.1223776 0.1296671 0.1296258 0.1254808 0.1308376 0.1379894 0.1296586 0.1235845 0.1313342 0.1282413
Percent unmarried mothers pct_unmarried 1973 0.139937 0.1371452 0.1338929 0.1321522 0.1343792 0.133789 0.1270101 0.1332072 0.1371847 0.129194 0.1313276 0.1409214 0.1341451
Percent unmarried mothers pct_unmarried 1974 0.1441215 0.1357481 0.1327509 0.131284 0.1350502 0.137415 0.1297453 0.1340222 0.1381349 0.1348438 0.1297099 0.1454861 0.1356326
Percent unmarried mothers pct_unmarried 1975 0.1477272 0.1460931 0.1411129 0.1426218 0.14694 0.1498106 0.1441377 0.1484883 0.1499891 0.1461234 0.141599 0.1504145 0.1462909
Percent unmarried mothers pct_unmarried 1976 0.1522249 0.1467884 0.1421555 0.1441298 0.1512881 0.1520538 0.1452872 0.1495119 0.1539011 0.147547 0.1444334 0.153947 0.148685
Percent unmarried mothers pct_unmarried 1977 0.1614584 0.1581993 0.1580894 0.1554589 0.1618086 0.1607406 0.1517992 0.1584582 0.1638556 0.1545984 0.1557855 0.1644677 0.1586899
Percent unmarried mothers pct_unmarried 1978 0.1658374 0.1608812 0.1564377 0.1604427 0.1670736 0.1679354 0.1586184 0.1604091 0.1708466 0.165353 0.1572778 0.1657745 0.1631735
Percent unmarried mothers pct_unmarried 1979 0.172442 0.1676365 0.1622801 0.1650034 0.1749978 0.1762123 0.1682428 0.1726285 0.1781974 0.1719084 0.1647695 0.1783512 0.1711743
Percent unmarried mothers pct_unmarried 1980 0.1868781 0.1807452 0.1764007 0.1815257 0.1854482 0.1864709 0.1760908 0.178932 0.1845413 0.1794513 0.1749465 0.1890908 0.181726
Percent unmarried mothers pct_unmarried 1981 0.1888832 0.1832825 0.1805929 0.1852685 0.1897817 0.1883507 0.1821234 0.1876568 0.1923229 0.1832895 0.1810909 0.1936149 0.1863722
Percent unmarried mothers pct_unmarried 1982 0.195937 0.1911741 0.1839833 0.1890869 0.1940393 0.1951893 0.1872018 0.1927122 0.1966251 0.1903623 0.1848005 0.1992999 0.1916877
Percent unmarried mothers pct_unmarried 1983 0.202099 0.1960343 0.1913797 0.1958644 0.2040871 0.2021214 0.1986576 0.2023185 0.2054832 0.1993534 0.1924992 0.2062753 0.19968
Percent unmarried mothers pct_unmarried 1984 0.210518 0.2043366 0.1981066 0.2027662 0.2101318 0.2105004 0.2041214 0.207312 0.2153955 0.2055599 0.1983346 0.2138255 0.2067811
Percent unmarried mothers pct_unmarried 1985 0.217425 0.2129642 0.2092232 0.2148607 0.2230201 0.2261698 0.2204237 0.2269384 0.2322704 0.224707 0.2104679 0.2218834 0.2201285
Percent unmarried mothers pct_unmarried 1986 0.2334266 0.2312039 0.2241741 0.2298392 0.2350371 0.2385992 0.2312498 0.2396283 0.2456931 0.2331191 0.2247575 0.2385699 0.2337847
Percent unmarried mothers pct_unmarried 1987 0.2457921 0.2379437 0.2344921 0.2391831 0.2477031 0.2492454 0.2464972 0.2514302 0.253167 0.2465264 0.2353042 0.2505561 0.2448366
Percent unmarried mothers pct_unmarried 1988 0.2572914 0.2495919 0.2466614 0.2540163 0.2630093 0.262346 0.2578992 0.2620158 0.2661503 0.2572968 0.2465575 0.260595 0.2570347
Percent unmarried mothers pct_unmarried 1989 0.270155 0.2649109 0.2615591 0.2676574 0.2763324 0.2771645 0.2701902 0.272891 0.2786103 0.2726975 0.2585894 0.2748838 0.270571
Percent unmarried mothers pct_unmarried 1990 0.279235 0.2727389 0.2677345 0.2745212 0.2847949 0.2851485 0.2819418 0.2869906 0.2947833 0.2808939 0.265946 0.286159 0.2800647
Percent unmarried mothers pct_unmarried 1991 0.2964486 0.2899295 0.2841581 0.2910693 0.2979795 0.3009613 0.2944359 0.3009426 0.3044659 0.2960902 0.2836302 0.3008498 0.2950751
Percent unmarried mothers pct_unmarried 1992 0.3035317 0.2958539 0.2925816 0.2951851 0.3019664 0.3044343 0.3033319 0.3093415 0.3116304 0.3005072 0.2902228 0.3055303 0.3011293
Percent unmarried mothers pct_unmarried 1993 0.3127855 0.3061591 0.2996469 0.3020795 0.3127307 0.3136183 0.3095679 0.3138554 0.318375 0.3088155 0.2995618 0.321319 0.3098279
Percent unmarried mothers pct_unmarried 1994 0.3327377 0.3235523 0.3151681 0.3184685 0.3268251 0.3299024 0.3269458 0.3300507 0.3343137 0.3243419 0.3128766 0.3383022 0.3260779
Percent unmarried mothers pct_unmarried 1995 0.3287131 0.3164636 0.3103009 0.3154015 0.3260068 0.3241649 0.3191417 0.3228843 0.3307471 0.3194866 0.3080404 0.3369282 0.32143
Percent unmarried mothers pct_unmarried 1996 0.3286085 0.3201919 0.3128196 0.3217879 0.3262926 0.3288434 0.3218448 0.3263185 0.3319627 0.3214828 0.3096628 0.3350976 0.3237334
Percent unmarried mothers pct_unmarried 1997 0.3283675 0.3201009 0.3136943 0.3177866 0.3238941 0.3246724 0.3221757 0.3334482 0.3348068 0.3212883 0.310369 0.3370719 0.323891
Percent unmarried mothers pct_unmarried 1998 0.3329743 0.325662 0.3179911 0.3215174 0.3275032 0.330652 0.3256038 0.3350917 0.3375159 0.3254925 0.3158475 0.3414306 0.3280378
Percent unmarried mothers pct_unmarried 1999 0.3361593 0.3266591 0.3207749 0.3225258 0.332748 0.3331334 0.3299495 0.3324199 0.3401595 0.3279887 0.3186408 0.3434368 0.3303445
Percent unmarried mothers pct_unmarried 2000 0.3378125 0.3279892 0.3224988 0.3253787 0.3343483 0.333227 0.3310152 0.3364424 0.3435629 0.3288902 0.31658 0.3433239 0.3317295
Percent unmarried mothers pct_unmarried 2001 0.3380301 0.332138 0.3273124 0.3293871 0.3360088 0.336424 0.3320323 0.3400964 0.3463467 0.3337938 0.322471 0.3462778 0.3349663
Percent unmarried mothers pct_unmarried 2002 0.343343 0.3360018 0.3285496 0.3355769 0.3394813 0.3405326 0.340629 0.348003 0.3515012 0.3370617 0.3230266 0.3506217 0.3394724
Percent unmarried mothers pct_unmarried 2003 0.347573 0.3387579 0.3322887 0.3378252 0.3448876 0.3505849 0.3485954 0.3581719 0.3619739 0.3469786 0.3306502 0.3543069 0.3460191
Percent unmarried mothers pct_unmarried 2004 0.3586387 0.3494294 0.3425798 0.347295 0.3583363 0.3589581 0.3615565 0.3702547 0.3752308 0.3559264 0.3421524 0.3673997 0.3573244
Percent unmarried mothers pct_unmarried 2005 0.3681795 0.3585533 0.3571272 0.3603911 0.3683813 0.36872 0.3737116 0.3809681 0.3865408 0.3706504 0.3537295 0.3786194 0.3687722
Percent unmarried mothers pct_unmarried 2006 0.3838766 0.3730832 0.3692671 0.3735529 0.3850496 0.3886857 0.3906754 0.3969599 0.404066 0.3899209 0.3663593 0.3935389 0.384708
Percent unmarried mothers pct_unmarried 2007 0.3989474 0.389754 0.3830605 0.3889651 0.3983952 0.3992539 0.4015467 0.4076686 0.4147793 0.4006158 0.3791848 0.4026212 0.397107
Percent unmarried mothers pct_unmarried 2008 0.4099639 0.403634 0.396171 0.3977235 0.4039856 0.4075016 0.4050506 0.415774 0.41831 0.4075544 0.391253 0.4185086 0.4062368
Percent unmarried mothers pct_unmarried 2009 0.415091 0.4045598 0.3973121 0.4030938 0.40893 0.4131517 0.4096313 0.4174936 0.4221072 0.4084029 0.3963785 0.4225259 0.4097913
Percent unmarried mothers pct_unmarried 2010 0.4173015 0.4051041 0.3955685 0.3964019 0.4052823 0.4085536 0.4090531 0.4151003 0.4204731 0.4060932 0.3936193 0.4266003 0.4081712
Percent unmarried mothers pct_unmarried 2011 0.4128969 0.4013218 0.3918535 0.3964071 0.4068956 0.4077272 0.4068882 0.4128859 0.4217497 0.4064155 0.3893296 0.4229595 0.406397
Percent unmarried mothers pct_unmarried 2012 0.4133843 0.4036357 0.3935989 0.3997425 0.406512 0.4067123 0.4058934 0.4132808 0.4180822 0.4070947 0.3912764 0.4242599 0.4069116
<!DOCTYPE HTML>
<meta charset="utf-8">
<html>
<head>
<link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=Source+Sans+Pro:400italic,600italic,700italic,200,300,400,600,700,900">
<script src="http://d3js.org/d3.v3.min.js"></script>
<style>
body, h1, h2, h3, p {
margin: 0;
padding: 0;
font-family: 'Source Sans Pro', sans-serif;
font-size: 1em;
color: #333;
font-weight: 400;
}
#content {
margin: 5px;
padding: 20px 10px 20px 20px;
width: 720px;
text-align: left;
border: 1px solid #ccc;
}
.axis path,
.axis line {
fill: none;
stroke: #000;
shape-rendering: crispEdges;
}
.axis path {
fill: none;
stroke: #000;
shape-rendering: crispEdges;
}
#chart {
margin: 0px;
padding: 0px;
}
h1 {
margin: 0;
padding: 0;
line-height: 1em;
font-size: 1.75em;
font-weight: 900;
color: #000;
}
p {
margin: 5px 0px 0px 0px;
padding: 0;
}
#menu {
margin: 5px 0px 0px 0px;
padding: 0;
display: block;
}
.axis path, .axis line {
fill: none;
stroke: #ccc;
shape-rendering: crispEdges;
border-width: 2px;
}
.axis line {
stroke: #eee;
stroke-width: 1;
shape-rendering: crispEdges;
}
.domain {
stroke-width: 1px;
}
path.line {
fill: none;
stroke-width: 1.5px;
}
.x.axis .tick text, .y.axis .tick text, .month text {
color: #333;
font-size: 0.9em;
padding: 5px;
}
.g-baseline line {
stroke: #333;
stroke-width: 2;
shape-rendering: crispEdges;
}
.month text {
display: none;
}
.month:hover text {
display: block;
}
.month .line {
opacity: 0.4;
}
.month .line:hover {
opacity: 1;
}
</style>
</head>
<body>
<div id="content">
<h1>Why Do Single Moms Have Children in January?</h1>
<p>New research* has found that women who give birth in different parts of the year tend to have different characteristics. The figure below displays this seasonal variation over the last 45 years.</p>
<select id="menu">
<option value="pct_black">Percent black mothers</option>
<option value="pct_white">Percent white mothers</option>
<option value="pct_teen">Percent teen mothers</option>
<option value="pct_unmarried">Percent unmarried mothers</option>
</select>
<div id="chart"></div>
<p>*Buckles, K. S. and Hungerman, D. M. (2013). Season of Birth and Later Outcomes: Old Questions, New Answers. <em>Review of Economics and Statistics</em>, 95(3):711&ndash;724.</p>
<p>Source: National Bureau of Economic Research, Centers for Disease Control and Prevention.</p>
</div>
<script src="chart.js"></script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment