Skip to content

Angular module that uses SVG to create a circular progressbar with Angular5 and AOT(Ahead of Time) compiler support.

License

Notifications You must be signed in to change notification settings

faisal3325/angular5-svg-round-progressbar

Repository files navigation

Angular5 SVG Round Progressbar

Ionic/Angular module that uses SVG to create a circular progressbar with Angular5 and AOT(Ahead of Time) compiler support. Originally made by crisbeto, crisbeto/angular-svg-round-progressbar. Go give that repo a star for his efforts!

Note

responsive and semicircle option is not available in this versio because of some issues. Will fix that later or you may contirubte to this repo.

NPM

https://www.npmjs.com/package/angular5-svg-round-progressbar

Installation

First you have to install the module through npm:

npm install angular5-svg-round-progressbar --save

Afterwards you need to import the RoundProgressModule in your module:

import {NgModule} from '@angular/core';
import {RoundProgressModule} from 'angular5-svg-round-progressbar';

@NgModule({
  imports: [RoundProgressModule]
})
export class YourModule {};

Options

Name Description Required Default value Possible values
current The current progress. Limited by the max option. Yes undefined number
max The progress' maximum value. Yes undefined number
radius Radius of the circle. No 125 number
color The color of the current value on the circle. No #45ccce string
background Color of the circle's background. No #eaeaea string
stroke Specifies the circle's thickness. No 15 number
semicircleN/A Whether the progressbar should be a full circle or a semicircle. No false boolean
clockwise Whether the progressbar should rotate clockwise or counter-clockwise. No true boolean
responsiveN/A Whether the progressbar should fit inside its parent container. Note Turning this option on will override the specified radius in order to make the circle fit in its parent. The radius to stroke ratio won't change. No false boolean
rounded Whether the current progress ending should be rounded or straight. No false boolean
duration The duration of the animation. Pass 0 for no animation. No 800 number
animationDelay Milliseconds to wait before starting an animation. No 0 number
onRender Callback function that gets executed every time the circle is animated. The function gets called with the current progress as it is being animated. No undefined Function
animation The easing function that will be used when animating. No easeOutCubic linearEase
easeInQuad
easeOutQuad
easeInOutQuad
easeInCubic
easeOutCubic
easeInOutCubic
easeInQuart
easeOutQuart
easeInOutQuart
easeInQuint
easeOutQuint
easeInOutQuint
easeInSine
easeOutSine
easeInOutSine
easeInExpo
easeOutExpo
easeInOutExpo
easeInCirc
easeOutCirc
easeInOutCirc
easeInElastic
easeOutElastic
easeInOutElastic
easeInBack
easeOutBack
easeInOutBack
easeInBounce
easeOutBounce
easeInOutBounce

Minimal example:

<round-progress [current]="current" [max]="max"></round-progress>

Full example:

<round-progress
    [current]="current"
    [max]="max"
    [color]="'#45ccce'"
    [background]="'#eaeaea'"
    [radius]="125"
    [stroke]="20"
    [semicircle]="true"
    [rounded]="true"
    [clockwise]="false"
    [responsive]="false"
    [duration]="800"
    [animation]="'easeInOutQuart'"
    [animationDelay]="0"
    (onRender)="doSomethingWithCurrentValue($event)"></round-progress>

Configuring the default values

The module comes with some pre-configured options for things like colors, size, stroke etc. If these don't match your app's design, you can change the global defaults by using the RoundProgressConfig service. Whenever an option isn't defined on a round-progress element, it's value will be taken from the defaults.

import {NgModule} from '@angular/core';
import {RoundProgressModule, RoundProgressConfig} from 'angular5-svg-round-progressbar';

@NgModule({
  imports: [RoundProgressModule]
})
export class YourModule {
  constructor(private _config: RoundProgressConfig) {
    _config.setDefaults({
      color: '#f00',
      background: '#0f0'
    });
  }
};

Browser support

  • Internet Explorer 9+
  • Firefox 28.0+
  • Chrome 31+
  • Safari 5.1+
  • and pretty much any browser that supports SVG

Note: Some older browsers may require (a polyfill for requestAnimationFrame). Read more about the requestAnimationFrame browser support.

Development

  • npm install to install development dependencies
  • npm run build to generate /dist/ with .js and .d.ts files

Issues

For any issues please report them in the issues section.

Credits