2
我试图创建上面使用D3填写饼图圆环图D3
图像内http://jsfiddle.net/Spwizard/LBzx7/1/
var dataset = {
hddrives: [20301672, 9408258, 2147483, 21474836, 35622,32210000],
};
var width = 460,
height = 300,
radius = Math.min(width, height)/2;
var color = d3.scale.ordinal()
.range(["#2DA7E2"]);
var pie = d3.layout.pie()
.sort(null);
var arc = d3.svg.arc()
.innerRadius(radius - 100)
.outerRadius(radius - 70);
var svg = d3.select("body").append("svg")
.attr("width", width)
.attr("height", height)
.append("g")
.attr("transform", "translate(" + width/2 + "," + height/2 + ")");
var path = svg.selectAll("path")
.data(pie(dataset.hddrives))
.enter().append("path")
.attr("class", "arc")
.attr("fill", function(d, i) { return color(i); })
.attr("d", arc);
svg.append("text")
.attr("dy", ".35em")
.style("text-anchor", "middle")
.attr("class", "inside")
.text(function(d) { return '56%'; });
svg.append("text")
.attr("dy", "2em")
.style("text-anchor", "middle")
.attr("class", "data")
.text(function(d) { return 'some text'; });
进出口挣扎来看看如何应对内的背景颜色圈和处理留下的存储空间
感谢
对于前者,您可以追加一个单独的'circle'并相应地填充它。对于后者,您需要一个虚拟元素来表示您不知道绘制的可用空间。 –
谢谢我已经更新了小提琴来排序背景,只是不知道如何处理自由空间 –
像[this](http://jsfiddle.net/LBzx7/2/)这样的设置不透明度的基础在属性上。 –