Skip to content

Instantly share code, notes, and snippets.

@molliemarie
Last active March 31, 2017 04:28
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 molliemarie/c7a263e631bb55f555beb2bbd0c00bdf to your computer and use it in GitHub Desktop.
Save molliemarie/c7a263e631bb55f555beb2bbd0c00bdf to your computer and use it in GitHub Desktop.
Most Popular Girl Baby Names of 1986

Remember those names that were suffocatingly prevalent during your schooling days? During my time, it was the throngs of Jessicas, swarms of Ashleys, gaggles Jennifers, etc. I was curious to see the rise and fall of the girl names most popular during my youth. Additionally, I wanted to see how they compared to my name, Mollie - or the more commonly used spelling, Molly.

I found this interesting for two reasons.

  1. It shows the stylish and trendy nature of the most popular names, with their distinct rises and falls.
  2. It proves that I am, in fact, a unique snowflake (at least in comparison). :)
<!DOCTYPE html>
<meta charset="utf-8">
<style>
/*.x-axis path {
display: none;
}*/
.line {
fill: none;
stroke: Plum;
stroke-width: 1.5px;
}
/*When line is attached with class "hovering, darken and thicken line*/
text.text.hovering {
fill: black;
}
text.text {
font: bold 10px sans-serif;
fill: transparent;
}
.hovering > path.line {
stroke-width: 5px;
stroke: Indigo;
}
.hovering > text {
fill: black;
}
/*line:hover {
stroke-width: 5;
}*/
</style>
<svg width="900" height="500"></svg>
<script src="//d3js.org/d3.v4.min.js"></script>
<script>
var svg = d3.select("svg"),
margin = {top: 30, right: 80, bottom: 30, left: 50},
w = svg.attr("width") - margin.left - margin.right,
h = svg.attr("height") - margin.top - margin.bottom;
var xScale = d3.scaleTime().range([0, w]),
yScale = d3.scaleLinear().range([h, 0]),
ordinalScale = d3.scaleOrdinal(d3.schemeCategory10);
var g = svg.append("g").attr("transform", "translate(" + margin.left + "," + margin.top + ")");
var parseTime = d3.timeParse("%Y%m%d");
var line = d3.line()
.curve(d3.curveBasis)
.x(function(d) { return xScale(d.date); })
.y(function(d) { return yScale(d.count); });
d3.csv("names.csv", type, function(error, data) {
if (error) throw error;
// setup name data. Creates objects with each name as the id and count & date as values associated with each name.
var names = data.columns.slice(1).map(function(id) {
return {
id: id,
values: data.map(function(d) {
return {date: d.date, count: d[id]};
})
};
});
// x, y, and ordinal(name data) scales
xScale.domain(d3.extent(data, function(d) { return d.date; }));
yScale.domain([0,
d3.max(names, function(c) { return d3.max(c.values, function(d) { return d.count; }); })
]);
ordinalScale.domain(names.map(function(c) { return c.id; }));
// add chart title
g.append("text")
.attr("x", (w / 2))
.attr("y", 0 - (margin.top / 2))
.attr("text-anchor", "middle")
.attr("font-family", "sans-serif")
.attr("font-weight", "bold")
.style("font-size", "16px")
.text("Most popular female baby names of 1986 (plus Mollie) over time");
// x axis
g.append("g")
.attr("class", "axis x-axis")
.attr("transform", "translate(0," + h + ")")
.call(d3.axisBottom(xScale));
// Y axis
g.append("g")
.attr("class", "axis y-axis")
.call(d3.axisLeft(yScale))
.append("text")
.attr("transform", "translate(" + (-margin.left + 8) + "," + ((h - margin.top - margin.bottom)/2) + ") rotate(-90)")
.attr("fill", "#000")
.style("text-anchor", "center")
.text("Babies");
var name = g.selectAll(".name")
.data(names)
.enter().append("g")
.attr("class", "name");
// create lines
var namePath = name.append("path")
.attr("class", "line")
.attr("d", function(d) { return line(d.values); })
// on mouseover of line, attach "hovering" class to line
// add name labels
var nameText = name.append("text")
.datum(function(d) { return {id: d.id, value: d.values[d.values.length - 1]}; })
.attr("class", "text")
.attr("transform", function(d) { return "translate(" + xScale(d.value.date) + "," + yScale(d.value.count) + ")"; })
.attr("x", 3)
.attr("dy", "0.35em")
.text(function(d) { return d.id; });
// when you mouseover name labels, add "hovering" class to associated line
function handleHover (currentElement) {
currentElement.on("mouseover", function () {
d3.select(this.parentElement).classed("hovering", true);
}).on("mouseleave", function() {
d3.select(this.parentElement).classed("hovering", false);
});
}
handleHover(namePath)
handleHover(nameText);
});
// parse dates
function type(d, _, columns) {
d.date = parseTime(d.date);
for (var i = 1, n = columns.length, c; i < n; ++i) d[c = columns[i]] = +d[c];
return d;
}
</script>
date Mollie Molly Jessica Ashley Amanda Jennifer Sarah Stephanie Nicole Brittany Heather Elizabeth
18800101 283 18 7 0 241 0 1288 0 0 0 0 1939
18810101 281 33 7 0 263 0 1226 0 0 0 0 1852
18820101 305 30 8 0 288 0 1410 0 0 0 0 2186
18830101 301 30 6 0 287 0 1359 0 0 0 0 2255
18840101 374 32 14 0 337 0 1518 0 0 0 0 2549
18850101 396 30 6 0 339 0 1424 0 0 0 0 2582
18860101 421 29 11 0 370 0 1569 0 0 0 0 2680
18870101 333 32 8 0 338 0 1436 0 0 0 0 2681
18880101 375 37 18 0 404 0 1755 0 0 0 0 3224
18890101 402 35 9 0 413 0 1730 0 0 0 0 3058
18900101 349 46 18 0 392 0 1786 0 0 0 0 3112
18910101 356 33 14 0 371 0 1669 5 0 0 0 3059
18920101 411 51 14 0 455 0 1799 9 0 0 0 3461
18930101 367 58 15 0 387 0 1632 8 0 0 0 3360
18940101 379 36 10 0 418 0 1701 8 0 0 0 3425
18950101 382 45 19 0 431 0 1777 8 0 0 0 3603
18960101 374 49 9 0 367 0 1691 13 0 0 0 3471
18970101 333 50 9 0 354 0 1713 20 0 0 0 3442
18980101 357 39 13 0 371 0 1800 14 0 0 0 3659
18990101 301 47 14 0 326 0 1587 15 0 0 0 3287
19000101 437 67 23 0 377 0 2055 25 0 0 0 4096
19010101 324 55 8 0 317 0 1514 17 0 0 0 3216
19020101 337 54 9 0 301 0 1710 12 0 0 0 3694
19030101 284 75 16 0 247 0 1553 33 0 0 0 3723
19040101 336 72 16 0 294 0 1594 32 0 0 0 3833
19050101 344 71 17 0 311 0 1762 36 0 0 0 4121
19060101 355 86 18 0 260 0 1697 35 0 0 0 4321
19070101 356 113 17 0 285 0 1799 43 0 0 0 4624
19080101 341 101 17 0 260 0 1814 68 0 0 0 4904
19090101 361 109 18 0 271 0 1845 63 0 0 0 5176
19100101 399 145 28 0 278 0 2173 88 0 0 0 5800
19110101 378 129 21 0 280 0 2201 118 0 0 0 6298
19120101 463 197 36 0 310 0 2919 165 0 0 0 8528
19130101 506 197 25 0 346 0 3178 185 0 0 0 9505
19140101 644 247 42 0 375 0 3680 280 0 0 8 11367
19150101 738 325 55 0 412 0 4414 361 0 0 0 14103
19160101 650 333 53 0 421 5 4796 397 0 0 0 14939
19170101 672 310 55 5 445 0 4768 394 0 0 5 15131
19180101 701 306 56 0 397 0 4969 374 0 0 0 15851
19190101 638 258 40 0 379 6 5020 311 0 0 0 15288
19200101 560 246 43 0 379 7 5032 313 0 0 5 15910
19210101 570 302 48 0 392 5 5023 305 0 0 0 15800
19220101 532 277 40 0 341 7 4982 223 0 0 5 15243
19230101 491 293 52 0 362 9 4964 244 0 0 8 15461
19240101 431 290 41 0 341 11 5043 224 0 0 0 14950
19250101 413 241 34 0 310 9 4687 165 0 0 0 13932
19260101 394 255 35 0 310 10 4422 166 0 0 0 12834
19270101 370 258 39 0 234 5 4559 127 0 0 0 12527
19280101 358 314 36 0 247 7 4244 124 0 0 0 11765
19290101 354 320 42 0 209 17 3816 98 0 0 9 11250
19300101 353 342 38 0 196 17 3920 102 0 0 9 10993
19310101 327 300 39 0 209 26 3633 89 0 0 7 10295
19320101 283 314 44 0 213 25 3599 131 0 0 11 9994
19330101 272 271 43 0 199 30 3619 106 0 0 30 9015
19340101 284 293 46 0 189 41 3598 128 0 0 41 9342
19350101 282 301 47 0 211 36 3617 156 0 0 63 9075
19360101 237 316 43 7 192 42 3515 169 0 0 52 8860
19370101 226 306 72 0 176 38 3585 209 9 0 52 9386
19380101 252 328 50 0 192 52 3748 233 7 0 76 9801
19390101 257 348 77 0 185 62 3670 283 12 0 94 9705
19400101 241 346 61 0 218 102 3870 394 25 0 106 9954
19410101 234 339 81 6 223 136 3981 491 32 0 131 10269
19420101 237 375 127 8 295 199 4100 664 69 0 159 11180
19430101 242 386 121 10 284 337 3987 800 89 0 166 11650
19440101 224 366 124 12 238 686 3860 898 58 0 131 11034
19450101 215 333 132 10 280 986 3593 871 61 0 175 10335
19460101 205 415 240 7 274 1733 3906 1508 80 0 237 11751
19470101 243 484 430 11 310 2013 4223 1693 66 0 273 13442
19480101 243 562 482 13 306 1881 4156 2103 68 0 215 13208
19490101 230 556 406 11 333 2623 4298 2516 69 0 249 13711
19500101 214 565 402 15 379 2802 4145 2643 89 0 310 14339
19510101 187 611 466 15 409 2973 4034 2573 94 0 308 15112
19520101 242 617 452 24 418 3531 4039 2932 103 0 381 16022
19530101 239 582 495 15 428 3376 4081 3083 119 0 427 16092
19540101 187 599 424 21 428 3960 4040 3369 110 0 541 16580
19550101 184 623 386 8 452 4127 3982 3757 119 0 614 16689
19560101 205 654 406 25 643 4711 3876 3912 153 0 661 16344
19570101 208 699 476 27 667 5482 3984 4216 141 0 665 17496
19580101 186 746 529 38 796 5881 3910 4250 180 0 732 18529
19590101 166 762 523 37 858 6232 3874 4827 204 0 912 18438
19600101 171 730 560 57 977 7243 4205 5267 243 0 972 18858
19610101 147 781 669 80 1057 9265 4207 5810 273 0 1103 18851
19620101 112 820 867 95 948 10980 4546 6266 564 0 1284 17800
19630101 129 860 1121 108 1035 11760 4576 6823 653 7 2088 17591
19640101 173 1008 1172 180 1275 12960 4587 7938 832 5 2386 17285
19650101 145 1062 1529 218 1650 15211 4056 9761 898 10 2499 16319
19660101 128 983 1665 263 2329 18217 4036 10165 2030 16 2898 15887
19670101 141 1015 1761 386 2663 18239 4138 13350 2773 16 3905 16114
19680101 146 1021 1841 544 2430 26849 4487 12953 3085 33 5501 14892
19690101 167 1093 2492 643 2817 33705 5076 14492 7216 62 10073 15300
19700101 196 1193 4023 932 3550 46160 5620 15390 10692 75 14669 15121
19710101 195 1186 5360 1164 4133 56785 5851 15143 10430 147 15020 13605
19720101 184 1235 6208 1176 4181 63610 6112 16886 15753 201 16325 12188
19730101 170 1330 7226 1253 5627 62455 7216 17262 13922 219 19352 12358
19740101 208 1480 10653 1626 7476 63116 9787 16983 13111 246 23184 12261
19750101 222 1548 12930 1988 12653 58186 11169 15773 14273 332 24303 12475
19760101 204 1732 18370 2292 15591 59478 13994 15179 14457 352 24204 13552
19770101 250 2067 24843 2706 18280 58965 18097 15419 15253 488 23773 16425
19780101 228 1933 26105 3484 20522 56316 19978 16231 17272 630 22269 16808
19790101 274 2024 27777 4450 31927 56720 21017 16204 19509 790 20840 18076
19800101 286 2202 33921 7296 35819 58381 25747 17841 19918 1406 19972 19530
19810101 295 2090 42527 8877 34373 57043 28171 20210 20314 1714 17944 20171
19820101 329 2317 45445 14851 34210 57109 28482 20858 21703 3100 17488 20509
19830101 312 2310 45278 33290 33754 54336 27229 22326 22394 4377 20750 19838
19840101 292 2178 45851 38759 33906 50562 25875 23019 22264 7664 21488 20362
19850101 387 2431 48343 47007 39050 42649 24877 23239 22963 15438 21149 20538
19860101 370 2550 52667 49674 40522 36181 28146 22640 21283 20311 19790 19067
19870101 397 2889 55990 54845 41786 32694 27884 22398 20282 22227 18980 18602
19880101 419 3460 51532 49963 39451 27886 28358 22832 20311 26814 18033 20028
19890101 442 3457 47885 47585 36827 23995 27790 22768 19024 37787 16247 20293
19900101 527 3964 46470 45553 34405 22219 25810 24859 17950 36534 14217 20742
19910101 535 4651 43394 43482 28887 20671 25228 22771 16046 29090 11700 20390
19920101 486 4136 38352 38452 25034 17819 24633 19668 16321 24975 9722 19029
19930101 495 3707 34987 34847 20809 15748 24248 17183 16179 21728 8105 17555
19940101 454 3440 32117 30278 18715 13997 22281 14749 16011 18899 7034 16778
19950101 438 3382 27935 26603 16345 12685 21369 12979 12276 16476 6032 16185
19960101 423 3311 24192 23676 13973 11727 21029 11639 11132 13796 4758 15990
19970101 418 3447 21043 20895 12239 11838 20694 9777 10744 11527 3768 15415
19980101 442 3190 18233 19871 10908 10688 19873 8488 9911 9843 3395 15179
19990101 441 3323 16346 18132 9741 10611 19088 7688 9514 7942 2888 15332
20000101 448 3399 15705 17997 8550 9384 17689 7029 8559 5183 2684 15089
20010101 423 3413 13917 16524 6963 8921 15889 6606 7816 2929 2272 14783
20020101 386 3119 11913 15339 6132 8537 14752 6266 6972 1934 2066 14593
20030101 410 3403 10445 14512 5339 7564 13756 5601 6227 1578 1617 14096
20040101 332 3342 9469 14370 4677 6541 12732 5181 5738 1355 1303 13555
20050101 365 3214 8108 13270 4088 5833 11527 4700 4984 1193 1066 12722
20060101 363 3124 6809 12340 3355 5267 11144 4507 4318 1025 974 12417
20070101 373 3413 5704 11423 3038 4648 9985 3804 3864 914 793 13037
20080101 419 3321 4732 9402 2439 3791 9032 3314 3286 773 651 11990
20090101 419 3504 3793 7811 1952 2986 7767 2919 2764 670 553 11023
20100101 428 3359 3195 6306 1655 2618 6314 2486 2562 728 420 10248
20110101 436 3611 2620 5398 1409 2277 5547 2145 2653 748 391 10071
20120101 437 3254 2327 4696 1228 1922 5174 1882 2651 767 327 9685
20130101 390 3076 1946 3936 1064 1688 4686 1671 3341 718 315 9431
20140101 346 2596 1790 3547 1048 1518 4682 1635 2524 696 330 9537
20150101 266 2235 1577 3409 1013 1275 4476 1554 2106 686 280 9656
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment