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 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

Packages

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.

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

              
                <h1>Animated Graphs</h1> 
<h2>Scroll Triggered, Responsive, Data-driven</h2>  
<p>&nbsp;</p> 

<div class="chartBarsWrap">
    <div class="chartBars chartBars1">
        <ul class="numbers">
            <li><span>100%</span></li>
            <li><span>80%</span></li>
            <li><span>60%</span></li>
            <li><span>40%</span></li>
            <li><span>20%</span></li>
            <li><span>0%</span></li>
        </ul>
        <ul class="bars">
            <li>
                <span class="tooltip"> 
                <span class="tooltipContent">Very important info that you should read!</span>
                <div data-percentage="52" class="bar greenBar trigger"></div>
                </span>
                <b>Alpha</b>
            </li>
            <li>
                <span class="tooltip">  
                <span class="tooltipContent">This one is trending well.</span>
                <div data-percentage="83" class="bar blueBar trigger"></div>
                </span> 
                <b>Beta</b> 
            </li>
            <li>
                <span class="tooltip"> 
                <span class="tooltipContent">I like cheese!</span>
                <div data-percentage="94" class="bar orangeBar trigger"></div>
                </span>
                <b>Gamma</b>
            </li>
            <li>
                <span class="tooltip"> 
                <span class="tooltipContent">Monkey's are funny!</span> 
                <div data-percentage="64" class="bar purpleBar trigger"></div>    
                </span>
                <b>Delta</b>   
            </li>
        </ul>
    </div>
</div>

<p>Bacon ipsum do lor amet porchetta jowl jerky short loin, tri-tip flank c ow. Strip steak meat ball picanha t-bone pork loin filet mignon, pancetta jerky kielba sa sirloin ball t ip hamburger turkey pork belly ham hock. Chicken swine tail s pa re ribs,pork loin tongue picanha strip steak ribeye pancetta bresaola landjaeger flank ham shank. Picanha t-bone meatball, corned beef tail tri-tip flank capicola alcatra spare ribs. Flank tail pork loin pork belly sirloin tri-tip.</p>

<h3>Responsive? Yep.</h3>

<div class="chartBarsWrap">
    <div class="chartBars chartBars2"> 
        <ul class="numbers">
            <li><span>100%</span></li>
            <li><span>80%</span></li>
            <li><span>60%</span></li>
            <li><span>40%</span></li>   
            <li><span>20%</span></li> 
            <li><span>0%</span></li>
        </ul>
        <ul class="bars">
            <li>
                <div data-percentage="92" class="bar greenBar trigger"></div><b>Alpha</b></li><li> 
    <div data-percentage="33" class="bar orangeBar trigger"></div><b>Beta</b></li>
<li>
    <div data-percentage="64" class="bar blueBar trigger"></div><b>Gamma</b></li>
<li>
    <div data-percentage="44" class="bar purpleBar trigger"></div>
    <b>Delta</b></li>
        </ul>
    </div>
</div>

<p>Bacon ipsum do lor amet porchetta jowl jerky short loin, tri-tip flank c ow. Strip steak meat ball picanha t-bone pork loin filet mignon, pancetta jerky kielba sa sirloin ball t ip hamburger turkey pork belly ham hock. Chicken swine tail s pa re ribs, pork loin tongue picanha strip steak ribeye pancetta bresaola landjaeger flank ham shank. Picanha t-bone meatball, corned beef tail tri-tip flank capicola alcatra spare ribs. Flank tail pork loin pork belly sirloin tri-tip. Bresaola salmi.</p>

<h3>Radial Graphs</h3>   
 
<div class="box-piesite">
    <ul>
        <li class="design">
            <div class="piesite" id="pie_0" data-pie="82"></div>
        </li>
        <li class="usability">
            <div class="piesite" id="pie_2" data-pie="55"></div>
        </li>
        <li class="creativity">
            <div class="piesite" id="pie_1" data-pie="33"></div>
        </li>
    </ul>
</div>

<p>Bacon ipsum do lor amet porchetta jowl jerky short loin, tri-tip flank c ow. Strip steak meat ball picanha t-bone pork loin filet mignon, pancetta jerky kielba sa sirloin ball t ip hamburger turkey pork belly ham hock. Chicken swine tail s pa re ribs,pork loin tongue picanha strip steak ribeye pancetta bresaola landjaeger flank ham shank. Picanha t-bone meatball, corned beef tail tri-tip flank capicola alcatra spare ribs. Flank tail pork loin pork belly sirloin tri-tip..</p>
<!-- <p>&nbsp;</p>  -->
 
<h3>Horizontal</h3>   
 
<div class="chartBarsWrap chartBarsHorizontal"> 
    <div class="chartBars"> 
        <ul class="bars">  
            <li> 
                <div data-percentage="92" class="bar greenBarFlat"></div><b>Alpha</b></li>
            <li>
                <div data-percentage="33" class="bar orangeBarFlat"></div><b>Beta</b></li>
            <li>
                <div data-percentage="64" class="bar blueBarFlat"></div><b>Gamma</b></li>
            <li>
                <div data-percentage="44" class="bar purpleBarFlat"></div><b>Delta</b></li>
        </ul>
    </div>
</div>


<p>Bacon ipsum do lor amet porchetta jowl jerky short loin, tri-tip flank c ow. Strip steak meat ball picanha t-bone pork loin filet mignon, pancetta jerky kielba sa sirloin ball t ip hamburger turkey pork belly ham hock. Chicken swine tail s pa re ribs,pork loin tongue picanha strip steak ribeye pancetta bresaola landjaeger flank ham shank.</p> 

<h3>Just add more bars, they sqeeze in. Sweet!</h3>

<div class="chartBarsWrap">
    <div class="chartBars chartBars3">
        <ul class="numbers">
            <li><span>100%</span></li>
            <li><span>80%</span></li>
            <li><span>60%</span></li>
            <li><span>40%</span></li>
            <li><span>20%</span></li>
            <li><span>0%</span></li>
        </ul>
        <ul class="bars">
            <li><div data-percentage="92" class="bar greenBar trigger"></div><b>Alpha</b></li>
            <li><div data-percentage="33" class="bar blueBar trigger"></div><b>Beta</b></li>
            <li><div data-percentage="64" class="bar orangeBar trigger"></div><b>Gamma</b></li>
            <li><div data-percentage="41" class="bar purpleBar trigger"></div><b>Delta</b></li>
            <li><div data-percentage="52" class="bar greenBar trigger"></div><b>Epsilon</b></li> 
            <li><div data-percentage="58" class="bar blueBar trigger"></div><b>Zeta</b></li>
            <li><div data-percentage="65" class="bar orangeBar trigger"></div><b>Eta</b></li>
            <li><div data-percentage="91" class="bar purpleBar trigger"></div><b>Theta</b></li>
            <li><div data-percentage="32" class="bar greenBar trigger"></div><b>Iota</b></li>    
            <li><div data-percentage="68" class="bar blueBar trigger"></div><b>Kappa</b></li>
        </ul>
    </div>
</div>

<p>Bacon ipsum do lor amet porchetta jowl jerky short loin, tri-tip flank c ow. Strip steak meat ball picanha t-bone pork loin filet mignon, pancetta jerky kielba sa sirloin ball t ip hamburger turkey pork belly ham hock. Chicken swine tail s pa re ribs,pork loin tongue picanha strip steak ribeye pancetta bresaola landjaeger flank ham shank.</p>


              
            
!

CSS

              
                ////////////////////////////////////////////////////
//                 The Bar Graphs
////////////////////////////////////////////////////

.chartBarsWrap {
    // This wrapper is for padding the leftside numbers *mobile*
    padding-left: 40px;
    margin: 0 30px 0 20px;
    overflow-x: hidden;
}

.chartBars {
    position: relative;
    max-width: 600px;
    height: 300px;
    margin: 50px auto 100px;
    .bars {
        display: flex;
        justify-content: space-around;
        border-left: 1px solid #bbb;
        border-bottom: 1px solid #bbb;
        width: 100%;
        height: 100%;
        padding: 0;
        padding: 0 1%;
        margin: 0;
        li {
            display: inline-block;
            flex: 0 1 24%;
            height: 100%;
            margin: 0;
            text-align: center;
            position: relative;
            font-size: 16px;
            .bar {
                width: 100%;
                background: #49E;
                position: absolute;
                font-size: 1.5em;
                color: #fff;
                padding-top: 18px;
                bottom: 0;
                height: 0;
                overflow: hidden;
                font-weight: bold;
                outline: 2px solid transparent;
                -webkit-transition: 1.5s height cubic-bezier(.6, .4, .4, 1.1);
                transition: 1.5s height cubic-bezier(.6, .4, .4, 1.1);
                &:after {
                    content: '%';
                    font-size: 22px !important;
                    vertical-align: top;
                    color: rgba(255, 255, 255, .8);
                    margin-right: -8px;
                }
                &:hover {
                }
            }
            b {
                color: #eee;
                width: 100%;
                position: absolute;
                bottom: -2em;
                left: 0;
                text-align: center;
            }
        }
    }
    .numbers {
        width: 50px;
        height: 100%;
        margin: 0;
        padding: 0;
        display: inline-block;
        position: absolute;
        left: -50px;
        li {
            text-align: right;
            padding-right: 1em;
            list-style: none;
            height: 59px;
            position: relative;
            font-size: 13px;
            bottom: 11px;
            right: -9px;
            color: #eee;
            &:after {
                content: "\00af";
                position: relative;
                right: -5px;
                font-size: 20px;
                top: 7px;
                color: rgba(255, 255, 255, 0.34);
            }
            &:first-of-type {
                height: 63px;
                margin-top: -1px;
            }
        }
    }
}

////////////////////////////////////
// Individual Chart Styles

.chartBars1 .bar {
    border-top-right-radius: 30px;
}

.chartBars2 {
    max-width: 350px;
    .bars {
        padding: 0;
        li {
            flex: 0 1 25%;
            .bar {
                box-shadow: 0 0 20px #222;
            }
        }
    } 
}

.chartBars3 {
    background: rgba(255, 255, 255, .1);
    border-top: 1px solid #666;
    border-right: 1px solid #666;
    .bars {
        border-color: #666;
        padding: 0;
        li .bar {
            border-top-right-radius: 3px;
            border-top-left-radius: 3px;
            font-size: 22px !important;
            &:after {
                font-size: .6em !important;
            }
        }
    }
}

.chartBarsWrap.chartBarsHorizontal {
    flex-direction: column;
    padding-left: 70px;
    .bars b {
        color: #eee;
        width: 100%;
        position: absolute;
        bottom: initial;
        top: 1em;
        left: -102%;
        text-align: right;
    }
    .chartBars {
        height: 200px;
    }
    .chartBars .bars {
        border: 0;
        .bar {
            width: 0;
            padding-top: 10px;
            height: 100% !important;
            text-align: right;
            font-size: 1.5em;
            -webkit-transition: 2s width cubic-bezier(0.6, 0.4, 0.4, 1.1);
            transition: 2s width cubic-bezier(0.6, 0.4, 0.4, 1.1);
            &:after {
                font-size: .6em !important;
                margin-right: 20px;
            }
        }
    }
}

////////////////////////////////////////////////////
//                   Colors
////////////////////////////////////////////////////
@lighten-percentage: 15%;
@green: #6B8E23;
@lightgreen: lighten(@green, @lighten-percentage);
@blue: #49E;
@lightblue: lighten(@blue, @lighten-percentage);
@orange: #FFA500;
@lightorange: lighten(@orange, @lighten-percentage);
@purple: #6e46af;
@lightpurple: lighten(@purple, @lighten-percentage);

.bars li .bar.greenBar {
    background-color: #6B8E23;
    background: radial-gradient(@lightgreen, @green);
}
.bars li .bar.greenBarFlat {
    background-color: #6B8E23;
}

.bars li .bar.blueBar {
    background-color: #49E;
    background: radial-gradient(@lightblue, @blue);
}

.bars li .bar.blueBarFlat {
    background-color: #49E;
}

.bars li .bar.orangeBar {
    background-color: orange;
    background: radial-gradient(@lightorange, @orange);
}

.bars li .bar.orangeBarFlat {
    background-color: orange;
}

.bars li .bar.purpleBar {
    background-color: #6e46af;
    background: radial-gradient(@lightpurple, @purple);
}

.bars li .bar.purpleBarFlat {
    background-color: #6e46af;
}

////////////////////////////////////////////////////
//              Pie Charts
////////////////////////////////////////////////////
// https://codepen.io/StephenScaff/pen/VYaQGB
// by Stephen Scaff
.box-piesite {
    text-align: center;
    font-size: 22px;
}

.piesite {
    position: relative;
    width: 1em;
    height: 1em;
    font-size: 10em;
    cursor: default;
}

.piesite .percent {
    position: absolute;
    top: 1.1em;
    left: .1em;
    width: 100%;
    font-size: .3em;
    text-align: center;
    z-index: 2;
    .symbol {
        font-size: .5em;
        vertical-align: top;
        opacity: .5;
    }
}

.piesite > #slice {
    position: absolute;
    width: 1em;
    height: 1em;
    clip: rect(0px, 1em, 1em, 0.5em);
}

.piesite > #slice.gt50 {
    clip: rect(auto, auto, auto, auto);
}

.piesite > #slice > .pie {
    position: absolute;
    border: .1em solid #444;
    width: 1em;
    height: 1em;
    clip: rect(0em, 0.5em, 1em, 0em);
    border-radius: 0.5em;
}

li.design .piesite > #slice > .pie {
    border-color: #49E;
}

li.usability .piesite > #slice > .pie {
    border-color: #FFA500;
}

li.creativity .piesite > #slice > .pie {
    border-color: #6B8E23;
}

.piesite > #slice > .pie.fill {
    -webkit-transform: rotate(180deg) !important;
    transform: rotate(180deg) !important;
}

.piesite.fill > .percent {
    display: none;
}

.piesite:after {
    content: '';
    display: block;
    position: absolute;
    top: .1em;
    left: .1em;
    width: .8em;
    height: .8em;
    background: #30303A;
    border-radius: 100%;
    z-index: 1;
}

.piesite:before {
    content: '';
    display: block;
    position: absolute;
    width: 1em;
    height: 1em;
    border-radius: .5em;
    opacity: .5;
    z-index: 0;
}

.piesite:before {
    background: rgba(255, 255, 255, 0.1);
}

.box-piesite ul {
    padding: 0;
    li {
        display: inline-block;
        margin: 10px 20px;
    }
}

.chartBarsHorizontal .chartBars .bars {
    flex-direction: column;
}

////////////////////////////////////////////////////
//                Media Queries
////////////////////////////////////////////////////
@media screen and (min-width: 600px) {
    .bar:before {
        font-size: 2em !important;
    }
    .chartBars3 .bar:before {
        font-size: 1.5em !important;
    }
}

////////////////////////////////////////////////////
//                Tooltips
////////////////////////////////////////////////////
.tooltip {
    // position: relative;
    & > .tooltipContent {
        display: block;
        position: absolute;
        background: none repeat scroll 0 0 #222;
        color: #F0B015;
        font-family: 'Helvetica';
        font-size: 0.8em;
        font-weight: normal;
        line-height: 1.5em;
        padding: 16px 15px;
        min-width: 200px;
        max-width: 500px;
        top: 0;
        left: 50%;
        transform: translate(-50%, -110%);
        margin-left: 0;
        opacity: 0;
        filter: alpha(opacity=0);
        text-align: center;
        z-index: 2;
        text-transform: none;
        -webkit-transition: all 0.3s ease;
        -moz-transition: all 0.3s ease-in-out;
        -o-transition: all 0.3s ease;
        transition: all 0.3s ease-in-out;
    }
    &:hover > .tooltipContent {
        opacity: 1;
        filter: alpha(opacity=100);
        z-index: 99;
        transform: translate(-50%, -130%);
        -webkit-transition: all 0.2s ease;
        -moz-transition: all 0.2s ease;
        -o-transition: all 0.2s ease;
        transition: all 0.2s ease;
    }
    & .tooltipContent:after {
        border-color: #222 rgba(0, 0, 0, 0);
        border-style: solid;
        border-width: 15px 15px 0;
        bottom: -15px;
        content: "";
        display: block;
        left: 50%;
        transform: translate(-50%, 0);
        position: absolute;
        width: 0;
    }
}

////////////////////////////////////////////////////
//               layout extras
////////////////////////////////////////////////////
* {
    box-sizing: border-box;
}

body {
    background: #30303A;
    font-family: 'Quicksand', sans-serif;
    color: #ddd;
}

h1, h2, h3 {
    text-align: center;
}

h1 {
    margin: 100px auto 0;
    color: #F0B015;
}

h2 {
    margin: 20px auto 0;
    font-size: 1.2em;
}

p {
    margin: 5vw auto;
    padding: 0 5vw;
    line-height: 2em;
    max-width: 60em;
}

              
            
!

JS

              
                var piesiteFired = 0;
$(document).ready(function() {
    var $win = $(window),
        $win_height = $(window).height(),
        // - A multiple of viewport height - The higher this number the sooner triggered.
        windowPercentage = $(window).height() * 0.9;
    $win.on("scroll", scrollReveal);
    function scrollReveal() {
        var scrolled = $win.scrollTop();
        
        ///////////////////////////////////////
        // Bar Charts scroll activate, looking for .trigger class to fire.
        $(".trigger").each(function() {
            var $this = $(this),
                offsetTop = $this.offset().top;
            if (
                scrolled + windowPercentage > offsetTop ||
                $win_height > offsetTop
            ) {
                $(this).each(function(key, bar) {
                    var percentage = $(this).data("percentage");
                    $(this).css("height", percentage + "%"); 
                    
                    ///////////////////////////////////////
                    //        Animated numbers
                    $(this).prop("Counter", 0).animate(
                        {
                            Counter: $(this).data("percentage")
                        },
                        {
                            duration: 2000,
                            easing: "swing",
                            step: function(now) {
                                $(this).text(Math.ceil(now));
                            }
                        }
                    );
                    //        Animated numbers
                    ///////////////////////////////////////
                });

            } else {
                ///////////////////////////////////////
                // To keep them triggered, lose this block.
                $(this).each(function(key, bar) {
                    $(this).css("height", 0);
                });
            }    
            
        });

        ///////////////////////////////////////
        // Horizontal Chart
        $(".chartBarsHorizontal .bar").each(function() {
            var $this = $(this),
                offsetTop = $this.offset().top;
            if (
                scrolled + windowPercentage > offsetTop ||
                $win_height > offsetTop
            ) { 
                $(this).each(function(key, bar) {
                    var percentage = $(this).data("percentage");
                    $(this).css("width", percentage + "%");
                    ///////////////////////////////////////
                    //        Animated numbers
                    $(this).prop("Counter", 0).animate(
                        {
                            Counter: $(this).data("percentage")
                        },
                        {
                            duration: 2000,
                            easing: "swing",
                            step: function(now) {
                                $(this).text(Math.ceil(now));
                            }
                        }
                    );
                    //        Animated numbers
                    ///////////////////////////////////////
                });
    
            } else {
                ///////////////////////////////////////
                // To keep them triggered, lose this block.
                $(this).each(function(key, bar) {
                    $(this).css("width", 0);
                });
            }    
            
        });
        
        ///////////////////////////////////////
        // Radial Graphs - scroll activate
        $(".piesite").each(function() {
            var $this = $(this),
                offsetTop = $this.offset().top;
            if (
                scrolled + windowPercentage > offsetTop ||
                $win_height > offsetTop
            ) {
                if (piesiteFired == 0) {
                    timerSeconds = 3;
                    timerFinish = new Date().getTime() + timerSeconds * 1000;
                    $(".piesite").each(function(a) {
                        pie = $("#pie_" + a).data("pie");
                        timer = setInterval(
                            "stoppie(" + a + ", " + pie + ")",
                            0
                        );
                    });
                    piesiteFired = 1;
                }
            } else {
                // To keep them triggered, lose this block.
                $(".piesite").each(function() {
                    piesiteFired = 0;
                });
            }
        });
    }
    scrollReveal();
});



///////////////////////////////////////
//        The Radial Graphs
///////////////////////////////////////

// The following code is originally from the excellent pen:
// https://codepen.io/StephenScaff/pen/VYaQGB by Stephen Scaff

var timer;
var timerFinish;
var timerSeconds;

function drawTimer(c, a) {
    $("#pie_" + c).html(
        '<div class="percent"></div><div id="slice"' +
            (a > 50 ? ' class="gt50"' : "") +
            '><div class="pie"></div>' +
            (a > 50 ? '<div class="pie fill"></div>' : "") +
            "</div>"
    );
    var b = 360 / 100 * a;
    $("#pie_" + c + " #slice .pie").css({
        "-moz-transform": "rotate(" + b + "deg)",
        "-webkit-transform": "rotate(" + b + "deg)",
        "-o-transform": "rotate(" + b + "deg)",
        transform: "rotate(" + b + "deg)"
    });
    a = Math.floor(a * 100) / 100;
    arr = a.toString().split(".");
    intPart = arr[0];
    $("#pie_" + c + " .percent").html(
        '<span class="int">' +
            intPart +
            "</span>" +
            '<span class="symbol">%</span>'
    );
}
function stoppie(d, b) {
    var c = (timerFinish - new Date().getTime()) / 1000;
    var a = 100 - c / timerSeconds * 100;
    a = Math.floor(a * 100) / 100;
    if (a <= b) {
        drawTimer(d, a);
    } else {
        b = $("#pie_" + d).data("pie");
        arr = b.toString().split(".");
        $("#pie_" + d + " .percent .int").html(arr[0]);
    }
}


              
            
!
999px

Console