Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource


Babel includes JSX processing.

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


Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.


Auto Save

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.



Change the data-percentage attribute on `div.pie-chart` to render a fresh pie chart


<div class="pie-chart" data-percentage="33">
  <svg viewBox="-100 -100 200 200">
		<path d="" />



                .pie-chart {
    display: block;
    max-width: 80px;
    max-height: 80px;
    width: 100%;
    padding: 0;
	  margin: 20px auto 0;
    transform-origin: 50% 50%;
    -moz-transform-origin: 40px 40px;
    -ms-transform: rotate(-90deg);
    transform: rotate(-90deg);

.pie-chart ~ h3 {
	text-align: center;
	font-family: 'Helvetica', sans-serif;
	font-size: 24px;
	font-weight: normal;
	color: gray;

.pie-chart svg {
    max-height: 80px;
    border-radius: 50%;
    border: 1px solid #eee;
    background: #ffffff;

.pie-chart svg path {
    fill: #0074a2;
    -moz-transform: translate3d(0, 0, -1px);


window.onresize = draw_pie_chart();

function draw_pie_chart() {
    var percentage, // percentage for the data attribute
        path, // path for svg
        angle, // 1% = 3.6deg; used for coord mapping
        radius = 50, // radius of the pie chart in pixels
        coords = []; // holds Cartesian plane coords for svg path

    percentage = parseInt( document.querySelectorAll( '.pie-chart[data-percentage]' )[0].getAttribute( 'data-percentage' ) );
    angle = percentage * 3.6; // 1% ~ 3.6deg
    radius = radius * 2;      // get diameter

    coords[0] = radius * Math.cos( Math.PI * angle / 180 );
    coords[1] = radius * Math.sin( Math.PI * angle / 180 );

    path = 'M0,0 L' + radius + ',0 A' + radius + ',' + radius + ' 0 1,1 ' + coords[0] + ',' + coords[1] + ' Z';

    document.querySelectorAll( '.pie-chart svg path' )[0].setAttribute( 'd', path );
    document.querySelectorAll( 'h3' )[0].innerHTML = percentage + '%';