JavaScript preprocessors can help make authoring JavaScript easier and more convenient. For instance, CoffeeScript can help prevent easy-to-make mistakes and offer a cleaner syntax and Babel can bring ECMAScript 6 features to browsers that only support ECMAScript 5.
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.
You can apply a script from anywhere on the web to your Pen. Just put a URL to it here and we'll add it, in the order you have them, before the JavaScript in the Pen itself.
If the script you link to has the file extension of a preprocessor, we'll attempt to process it before applying.
You can also link to another Pen here, and we'll pull the JavaScript from that Pen and include it. If it's using a matching preprocessor, we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
HTML Settings
Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.
<div class="card">
<div class="donut-chart chart1">
<div class="quad one"></div>
<div class="quad two"></div>
<div class="quad three"></div>
<div class="quad four"></div>
<div class="quad top"></div>
<div class="chart-center"></div>
</div><!--/.donut-chart-->
</div>
<div class="card">
<div class="donut-chart chart2">
<div class="quad one"></div>
<div class="quad two"></div>
<div class="quad three"></div>
<div class="quad four"></div>
<div class="quad top"></div>
<div class="chart-center"></div>
</div><!--/.donut-chart-->
</div>
<div class="card">
<div class="donut-chart chart3">
<div class="quad one"></div>
<div class="quad two"></div>
<div class="quad three"></div>
<div class="quad four"></div>
<div class="quad top"></div>
<div class="chart-center"></div>
</div><!--/.donut-chart-->
</div>
<div class="card">
<div class="donut-chart chart4">
<div class="quad one"></div>
<div class="quad two"></div>
<div class="quad three"></div>
<div class="quad four"></div>
<div class="quad top"></div>
<div class="chart-center"></div>
</div><!--/.donut-chart-->
</div>
* {
-webkit-box-sizing: border-box;
box-sizing: border-box;
-webkit-transform: transform3d(0, 0, 0);
}
body {
font-family: sans-serif;
background: #e1e1e1;
}
.card {
float: left;
background: #fff;
padding: 20px;
margin: 0 20px 0 0;
}
// Donut Chart Mixin
.donut-chart {
position: relative;
border-radius: 50%;
overflow: hidden;
.quad {
position: absolute;
top: 0;
left: 0;
}
.chart-center {
position: absolute;
border-radius: 50%;
span {
display: block;
text-align: center;
}
}
}
@mixin donut-chart($name, $perc, $size, $width, $speed, $base, $center, $color, $textColor: $color, $textSize: 40px) {
$deg: ($perc/100*360)+deg;
@-webkit-keyframes #{$name} {
0% {
-webkit-transform: rotate(0deg);
}
100% {
-webkit-transform: rotate($deg);
}
}
@-webkit-keyframes chartRotate2 {
0% {
-webkit-transform: rotate(0deg);
}
100% {
-webkit-transform: rotate(90deg);
}
}
@-webkit-keyframes chartRotate3 {
0% {
-webkit-transform: rotate(0deg);
}
100% {
-webkit-transform: rotate(180deg);
}
}
@-webkit-keyframes chartRotate4 {
0% {
-webkit-transform: rotate(0deg);
}
100% {
-webkit-transform: rotate(270deg);
}
}
@-webkit-keyframes chartCover {
0%, 90% {
opacity: 1;
}
91%, 100% {
opacity: 0;
}
}
.donut-chart {
&.#{$name} {
width: $size;
height: $size;
background: $base;
.quad {
width: $size/2;
height: $size/2;
top: 0;
left: 0;
border-radius: 100% 0 0 0;
display: none;
&.one {
-webkit-transform: rotate($deg);
-webkit-transform-origin: bottom right;
background: $color;
-webkit-animation: #{$name} $speed linear;
@if $perc > 0 {
display: block;
}
}
&.two {
-webkit-transform: rotate(90deg);
-webkit-transform-origin: bottom right;
background: $color;
-webkit-animation: chartRotate2 $speed linear;
@if $perc > 25 {
display: block;
}
}
&.three {
-webkit-transform: rotate(180deg);
-webkit-transform-origin: bottom right;
background: $color;
-webkit-animation: chartRotate3 $speed linear;
@if $perc > 50 {
display: block;
}
}
&.four {
-webkit-transform: rotate(270deg);
-webkit-transform-origin: bottom right;
background: $color;
-webkit-animation: chartRotate4 $speed linear;
@if $perc > 75 {
display: block;
}
}
&.top {
display: block;
background: $base;
@if $perc > 75 {
opacity: 0;
-webkit-animation: chartCover .01s linear $speed/1.2 both;
}
}
} // quad
.chart-center {
top: $width;
left: $width;
width: $size - ($width * 2);
height: $size - ($width * 2);
background: $center;
&:after {
display: inline-block;
width: 100%;
font-size: $size / 5;
color: $textColor;
text-align: center;
line-height: $size - ($width * 2);
content: '#{$perc}%';
}
}
}
}
} // mixin
// Charts
@include donut-chart('chart1', 67, 300px, 25px, 1s, #e1e1e1, #fff, #48b2c1);
@include donut-chart('chart2', 37, 200px, 15px, 2s, #e1e1e1, #fff, #f26a4a);
@include donut-chart('chart3', 17, 150px, 10px, 1.5s, #e1e1e1, #fff, #353535);
@include donut-chart('chart4', 93, 250px, 40px, .5s, #e1e1e1, #fff, #50C690);
Also see: Tab Triggers