Last active
February 24, 2016 21:19
-
-
Save ayshabkhan/f9903441837d3e9565b5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<style> | |
table { | |
border-collapse: collapse; | |
border: 2px black solid; | |
font: 12px sans-serif; | |
} | |
td { | |
border: 1px black solid; | |
padding: 5px; | |
} | |
</style> | |
</head> | |
<body> | |
<script src="http://d3js.org/d3.v3.min.js"></script> | |
<script type="text/javascript"charset="utf-8"> | |
var columns = ['page','page_title','active_visitors'] | |
d3.csv("https://analytics.usa.gov/data/live/all-pages-realtime.csv").get(function(errors, rows) { | |
var table = d3.select('body').append('table') | |
var thead = table.append('thead') | |
var tbody = table.append('tbody') | |
thead.append('tr') | |
.selectAll('th') | |
.data(columns) | |
.enter() | |
.append('th') | |
.text(function (d) { return d }) | |
var rows = tbody.selectAll('tr') | |
.data(rows) | |
.enter() | |
.append('tr') | |
var cells = rows.selectAll('td') | |
.data(function(row) { | |
return columns.map(function (column) { | |
return { column: column, value: row[column] } | |
}) | |
}) | |
.enter() | |
.append('td') | |
.text(function (d) { return d.value }) }); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment