我有一个动态创建的图表,因此svg包含一个包含以下代码的部分。 我无法给这个类的背景颜色..我已经尝试使用attr()函数动态,但它不会这样工作.. 无论如何要指定像svg:text ??
这样的CSS<text id="circleText_Persons-bruno-waterfield" font-size="14" class="circleText" font-family="Tahoma" text-anchor="middle" background-color="#000000" font-weight="900" display="block" x="-1.8714285714285717" y="28.711414285714287" fill-opacity="1" stroke-opacity="1" style="fill: #666666;">Bruno Waterfield</text>
动态创建svg文本
nodeEnter.append("svg:text")
.attr("id", function(d){ return "circleText_" + d.name})
.attr("font-size", function(d){return 14;}) //returnNodeSize(d) / 2
.attr("class", function(d){return "circleText"}).attr("font-family", "Tahoma")
.attr("text-anchor","middle")
.attr("background-color","#000000")
.attr("font-weight","900")
//returnNodeSize(d)+returnNodeSize(d)/1.8;
.text(function(d){
return toTitleCase(d.name));
答案 0 :(得分:0)
将所选颜色的rect
放在符合文本边界框的text
元素后面。 SVG文本没有用于设置背景颜色的流程框;你必须做一个。