examples

GitHub license GitHub release Language html css

CircularProgressBar.js

A lightweight circular progress bar made with Js, SVG circles, and CSS transitions.

How to use

Add these tags in yout HTML:

Then initialize the circular progress bar, for example:

See a live example here.

Documentation

Methods

new CircularProgressBar(width, height, container, [options])

Kind: constructor of CircularProgressBar

ParamTypeDefaultDescription
widthNumber width in px
heightNumber height in px
containerString ID of the parent
[options]Object progress bar options
[options.strokeSize]Number1size of the stroke
[options.backgroundColor]String'black'background color of the inner circle
[options.strokeColor]String'white'color of the stroke
[options.centerIcon]String icon displayed at the center of the inner circle
[options.showProgressNumber]Booleanfalseicon displayed at the center of the inner circle
[options.oncomplete]EventListener callback function invoked when progress reach 100%

circularProgressBar.setBackgroundColor(color)

set color of the inner circle

Kind: instance method of CircularProgressBar

ParamTypeDescription
colorStringa valid CSS color

circularProgressBar.setStrokeColor(color)

set color of the stroke

Kind: instance method of CircularProgressBar

ParamTypeDescription
colorStringa valid CSS color

circularProgressBar.showProgressNumber(enabled)

Kind: instance method of CircularProgressBar

ParamTypeDescription
enabledBooleanboolean to show/hide progress number

circularProgressBar.setCenterIcon(src)

set an image at the center of the progressbar

Kind: instance method of CircularProgressBar

ParamTypeDescription
srcStringimage src

circularProgressBar.setProgress(percent)

Set progress of the progressbar (with animation);

Kind: instance method of CircularProgressBar

ParamTypeDescription
percentNumberprogress percentage

circularProgressBar.getProgress() ⇒ Number

Get current progress

Kind: instance method of CircularProgressBar