Concentric arcs using D3.js

2019-08-07 07:01发布

I have a data set

var data = [100,150,200,250]

I want to draw concentric arcs having radius as elements from my dataset using D3. Please help.

Below is my code so far :-

var width = 500;
var height = 500;

var p = Math.PI *2 ;

var data = [100,150,200,250];

var canvas = d3.select("body").append("svg")
        .attr("width",width)
        .attr("height",height);

var group = canvas.append("g")
        .attr("transform","translate(100,200)");


var arc = d3.svg.arc()
        .innerRadius(function(d){return (d-1)})
        .outerRadius(function(d){return d})
        .startAngle(0)
        .endAngle(p/2);

var arcs = group.selectALl(".arc")
        .data(data)
        .enter()
        .append("g")
        .attr("class","arc");

    arcs.append("path")
        .attr("d",arc);

I get an error "Uncaught TypeError: undefined is not a function ". Please help

标签: svg d3.js
1条回答
该账号已被封号
2楼-- · 2019-08-07 07:30

I see there is a typo in your code.

Please change selectALl(".arc") to selectAll(".arc") in var arcs = group.selectALl(".arc") and your code will work.

查看更多
登录 后发表回答