Skip to content

Instantly share code, notes, and snippets.

@maogm12
Last active October 18, 2019 03:54
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maogm12/bf57b51713d6a6e814d6 to your computer and use it in GitHub Desktop.
Save maogm12/bf57b51713d6a6e814d6 to your computer and use it in GitHub Desktop.
Pie Chart in Pure CSS
<div id="skills">
<div id="part1" class="circle animate"></div>
<div id="part2" class="circle animate"></div>
<div id="part3" class="circle animate"></div>
<div id="part4" class="circle animate"></div>
<div id="part5" class="circle animate"></div>
<div id="part6" class="circle animate"></div>
</div>
#skills {
position: relative;
width: 300px;
height: 300px;
margin: 30px auto;
}
.circle {
width: 100%;
height: 100%;
border-radius: 50%;
position: absolute;
}
.animate {
-webkit-transition: 0.2s cubic-bezier(.74,1.13,.83,1.2);
-moz-transition: 0.2s cubic-bezier(.74,1.13,.83,1.2);
-o-transition: 0.2s cubic-bezier(.74,1.13,.83,1.2);
transition: 0.2s cubic-bezier(.74,1.13,.83,1.2);
}
.animate:hover {
transform: scale(1.1);
transform-origin: center center;
}
#part1 {
background-color: #E64C65;
-webkit-clip-path: polygon(50% 0, 50% 50%, 100% 41.2%, 100% 0);
clip-path: polygon(50% 0, 50% 50%, 100% 41.2%, 100% 0);
}
#part2 {
background-color: #11A8AB;
-webkit-clip-path: polygon(50% 50%, 100% 41.2%, 100% 100%, 63.4% 100%);
clip-path: polygon(50% 50%, 100% 41.2%, 100% 100%, 63.4% 100%);
}
#part3 {
background-color: #4FC4F6;
-webkit-clip-path: polygon(50% 50%, 36.6% 100%, 63.4% 100%);
clip-path: polygon(50% 50%, 36.6% 100%, 63.4% 100%);
}
#part4 {
background-color: #FFED0D;
-webkit-clip-path: polygon(50% 50%, 0 100%, 36.6% 100%);
clip-path: polygon(50% 50%, 0 100%, 36.6% 100%);
}
#part5 {
background-color: #F46FDA;
-webkit-clip-path: polygon(50% 50%, 0 36.6%, 0 100%);
clip-path: polygon(50% 50%, 0 36.6%, 0 100%);
}
#part6 {
background-color: #15BFCC;
-webkit-clip-path: polygon(50% 50%, 0 36.6%, 0 0, 50% 0);
clip-path: polygon(50% 50%, 0 36.6%, 0 0, 50% 0);
}
@bogdan-ionut
Copy link

Hy there! Really really nice work :). Still, I have some questions:

  1. How can I make from 6 pices just 4 and how can I set the percentage of each slice?
  2. Is there a way to put some text (24% for example) on the slice itself?

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment