1var data = [
2 ["colours", "green", "blue"],
3 ["shapes", "square", "triangle"],
4 ["languages", "javascript", "c++"]
5];
6
7var svg = d3.select("body")
8 .append("svg")
9 .attr("width", 500)
10 .attr("height", 200);
11
12var groups = svg.selectAll("groups")
13 .data(data)
14 .enter()
15 .append("g")
16 .attr("transform", (d, i) => "translate(" + (50 + i * 100) + ",0)");
17
18var texts = groups.selectAll("texts")
19 .data(d => d)
20 .enter()
21 .append("text")
22 .attr("y", (d, i) => 10 + i * 20)
23 .text(d => d);