相关疑难解决方法(0)

D3.js - 带有多个环的甜甜圈图表

以下示例显示了D3.js中的圆环图,是否可以向图表添加多个环?

var dataset = {
  apples: [53245, 28479, 19697, 24037, 40245],
};

var width = 460,
    height = 300,
    radius = Math.min(width, height) / 2;

var color = d3.scale.category20();

var pie = d3.layout.pie()
    .sort(null);

var arc = d3.svg.arc()
    .innerRadius(radius - 100)
    .outerRadius(radius - 50);

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.apples))
  .enter().append("path")
    .attr("fill", function(d, i) { return color(i); }) …
Run Code Online (Sandbox Code Playgroud)

javascript d3.js

11
推荐指数
1
解决办法
2万
查看次数

标签 统计

d3.js ×1

javascript ×1