Accepted answer

You can apply a corner radius to a d3 arc which allows rounding on the corners:

let arc = d3.svg

But, the downside is that all arcs' borders are rounded:

enter image description here

If you apply the cornerRadius to only the darkened arc - the other arc won't fill in the background behind the rounded corners. Instead, we could append a circular arc (full donut) and place the darkened arc on top with rounding (my example doesn't adapt your code, just shows how that it can be done, also with d3v4 which uses d3.arc() rather than d3.svg.arc() ):

var backgroundArc = d3.arc()
var mainArc = d3.arc()
  .endAngle(function(d) { return d/100*Math.PI* 2 });
var data = [10,20,30,40,50] // percents.
var svg ="body").append("svg")
  .attr("width", 600)
  .attr("height", 200);
var charts = svg.selectAll("g")
  .attr("transform",function(d,i) { 
     return "translate("+(i*100+50)+",100)";
  .attr("d", backgroundArc)

  .attr("d", mainArc) 
<script src=""></script>


Try playing with stroke attributes like:

  • stroke
  • stroke-dasharray
  • stroke-dashoffset
  • stroke-linecap
  • stroke-linejoin
  • stroke-miterlimit
  • stroke-opacity
  • stroke-width

And set width of bar to lower values, or 0.


But the better way is to make charts on canvas, because you can draw everything you want. Or to use an library.

Related Query