如何在D3中用白色填充文本

时间:2015-06-13 05:01:36

标签: text d3.js colors

下面是在圆圈内绘制文字的代码,我希望这个文字用白色而不是黑色填充,但它是黑色而不是白色。知道这些代码有什么问题。为什么文字是黑色而不是白色

    d3text.text(value); // value is dynamically generated text  
    d3text.style('font-size', function() {  
    myFontSize = Math.min(2 * (radiusSize - 16), (2 * radiusSize - 16) / 
((this.getComputedTextLength() + 16) * 2) * 24);  
    myFontSize = Math.round((myFontSize < 12) ? MINFONTSIZE : myFontSize);
    return (myFontSize + 'px');  
    });  
    d3text.style('fill', 'while');  
    d3text.textAnchor = 'middle'; 

1 个答案:

答案 0 :(得分:1)

d3text.style('fill', 'while');更改为d3text.style('fill', 'white');