cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

Quick-add: + add another resource

Code Indentation

     

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

            
              <p>Inspired from <a href="https://codepen.io/jo-asakura/pen/stFHi?editors=1100" target="_blank">https://codepen.io/jo-asakura/pen/stFHi?editors=1100</a></p>

<p>Github repository here: <a href="https://github.com/roparz/cg-percent-pie">https://github.com/roparz/cg-percent-pie</a></p>

<main ng-app="app">
  <cg-percent-pie percent="0"></cg-percent-pie>
  <cg-percent-pie percent="1"></cg-percent-pie>
  <cg-percent-pie percent="2"></cg-percent-pie>
  <cg-percent-pie percent="7"></cg-percent-pie>
  <cg-percent-pie percent="13"></cg-percent-pie>
  <cg-percent-pie percent="23"></cg-percent-pie>
  <cg-percent-pie percent="43"></cg-percent-pie>
  <cg-percent-pie percent="53"></cg-percent-pie>
  <cg-percent-pie percent="73"></cg-percent-pie>
  <cg-percent-pie percent="83"></cg-percent-pie>
  <cg-percent-pie percent="97"></cg-percent-pie>
  <cg-percent-pie percent="100"></cg-percent-pie>
</main>
            
          
!
            
              @mixin cg-percent-pie($border-size: 3px, $circle-size: 80px, $percent-font-size: 20%, $circle-color: rgb(85, 199, 215), $circle-shadow: rgb(212, 212, 212))

  %box-sizing
    &, &:before, &:after
      box-sizing: border-box

  %right-cirlce
    &:before
      display: block
      transform: rotate(45deg)

  %clip-pie
    clip: rect(0, 1em, 1em, .5em)
    &:before
      display: none

  .cg-pie-wrapper
    font-size: $circle-size
    width: 1em
    height: 1em
    position: relative
    float: left
    border: $border-size solid $circle-shadow
    border-radius: 50%
    @extend %box-sizing

    &:after
      content: attr(data-percent) '%'
      font-family: sans-serif
      white-space: nowrap
      font-size: $percent-font-size
      position: absolute
      top: 50%
      left: 50%
      transform: translate(-50%, -50%)

  .cg-pie
    position: absolute
    top: -$border-size
    left: -$border-size
    width: 1em
    height: 1em
    @extend %box-sizing

    &:after, &:before
      content: ''
      position: absolute
      width: 100%
      height: 100%
      border-width: $border-size
      border-style: solid
      border-color: $circle-color $circle-color transparent transparent
      border-radius: 50%

    @for $i from 0 through 100
      &.percent-#{$i}
        &:after
          $rotate: -135 + ($i * 3.6)
          transform: rotate($rotate * 1deg)

    @for $i from 0 through 50
      &.percent-#{$i}
        @extend %clip-pie

    @for $i from 51 through 100
      &.percent-#{$i}
        &:before
          @extend %right-cirlce
      
@include cg-percent-pie()

.cg-pie-wrapper
  margin: 10px
            
          
!
            
              angular.module('app', [])
.directive 'cgPercentPie', ->
  restrict: 'E'
  replace: true
  template: '
<div class="cg-pie-wrapper" data-percent="{{ percent }}">
  <div class="cg-pie percent-{{ percent }}"></div>
</div>
  '
  scope:
    percent: '@'
            
          
!
999px
Close

Asset uploading is a PRO feature.

As a PRO member, you can drag-and-drop upload files here to use as resources. Images, Libraries, JSON data... anything you want. You can even edit them anytime, like any other code on CodePen.

Go PRO

Loading ..................

Console