Created
September 26, 2015 22:20
-
-
Save kcsluis/aafc82181e4194b35af6 to your computer and use it in GitHub Desktop.
Tables
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
group | x | y | |
---|---|---|---|
I | 10 | 8.04 | |
I | 8 | 6.95 | |
I | 13 | 7.58 | |
I | 9 | 8.81 | |
I | 11 | 8.33 | |
I | 14 | 9.96 | |
I | 6 | 7.24 | |
I | 4 | 4.26 | |
I | 12 | 10.84 | |
I | 7 | 4.82 | |
I | 5 | 5.68 |
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> | |
<head> | |
<meta charset="utf-8"> | |
<title></title> | |
<style type="text/css"> | |
/*css*/ | |
table { | |
border-collapse: collapse; | |
} | |
td, th { | |
text-align: right; | |
border-bottom: 1px solid #CCC; | |
padding: 3px; | |
} | |
.tableRow:hover { | |
background-color: #ccc; | |
cursor: pointer; | |
} | |
</style> | |
</head> | |
<body> | |
<table></table> | |
</body> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/d3.min.js" charset="utf-8"></script> | |
<script> | |
d3.tsv("group1.tsv", ready); | |
function ready(error, data) { | |
if (error) return console.warn(error); | |
var d3Table = d3.select("table"); | |
var tableTitle = d3Table.append("tr"); | |
tableTitle.append("th") | |
.text("x") | |
.attr("class", "tableTitle"); | |
tableTitle.append("th") | |
.text("y") | |
.attr("class", "tableTitle"); | |
var d3Tabler = d3Table.selectAll(".tableRow") | |
.data(data) | |
.enter() | |
.append("tr") | |
.attr("class", "tableRow") | |
d3Tabler.append("td") | |
.text( function (d) { return d.x; }); | |
d3Tabler.append("td") | |
.text( function (d) { return d.y; }); | |
}; | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment