Pen Settings

HTML

CSS

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

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

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

Behavior

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.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <div class="flex_container">
  <div class="inputs">
    <div>Percent: <input class="percent" type="number" value='58.5'></div>
    <div>Step: <input class="step" type="number" value='2'></div>
  </div>
  <div class="chart">
    <svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 451.5 451.5" style="enable-background:new 0 0 451.5 451.5;" xml:space="preserve">
      <defs>
        <clipPath id="dodecagon-chart-clippath">
          <path d="M366,225.9l-18.8,70.1L296,347.2L225.9,366l-70.1-18.8l-51.3-51.3l-18.8-70.1l18.8-70.1
		l51.3-51.3l70.1-18.8l70.1,18.8l51.3,51.3L366,225.9z"/>
        </clipPath>
      </defs>
	<path class="dodecagon dodecagon--center" d="M366,225.9l-18.8,70.1L296,347.2L225.9,366l-70.1-18.8l-51.3-51.3l-18.8-70.1l18.8-70.1
		l51.3-51.3l70.1-18.8l70.1,18.8l51.3,51.3L366,225.9z" vector-effect="non-scaling-stroke"/>
	<path class="dodecagon dodecagon--dotted" d="M448.7,225.8l-29.8,111.4l-81.5,81.5L226,448.5l-111.4-29.8L33,337.2L3.2,225.8L33,114.4
		l81.5-81.5L226,3l111.4,29.8l81.5,81.5L448.7,225.8z"/>
	<path class="dodecagon dodecagon--solid" d="M448.7,225.8l-29.8,111.4l-81.5,81.5l-111.4,29.8l-111.4-29.8L33,337.2L3.1,225.8L33,114.4
		l81.5-81.5L225.9,3l111.4,29.8l81.5,81.5L448.7,225.8z"/>
<rect x="415.9" y="111.4" class="rect" width="6" height="6" vector-effect="non-scaling-stroke"/>
<rect x="30" y="334.2" class="rect" width="6" height="6" vector-effect="non-scaling-stroke"/>
<rect x="415.8" y="334.2" class="rect" width="6" height="6" vector-effect="non-scaling-stroke"/>
<rect x="30" y="111.4" class="rect" width="6" height="6" vector-effect="non-scaling-stroke"/>
<rect x="222.9" y="0" class="rect" width="6" height="6" vector-effect="non-scaling-stroke"/>
<rect x="222.9" y="445.5" class="rect" width="6" height="6" vector-effect="non-scaling-stroke"/>
<circle class="circle" clip-path="url(#dodecagon-chart-clippath)" stroke-width="162px" cx="226" cy="225.8" r="81"/>
</svg>
  </div>
</div>
              
            
!

CSS

              
                body {
  height: 100%;
  padding: 0;
  display: block;
  margin: 0;
  background-color: #703bf6;
}
.inputs {
  text-align: right;
  &>div {
    margin: 10px 20px;
  }
}
input {
  color: #333;
  padding: 0 15px;
  height: 40px;
  width: 100px;
  text-align: center; 
  background: rgba(255,255,255,.9);
  border: none;
}
.flex_container {
  display: flex;
  flex-flow: row wrap;
  height: 100vh;
  font: 20px Helvetica;
  font-weight: 300;
  letter-spacing: 3px;
  color: rgba(255, 255, 255, 0.8);
  justify-content: center;
  align-items: center;
}

.chart {
  width: 90vh;
  height: auto;
  background: none;
  position: relative;
  border: none;
  outline: none;
  &:after {
    content: "";
    display: block;
    padding-bottom: 100%;
  }
  svg {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
     opacity: 0;
    .dodecagon {
      &--solid {
        fill: none;
        stroke: #fff;
        stroke-width: 1;
        stroke-miterlimit: 10;
      }
      &--center {
        fill: none;
        stroke: rgba(51, 51, 51, 0.8);
        stroke-width: 1;
        stroke-miterlimit: 10;
      }
      &--dotted {
        fill: none;
        stroke: #fff;
        stroke-width: .5;
        stroke-miterlimit: 10;
        stroke-dasharray: 3px;
      }
    }
    .circle {
      fill: none;
      stroke: #262040;
      // stroke-width: 1px;
    }
    .rect {
      fill: #fff;
    }
  }
}

              
            
!

JS

              
                // Сreated by vereschak@gmail.com
// -----------------------------------------

class DodecagonChart {
  constructor(svg) {
    this.svg = svg;
    this.initProgress();
  }
  initProgress() {
    this.circle = this.svg.querySelector("circle");
    this.dodecagon = this.svg.querySelector(".dodecagon--solid");
    this.setOffset(this.circle);
    this.setOffset(this.dodecagon);

    TweenMax.set([this.circle, this.dodecagon], {
      rotation: -90.1,
      transformOrigin: "50% 50%"
    });

    this.svg.style.opacity = 1;
  }
  getCircleTotalLength() {
    let r = this.getAttribute('r');
    let circleLength = 2 * Math.PI * r; 
      return circleLength;
  }
  setOffset(el) {
    if(el.tagName === 'circle') {
      el.getTotalLength = this.getCircleTotalLength.bind(el);
    }
    let total = el.totalLength = el.getTotalLength()
    el.style.strokeDasharray = total;
    el.style.strokeDashoffset = total;
  }
  drawStroke(el, percent) {
    let total = el.totalLength;
    el.style.opacity = 1;
    TweenMax.set(el, {
      clearProps: "opacity"
    });

    let percentOffset = Math.ceil(total - total / 100 * percent);
    percentOffset = percentOffset < 0 ? 0 : percentOffset;
    percentOffset = percentOffset > total ? total : percentOffset;
    
    TweenMax.to(el, .8, {
      strokeDashoffset: percentOffset,
      ease: Power2.easeInOut
    });
  }
  setPercent(percent) {
    this.drawStroke(this.circle, percent);
    return this;
  }
  setStep(step) {
    step = step >= 6 ? 6 : Math.abs(step);
    let percent = 100 / 6 * step;
    this.drawStroke(this.dodecagon, percent);
    return this;
  }
}

window.chart = new DodecagonChart(document.querySelector(".chart svg"))


// example

$(document).ready(() => {
  let debouncePercent, debounceStep;
  $('input.percent').on('keyup change ready', function(){
  clearTimeout(debouncePercent);
  debouncePercent = setTimeout(() => chart.setPercent(this.value), 200);
});
  
$('input.step').on('keyup change ready', function(){ 
  clearTimeout(debounceStep);
  debounceStep = setTimeout(() => chart.setStep(this.value) , 200);
});
  
$('input').change();
});

              
            
!
999px

Console