Skip to content

Instantly share code, notes, and snippets.

@dceoy
Last active August 29, 2015 14:20
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 dceoy/71b175c0b0f612927995 to your computer and use it in GitHub Desktop.
Save dceoy/71b175c0b0f612927995 to your computer and use it in GitHub Desktop.
<!DOCTYPE HTML>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>D3 Word Clouds</title>
<meta name="author" content="d4i"/>
</head>
<body>
<script src="https://rawgit.com/mbostock/d3/master/d3.min.js"></script>
<script src="https://rawgit.com/jasondavies/d3-cloud/master/d3.layout.cloud.js"></script>
<script>
var filename = 'https://rawgit.com/dceoy/71b175c0b0f612927995/raw/word_count.csv';
d3.csv(filename, function(data){
data = data.splice(0, 100);
var width = 1200,
height = 600,
fill = d3.scale.category20(),
maxcount = d3.max(data, function(d){ return d.count; } ),
wordcount = data.map(function(d) { return {text: d.word, size: d.count / maxcount * 10}; });
d3.layout.cloud().size([width, height])
.words(wordcount)
.padding(5)
.rotate(function() { return ~~(Math.random() * 2) * 90; })
.font("Impact")
.fontSize(function(d) { return d.size; })
.on("end", draw)
.start();
function draw(words) {
d3.select("body").append("svg")
.attr({
"width": width,
"height": height
})
.append("g")
.attr("transform", "translate(" + [ width >> 1, height >> 1 ] + ")")
.selectAll("text")
.data(words)
.enter()
.append("text")
.style({
"font-size": function(d) { return d.size + "px"; },
"font-family": "Impact",
"fill": function(d, i) { return fill(i); }
})
.attr({
"text-anchor": "middle",
"transform": function(d) { return "translate(" + [d.x, d.y] + ")rotate(" + d.rotate + ")"; }
})
.text(function(d) { return d.text; });
}
});
</script>
</body>
</html>
count word
26456 Enbrel
8300 TYSABRI
8280 Tarceva
6310 PEGASYS
6288 RIBAVIRIN
5635 AVONEX
5366 NEXIUM
4688 METHOTREXATE
4466 Avastin
4367 ASPIRIN
4356 Incivek
3948 PREDNISONE
3887 CRESTOR
3411 REMICADE
3283 OMEPRAZOLE
3145 Mirena
3123 LISINOPRIL
2970 FOLIC ACID
2881 Lyrica
2821 HUMIRA
2807 SIMVASTATIN
2483 METFORMIN
2446 PRADAXA
2414 SPIRIVA
2280 GLIVEC
2143 SYNTHROID
2121 ABILIFY
2099 IBUPROFEN
2058 METOPROLOL
2057 DIANEAL LOW CALCIUM
2005 AMLODIPINE
1930 REBIF
1903 FOSAMAX
1866 REVLIMID
1828 Aleve caplet/tablet
1792 FUROSEMIDE
1773 CALCIUM
1736 REBETOL
1731 CYMBALTA
1711 LEVOTHYROXINE
1708 VITAMIN D
1698 Xeloda
1695 VX-950
1688 ATENOLOL
1675 PREDNISOLONE
1675 DEXAMETHASONE
1648 LIPITOR
1620 Prolia
1620 PLAVIX
1596 SEROQUEL
1590 Yaz
1558 GABAPENTIN
1510 PARACETAMOL
1466 LASIX
1464 Avandia
1456 XARELTO
1433 PEGINTRON
1421 VX-950 (Telaprevir)
1383 Yasmin
1362 FORTEO
1329 FISH OIL
1313 TYLENOL
1306 CYCLOPHOSPHAMIDE
1294 LANTUS
1267 HYDROCHLOROTHIAZIDE
1231 XANAX
1203 LORAZEPAM
1194 PRILOSEC
1192 DIOVAN
1181 PLAN B ONE-STEP
1174 Chantix
1166 ALLOPURINOL
1164 Lipitor
1154 ACLASTA
1146 COUMADIN
1138 RAMIPRIL
1137 LETAIRIS
1126 WARFARIN
1103 CITALOPRAM
1080 VICTRELIS
1077 TRACLEER
1060 LYRICA
1057 SINGULAIR
1027 NORVASC
1019 Capecitabine
1011 DARVOCET
1010 TRAMADOL
1000 ZOMETA
991 Genotropin
980 CISPLATIN
963 METOCLOPRAMIDE
947 CLONAZEPAM
943 AMBIEN
939 MIRALAX
938 PROZAC
932 CARBOPLATIN
922 GILENYA
920 Sutent
920 Rituxan
896 OXYCODONE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment