@rollin
To draw text in a rectangle in D3, you can use the following steps:
1 2 3 4 5 6 |
svg.append("rect") .attr("x", 50) .attr("y", 50) .attr("width", 200) .attr("height", 100) .attr("fill", "lightgrey"); |
1 2 3 4 5 |
svg.append("text") .attr("x", 100) .attr("y", 100) .text("Hello, D3!") .attr("fill", "black"); |
1 2 3 4 5 6 7 8 9 |
svg.append("text") .attr("x", 100) .attr("y", 100) .text("Hello, D3!") .attr("fill", "black") .style("font-family", "Arial") .style("font-size", "16px") .style("text-anchor", "middle") .style("alignment-baseline", "middle"); |
By following these steps, you can draw text inside a rectangle in D3 and customize its appearance as needed.