是我的svg元素下的g标签
<g class="nv-legendWrap" transform="translate(0,-10)">
<g class="nv-chart-legend">
<defs>
<clipPath id="nv-edge-clip-legend_5004">
<rect x="0.5" y="0" width="269" height="37"></rect>
</clipPath>
<filter id="legend_back_legend_5004" height="130%">
<feOffset in="SourceGraphic" result="offsetBlur" dx="2" dy="2"></feOffset>
<feColorMatrix in="offsetBlur" result="matrixOut" type="matrix" values="1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0"></feColorMatrix>
<feGaussianBlur in="matrixOut" result="blurOut" stdDeviation="2"></feGaussianBlur>
<feMerge>
<feMergeNode></feMergeNode>
<feMergeNode in="SourceGraphic"></feMergeNode>
</feMerge>
</filter>
</defs>
<rect class="nv-legend-background" x="71.5" y="0.5" width="269" height="37" style="opacity: 0; pointer-events: all; display: inline;" rx="0" ry="0" filter="none"></rect>
<text class="nv-legend-link" text-anchor="end" dy=".36em" dx="0" style="opacity: 0;">Show legend</text>
<g class="nv-legend-mask" clip-path="none" transform="translate(87.5,17)">
<g class="nv-legend" transform="translate(0,0)" style="display: inline; opacity: 1;">
<g class="nv-series" transform="translate(0,0)">
<rect x="-11" y="-12" width="115" height="24" style="fill: rgb(255, 255, 238); opacity: 0.1;"></rect>
<circle r="6" class="nv-slice nv-series-0" fill="#1f77b4" stroke="#1f77b4" style="stroke-width: 2;" transform="translate(0,0)"></circle>
<text dy=".36em" text-anchor="start" transform="translate(11,0)">31440000.000000</text>
</g>
<g class="nv-series" transform="translate(115,0)">
<rect x="-11" y="-12" width="144" height="24" style="fill: rgb(255, 255, 238); opacity: 0.1;"></rect>
<circle r="6" class="nv-slice nv-series-1" fill="#aec7e8" stroke="#aec7e8" style="stroke-width: 2;" transform="translate(0,0)"></circle>
<text dy=".36em" text-anchor="start" transform="translate(11,0)">Others Annual Forecast</text>
</g>
</g>
</g>
在这里你可以看到一个值“31440000.000000”,这个值不断变化,每次都变成不同的数字。无论价值如何变化,我都需要将内容替换为静态测试,如“测试文本”。
我尝试了类似下面的内容
d3.selectAll("svg text")
.filter(function() {
return /^\d/.test(d3.select(this).text()); //
})
.text("Test Text");
但它没有奏效。其实我在这里使用的是nvd3饼图。可以请一位帮助我。