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 Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

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
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................

Console