score:1

Accepted answer

Giving it an x and y was enough like @jrook suggested. (default fill is black)

var svg = d3.select("body").append("svg")
        .attr("width", 500)
        .attr("height", 500);
    var nodes = [
        { "name": "Michael" },
        { "name": "John" }
    ];
    svg
        .selectAll("text")
        .data(nodes)
        .enter()
        .append("text")
        .text(function(d) { return d.name; })
        .attr('x', 20)
        .attr('y', (d, i) => 30 + 20 * i);
<script src="https://d3js.org/d3.v5.min.js"></script>


Related Query

More Query from same tag