简体   繁体   中英

Progressbar.js - how to get a second circle?

I'm currently trying to get a second progressbar in my document with progressbar.js

I've managed to get one that even draws the progressbar percentage from the value attribute of the circle in the html document. So far I can't get the second one working. Could anybody help me out here?

http://codepen.io/stephan-v/pen/MwQQzJ

var startColor = '#FC5B3F';
var endColor = '#9ec64d';

window.onload = function onLoad() {
    var circle = new ProgressBar.Circle('.progress', {
        color: startColor,
        duration: 3000,
        easing: 'bounce',
        strokeWidth: 8,

        // Set default step function for all animate calls
        step: function(state, circle) {
            circle.path.setAttribute('stroke', state.color);
        }
    });

    // This will get the number from the page
    var value = ($('.progress').attr('value') / 100);

    // This will determine the circumference of the circle
    circle.animate(value, {
        from: {color: startColor},
        to: {color: endColor}
    });
};

I've got the javascripts from: http://kimmobrunfeldt.github.io/progressbar.js/

I just need to display multiple progressbars in a single page. I would be so happy if somebody could help me out.

Same class names make a conflict here

I added progress2 class value to second one

<div class="progress" value="75"></div>
<div class="progress2" value="25"></div>

codepen example

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM