score:10
You can apply a corner radius to a d3 arc which allows rounding on the corners:
let arc = d3.svg
.arc()
.innerRadius(23)
.outerRadius(radius)
.cornerRadius(10);
But, the downside is that all arcs' borders are rounded:
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()
.innerRadius(30)
.outerRadius(50)
.startAngle(0)
.endAngle(Math.PI*2);
var mainArc = d3.arc()
.innerRadius(30)
.outerRadius(50)
.cornerRadius(10)
.startAngle(0)
.endAngle(function(d) { return d/100*Math.PI* 2 });
var data = [10,20,30,40,50] // percents.
var svg = d3.select("body").append("svg")
.attr("width", 600)
.attr("height", 200);
var charts = svg.selectAll("g")
.data(data)
.enter()
.append("g")
.attr("transform",function(d,i) {
return "translate("+(i*100+50)+",100)";
});
charts.append("path")
.attr("d", backgroundArc)
.attr("fill","#ccc")
charts.append("path")
.attr("d", mainArc)
.attr("fill","orange")
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/4.10.0/d3.min.js"></script>
score:0
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.
Reference: https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute
But the better way is to make charts on canvas, because you can draw everything you want. Or to use an library.
Source: stackoverflow.com
Related Query
- Add border-radius property to D3js Donut Chart
- how to add tooltip for donut chart in loop using d3js
- How to add drop shadow to d3.js pie or donut chart
- How to add tooltips in a D3 donut chart
- d3.js: How to add value below the label in donut chart
- Donut Pie Chart - Add a Title - NVd3.js
- Add text in rect svg and append it to arc in donut chart
- add circle in a spiral chart with d3js with line connecting to center
- How to add svg rectangles as background behind axis tick labels in d3js if ticks are inside chart
- Possibility to add images inside a bar of a bar chart - d3js
- Add vertical line to d3js bar chart
- Add links and hover effects to multi series donut chart in d3.js
- Unable to adjust position and text (multi-line) of right side legend in D3js Donut chart
- How do you add multiple lines to a D3JS line chart where the depedent variable data sources start at different positions along the range?
- Multiple ring donut chart using D3js v4
- How to add a circle in the middle of donut chart and fill it in d3 js?
- How to tell d3js that this half donut chart should fill values from left to right corner
- D3.js Donut Chart change node colors and add text label to middle
- I am not able to add put labels in 3d donut chart using d3.js
- Add thinner arc for total in D3 Donut Chart
- What am i doing wrong? Add text to bar chart with d3js
- AngularJS D3JS Donut chart colour change of arc on hover
- D3 How to add rounded top border to a stacked bar chart
- Add border to a line element of d3js
- d3js simple donut chart not drawing path
- D3js - Add transparent gap between path in pie chart
- Add text on top of bar in d3js chart -- no <text> elements added
- D3js Donut chart legend
- d3js donut chart - highlight first data
- How to build a simple Donut Chart using D3js and Angular 7
More Query from same tag
- Working with dynamic JSON in d3.js
- Multiple graphs on one page, scale error in D3.js
- ES6 modules and decorator pattern
- Interrupt scrolling transitions in D3.js
- Type 'Area<X>' is not assignable to type 'String' using @types/d3
- Text label and color changes after transition
- How to register multiple external listeners to the same selection in d3?
- d3js drag right button
- Applying multiple functions to a d3.js object, while entering
- windows.resize() is not working
- Brush d3.js with right click
- Parsing CSV Files
- Can you insert a line break in text when using d3.js?
- Can't select svg element with d3
- Calculating the number of bars in a bar chart in dc.js
- d3 map with checkbox filtering
- Cx of circle is not updated after drag event?
- How to make d3 js tree view vertically bottom to up
- D3 fisheye on width on bar chart
- How to fill area with a vertical line chart?
- Can I use c3.js / nvd3.js in angular 2.0 beta ? import seems incompatible with system.js
- Is it possible to display a d3 chart using the mouseover element of another d3 chart
- Making a drop down menu from csv data in JS
- Positioning Text in D3
- Redrawing the stack bar chat on click on the toggle legend using D3.js
- The .ticks property doesn't affect my chart
- Scrolling visualization only syncs up to text when I load the page twice
- How to use "on click" before the creation of my element
- D3 force layout forceY does not map to range
- Access to svg from D3 library