0.1.1 • Published 5 years ago

ngx-radial-progress v0.1.1

Weekly downloads
7
License
Apache-2.0
Repository
-
Last release
5 years ago

Angular Radial Progress

A simple radial progress component for Angular. Responsive and highly customizable.

Installation

Import in your Angular AppModule like:

// Import radial-progress
import {RadialProgressModule} from "ngx-radial-progress";

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    RadialProgressModule // Import RadialProgressModule here
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule {}

Use it in your Angular application like:

<radial-progress
  [percent]="85"
  [circleSize]="250"
  [title]="'Title goes here'"
></radial-progress>

Options

OptionTypeDefaultDescription
addClassstring''add custom class(es) to component
animationbooleantruewhether to animate drawing of outer circle or not
circleSizenumber0size of circle. If 0 the circle is scaled relative to parent
clockwisebooleanfalsewhether to rotate clockwise or counter-clockwise
delaynumber0delay drawing of outer circle (in ms)
fillstring'transparent'color of fill of outer circle. Pass any color values you want
fillBackgroundstring'transparent'color of fill of inner circle. Pass any color values you want
percentnumber50number of percent
percentUnitstring'%'unit after percentage counter
showPercentbooleantruewhether to show (percentage) counter or not
strokeBackgroundstring'transparent'color of inner stroke. Pass any color values you want
strokeLinecapstring'butt'stroke linecap of outer circle. Possible values: 'butt', 'round', 'square', 'inherit'
strokeStepsarray{strokeColor: 'red',strokeStep: 10}, {strokeColor: 'green',strokeStep: 100}array with json object(s). Only relevant if animation == true
strokeSteps.strokeColorstring'red', 'green'color of outer circle until current step. Pass any color values you want. Only relevant if animation == true
strokeSteps.strokeStepnumber10, 100defines color to given percentage value. Make sure to define strokeColor for strokeStep == 100. Only relevant if animation == true
strokeWidthnumber10width of outer circle stroke
strokeWidthBackgroundnumber10width of inner circle stroke
titlestring''text to display. Leave empty to hide
transitionDurationnumber5000time to draw outer circle to 100% (in ms). Only relevant if animation == true

How stroke steps work

As mentioned in the options, there is one option strokeSteps. In here, you can define multiple intervals for your radial progress.

For example

   <radial-progress
     [percent]="85"
     [strokeSteps]="[{
         strokeColor: '#e00079',
         strokeStep: 25
      }, {
         strokeColor: '#ff7300',
         strokeStep: 50
      }, {
         strokeColor: 'rgb(149, 193, 31)',
         strokeStep: 75
      }, {
         strokeColor: 'rgb(58, 65, 68)',
         strokeStep: 100
      }]"
   ></radial-progress>

will result in something like this alt text depending on the given percentage. That means:

  • color = #e00079 for percentage interval between 0 - 24
  • color = #ff7300 for percentage interval between 25 - 49
  • color = rgb(149, 193, 31) for percentage interval between 50 - 74
  • color = rgb(58, 65, 68) for percentage interval between 75 - 100

NOTE: If you want only one single color, define strokeSteps like this:

   <radial-progress
     [strokeSteps]="[{
        strokeColor: 'red',
        strokeStep: 100
     }]"
   ></radial-progress>

Thank you

BrowserStack

Thank you BrowserStack for prodiving us with the infrastructure needed to test ngx-radial-progress.

License

ngx-radial-progress is released under the Apache 2.0 license.