我想在一个矩形中写入文本,我是这样创建矩形的:
body = d3.select('body')
svg = body.append('svg').attr('height', 600).attr('width', 200)
rect = svg.append('rect').transition().duration(500).attr('width', 150)
.attr('height', 100)
.attr('x', 40)
.attr('y', 100)
.style('fill', 'white')
.attr('stroke', 'black')
text = svg.append('text').text('This is some information about whatever')
.attr('x', 50)
.attr('y', 150)
.attr('fill', 'black')
然而,正如你所看到的 (http://jsfiddle.net/Tmj7g/3/),文字被截断了。有没有巧妙的方法在创建的 SVG 矩形内部编写段落?谢谢。