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

Dec 4, 2024 in Web Development by Nidhi
• 11,580 points
145 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 Dec 4, 2024 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, 2024 in Web Development by kavya
259 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, 2024 in Web Development by kavya
158 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, 2024 in Web Development by kavya
123 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,965 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,971 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
1,034 views
0 votes
1 answer

How to generate a service and include the provider in one step with Angular CLI?

In Angular, you can generate a service ...READ MORE

answered Dec 13, 2024 in Web Development by Navya
78 views
0 votes
1 answer

How to Align a Home Button and Dropdown Menus on the Same Line in a Navigation Bar?

Using CSS Flexbox, you can center a ...READ MORE

answered Dec 12, 2024 in Web Development by Navya
97 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