How to create a donut with rounded edges in one direction and a white border between segments

0 votes

How to create a donut with rounded edges in one direction and a white border between segments?

I am trying to create a donut chart with a specific styling where each segment has rounded edges on one side to give it a smooth, polished appearance. Additionally, I want to include a white border or gap between the segments to clearly distinguish them, but I am struggling to implement both features simultaneously. While I can create a basic donut chart, adding these stylistic elements has proven challenging. How can I achieve this design effectively

19 hours ago in Web Development by Nidhi
• 3,520 points
17 views

1 answer to this question.

0 votes

You can use CSS and conic-gradient for creating donut charts.

Approach:

Create the donut shape using a circular div.

Use conic-gradient to create colored segments in the donut with a white border.

Apply border-radius to give the segments a rounded edge in one direction.

Steps:

HTML:

<div class="donut"></div>

CSS:

.donut {

  width: 400px;

  height: 400px;

  border-radius: 50%; /* Make it circular */

  background: conic-gradient(

    #ff0000 0% 25%,     /* Red segment (25%) */

    #00ff00 25% 50%,    /* Green segment (25%) */

    #0000ff 50% 75%,    /* Blue segment (25%) */

    #ff00ff 75% 100%    /* Purple segment (25%) */

  );

  border: 20px solid white; /* White border between segments */

  background-clip: content-box; /* Ensure the border doesn't overlap the donut */

}

answered 19 hours ago by navya

Related Questions In Web Development

0 votes
0 answers
0 votes
1 answer

How to create a node in a linked list?

A linked list is a linear data structure ...READ MORE

answered Nov 6 in Web Development by kavya
134 views
0 votes
1 answer

How to create a horizontal line in CSS?

The most basic way to create a ...READ MORE

answered Nov 4 in Web Development by kavya
75 views
0 votes
1 answer

How to create a service file in Angular?

To create a service file in Angular, ...READ MORE

answered Nov 13 in Web Development by kavya
51 views
0 votes
2 answers

Define a SQL query? What is the difference between SELECT and UPDATE Query? How do you use SQL in SAS?

HI.. SQL is Structured Query Language, which is ...READ MORE

answered Aug 8, 2020 in PHP by anonymous
10,570 views
0 votes
1 answer

Using/Handling colon inside a JSF generated HTML element ID in CSS selector

Yes, you can.  Just Backslash (\) the colon.  Like ...READ MORE

answered Nov 14, 2018 in Others by DataKing99
• 8,250 points
2,864 views
0 votes
1 answer

What is a css selector and where is it used?

CSS Selector is a combination of element ...READ MORE

answered Nov 21, 2018 in Data Analytics by Kalgi
• 52,350 points
950 views
0 votes
1 answer

How do I send a file from postman to node.js with multer?

npm install multer express Then  we will set ...READ MORE

answered Oct 24 in Web Development by kavya

edited Oct 30 by Nidhi 159 views
0 votes
1 answer

How to parse a date in Java?

Using DateTimeFormatter  Example: import java.time.LocalDate; import java.time.format.DateTimeFormatter; public class DateParsing { ...READ MORE

answered 18 hours ago in Web Development by Navya
11 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP