Angular module that uses SVG to create a circular progressbar
First you have to install the module through npm:
npm install angular-svg-round-progressbar --save
Afterwards you need to import the RoundProgressModule
in your module:
import {NgModule} from '@angular/core';
import {RoundProgressModule} from 'angular-svg-round-progressbar';
@NgModule({
imports: [RoundProgressModule]
})
export class YourModule {};
If you're using SystemJS as your module loader, there is also a UMD bundle at ./node_modules/angular-svg-round-progressbar/bundles/angular-svg-round-progressbar.umd.js
.
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 |
semicircle |
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 |
responsive |
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 |
<round-progress [current]="current" [max]="max"></round-progress>
<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>
The module comes with some pre-configured options for things like colors, size, stroke etc. If thesedon't match your app's design, you can change the global defaults by providing a new value for theROUND_PROGRESS_DEFAULTS
injection token. 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,
ROUND_PROGRESS_DEFAULTS
} from 'angular-svg-round-progressbar';
@NgModule({
imports: [RoundProgressModule],
providers: [{
provide: ROUND_PROGRESS_DEFAULTS,
useValue: {
color: '#f00',
background: '#0f0'
}
}]
})
export class YourModule {};
Note: Some older browsers may require (a polyfill for requestAnimationFrame
).Read more about the requestAnimationFrame
browser support.
The project uses yarn
to manage dependencies to make sure that you have it installed.
yarn
to install development dependencies.yarn lint
to lint the source files.yarn start
to run a development server. Go to localhost:4200
to see the demo.yarn build-lib
to build the library in production mode.yarn build-demo
to build the demo in production mode.yarn release-lib
to build the library and release it to npm.yarn release-demo
to build the demo and deploy it to GitHub Pages.<ProgressBar Android:id="@+id/progressbar" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_vertical"> </ProgressBar>默认就是圆形状
前一段时间,因为项目须要研究了下progressbar,发现这个小东西还真是不简单。在这个小控件的显示效果上,花费的时间远大于预估的工作量。话说程序猿一直是这样,预估的工作量远少于实际。。。 先说明一下,这里主要是针对水平进度条进行说明的,关于圆形进度条或者其它进度条能够依此类推。android系统默认的进度条是圆形的,用到水平进度条一般都会加上这样一个属性:"@an
Angular SVG Icon The angular-svg-icon is an Angular 12 service and component that provides ameans to inline SVG files to allow for them to be easily styled by CSS and code. The service provides an ico
描述 (Description) round()方法接受一个数字,并返回舍入到最接近整数的数字的值 语法 (Syntax) 下面给出了JavaScript的round()方法的语法。 我们可以在CoffeeScript代码中使用相同的方法。 Math.round ( x ) 例子 (Example) 以下示例演示了CoffeeScript中round()方法的用法。 将此代码保存在名为math_
描述 (Description) round方法返回最接近的long或int,由方法返回类型给出。 语法 (Syntax) 此方法有以下变体 - long round(double d) int round(float f) 参数 (Parameters) 这是参数的细节 - d - double或float原始数据类型。 f - 浮点原始数据类型。 返回值 (Return Value) 此方法
描述 (Description) round()方法接受一个数字,并返回舍入到最接近整数的数字的值 语法 (Syntax) 下面给出了JavaScript的round()方法的语法。 我们可以在CoffeeScript代码中使用相同的方法。 Math.round ( x ) 例子 (Example) 以下示例演示了CoffeeScript中round()方法的用法。 将此代码保存在名为math_
此方法返回舍入到最接近整数的数字的值。 语法 (Syntax) Number.round() 返回值 (Return Value) 返回舍入到最接近整数的数字的值。 例子 (Example) void main() { double n1 = 12.023; double n2 = 12.89; var value = n1.round(); print( val
round方法返回最接近的long或int,由方法返回类型给出。 语法 (Syntax) long round(double d) int round(float f) 参数 (Parameters) d - double或float原始数据类型 f - 浮点原始数据类型 返回值 (Return Value) 此方法返回最接近的long或int ,如方法的返回类型所示,返回参数。 例子 (Ex