1.1.2 • Published 4 years ago

dev-ng-circle-progress v1.1.2

Weekly downloads
3
License
MIT
Repository
github
Last release
4 years ago

dev-ng-circle-progress

Demo

Original Package Demo

demo

About

Edits to a simple circle progress component created for angular based only on SVG graphics and has various of options to customize it.

Installation

To install this library, run:

Angular 6 projects

$ npm install dev-ng-circle-progress --save

Angular 5 or Angular 4 projects

$ npm install dev-ng-circle-progress@1.0.0 --save

Once you have installed it, you can import it in any Angular application,

then from your Angular AppModule:

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';

import { AppComponent } from './app.component';

// Import dev-ng-circle-progress
import { DevNgCircleProgressModule } from 'dev-ng-circle-progress';

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,

    // Specify dev-ng-circle-progress as an import
    DevNgCircleProgressModule.forRoot({
      // set defaults here
      radius: 100,
      outerStrokeWidth: 16,
      innerStrokeWidth: 8,
      outerStrokeColor: "#78C000",
      innerStrokeColor: "#C7E596",
      animationDuration: 300,
      ...
    })

  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

Once DevNgCircleProgressModule is imported, you can use CircleProgressComponent in your Angular application:

<!-- You can now use it in app.component.html -->
<circle-progress
  [percent]="85"
  [radius]="100"
  [outerStrokeWidth]="16"
  [innerStrokeWidth]="8"
  [outerStrokeColor]="'#78C000'"
  [innerStrokeColor]="'#C7E596'"
  [animation]="true"
  [animationDuration]="300"
></circle-progress>

Options

OptionTypeDefaultDescription
percentnumber0Number of percent you want to show
maxPercentnumber1000Max number of percent you want to show
radiusnumber90Radius of circle
clockwisebooleantrueWhether to rotate clockwise or counter-clockwise
responsivebooleanfalseWhether to make the circle responsive
startFromZerobooleantrueWhether to start the percent from zero
showZeroOuterStrokebooleantrueWhether to show the bar if percent is zero
showTitlebooleantrueWhether to display title
showSubtitlebooleantrueWhether to display subtitle
showUnitsbooleantrueWhether to display units
showImagebooleantrueWhether to display image. All text will be hidden if showImage is true.
showBackgroundbooleantrueWhether to display background circle
showInnerStrokebooleantrueWhether to display inner stroke
backgroundStrokestring'transparent'Background stroke color
backgroundStrokeWidthnumber0Stroke width of background circle
backgroundPaddingnumber5Padding of background circle
backgroundGradientbooleanfalseMake background gradient
backgroundColorstring'transparent'Background color
backgroundGradientStopColorstring'transparent'Background gradient stop color
backgroundOpacitynumber1Opacity of background color
spacenumber4Space between outer circle and inner circle
toFixednumber0Using fixed digital notation in Title
renderOnClickbooleantrueRender when component is clicked
unitsstring'%'Units showed aside the title
unitsFontSizestring'10'Font size of units
unitsFontWeightstring'100'Font weight of units
unitsColorstring'#444444'Font color of units
outerStrokeWidthnumber8Stroke width of outer circle (progress circle)
outerStrokeGradientbooleanfalseMake outer circle gradient
outerStrokeColorsting'#78C000'Stroke color of outer circle
outerStrokeGradientStopColorstring'transparent'Stroke gradient stop color of outer circle
outerStrokeLinecapsting'round'Stroke linecap of outer circle. Possible values(butt, round, square, inherit)
innerStrokeWidthnumber4Stroke width of inner circle
innerStrokeColorsting'#C7E596'Stroke color of inner circle
titlestring\|Array<String>'auto'text showed as title. Percentage is displayed when title equals 'auto'.
titleFormatFunctionundefinedA callback function to format title. It returns a string or an array of string.
titleColorstring'#444444'Font color of title
titleFontSizestring'20'Font size of title
titleFontWeightstring'100'Font weight of title
subtitlestring\|Array<String>'Percent'text showed as subtitle
subtitleFormatFunctionundefinedA callback function to format subtitle. It returns a string or an array of string.
subtitleColorstring'#A9A9A9'Font color of subtitle
subtitleFontSizestring'10'Font size of subtitle
subtitleFontWeightstring'100'Font weight of subtitle
imageSrcstring'/assets/images/music.svg'Src of image
imageHeightnumber80Height of image
imageWidthnumber80Width of image
containerHeightstring80%Height of circle
containerWidthstring80%Width of circle
animationbooleantrueWhether to animate the outer circle when rendering
animateTitlebooleantrueWhether to animate the title when rendering
animateSubtitlebooleanfalseWhether to animate the subtitle when rendering
animationDurationnumber500Duration of animation in microseconds
classstring''CSS class name for SVG element
lazybooleanfalsePauses when out of viewport
// subtitleFormat callback example
formatSubtitle = (percent: number) : string => {
  if(percent >= 100){
    return "Congratulations!"
  }else if(percent >= 50){
    return "Half"
  }else if(percent > 0){
    return "Just began"
  }else {
    return "Not started"
  }
}

Development (needs Angular 6)

To generate all *.js, *.d.ts and *.metadata.json files:

$ npm run build

To lint all *.ts files:

$ npm run lint

License

Original MIT © bootsoon

This project was generated by Yeoman generator angular2-library

1.1.2

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.0

4 years ago