Skip to content

Instantly share code, notes, and snippets.

@max-l
Last active December 13, 2018 01:06
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 max-l/b49fa3d68febea58002b411e6308502f to your computer and use it in GitHub Desktop.
Save max-l/b49fa3d68febea58002b411e6308502f to your computer and use it in GitHub Desktop.
select and grouping
license: mit
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<script src="https://d3js.org/d3.v4.min.js"></script>
<style>
body { margin:0;position:fixed;top:0;right:0;bottom:0;left:0; }
</style>
</head>
<body>
<script>
var matrix2 = [
{r:"r1", da: [11975, 5871, 8916, 2868]},
{r:"r2", da: [1951, 10048, 2060, 6171]},
];
var tr = d3.select("body")
.append("table")
.selectAll("tr")
.data(matrix2)
.enter().append("tr").text(d => d.r)
var td = tr.selectAll("td")
.data(d => d.da)
.enter().append("td")
.text(d => '+'+d);
</script>
</body>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment