1 { 2 source:{ 3 startAngle : 0.2, 4 endAngle : Math.PI * 0.3, 5 radius : 100
6 }, 7 target:{ 8 startAngle :Math.PI * 1.0, 9 endAngle : Math.PI * 1.6, 10 radius : 100
11 } 12 }
1 var chord = d3.svg.chord() 2 .source(function(d){return d.startArc}) 3 .target(function(d){return d.endArc}) 4 .radius(200) 5 .startAngle(function(d){return d.start}) 6 .endAngle(function(d){return d.end})
1 { 2 startArc:{ 3 start : 0.2, 4 end : Math.PI * 0.3, 5 radius : 100
6 }, 7 endArc:{ 8 start :Math.PI * 1.0, 9 end : Math.PI * 1.6, 10 radius : 100
11 } 12 }
1 var width = 600; 2 var height = 400; 3
4 var svg = d3.select("#body") 5 .append("svg") 6 .attr("width",width) 7 .attr("height",height) 8
9 var dataList = { 10 source:{ 11 startAngle : 0.2, 12 endAngle : Math.PI * 0.3, 13 radius : 100
14 }, 15 target:{ 16 startAngle :Math.PI * 1.0, 17 endAngle : Math.PI * 1.6, 18 radius : 100
19 } 20 } 21
22
23 //建立一個弦生成器
24 var chord = d3.svg.chord(); 25
26 //添加路徑
27 svg.append("path") 28 .attr("d",chord(dataList)) 29 .attr("transform","translate(200,200)") 30 .attr("fill","yellow") 31 .attr("stroke","black") 32 .attr("stroke-width","3px")