Skip to content

Instantly share code, notes, and snippets.

@aaizemberg
Created February 17, 2014 03:13
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 aaizemberg/9044072 to your computer and use it in GitHub Desktop.
Save aaizemberg/9044072 to your computer and use it in GitHub Desktop.
vector --> "html table" using d3.js
<!DOCTYPE html>
<html>
<head>
<script src="http://d3js.org/d3.v3.min.js"></script>
<meta charset="utf-8">
<title>tablas desde d3.js</title>
<style>
table, td, th {
border:1px solid green;
}
th {
background-color:green;
color:white;
}
</style>
</head>
<body>
<script>
var vector = [44,33,22,11];
var table = d3.select("body").append("table");
table.append("tr").append("th").text("título");
table.selectAll("tr")
// .data(vector)
.data(vector, function(d) {return d;} )
.enter()
.append("tr")
.append("td")
.text(function(d) { return d; });
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment