我在这里有代码,我需要在所有六边形右侧的rect元素中添加文本,并使其像div中的段落一样具有给定的高度和宽度,并使其正确包裹。这是jsfiddle。以下是绘制rect的代码: http://jsfiddle.net/2nykc/
var infoRect = svgContainer.append("rect");
var infoRectAttr = infoRect.attr("x", function(){
return infoDivX;
})
.attr("y", function(){
return infoDivY;
})
.attr("width", function(){
return infoDivWidth;
})
.attr("height", function(){
return infoDivHeight;
})
.style("fill", "rgb(30,180,134)")
.style("stroke", "black")
.style("stroke-width", 3)
.attr("id", "infoRect");