Skip to content

Commit c1879c4

Browse files
committed
added provision to add static text for replacing progress percentage
1 parent 49abedc commit c1879c4

File tree

4 files changed

+54
-2
lines changed

4 files changed

+54
-2
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ This HTML code demonstrates basic usage of this module:
6767
[shape]="'rectangle'"
6868
[borderColor]="'#383a3e'"
6969
[direction]="'horizontal'"
70+
[showMiddleText]="true"
71+
[middleTextStyle]="{textSize: 12,text: 'Loading'}"
7072
[showPercentage]="true"
7173
[height]="40"
7274
[progressColor]="'#FF0000'">
@@ -86,6 +88,8 @@ The `<angular-svg-progress />` component takes many attributes that allows you t
8688
| borderColor | string | Color of the svg progress component border | black |
8789
| showPercentage | boolean | To show the progress value | false |
8890
| percentageColor | string | Progress value text color | black |
91+
| showMiddleText | boolean | To show static text in the middle of the loader | false |
92+
| middleTextStyle | Object of type{text: string,textSize:number,fillColor:string,fontWeight:number/string} | style object for static text in the middle of the loader | null |
8993
| direction | string | Direction in which progress indicator grows. [horizontal,vertical] | horizontal |
9094
| backgroundFill | string | background color of the component svg | #eee8dc |
9195
| fontSize | number | Font size of the progress value text(pixel) | 15 |
@@ -94,5 +98,6 @@ The `<angular-svg-progress />` component takes many attributes that allows you t
9498
| circleWidth | number | Width of the circular disk | 15 |
9599

96100

101+
97102
## Support this project
98103
If you find this project useful, please star the repo to let people know that it's reliable. Also, share it with friends and colleagues that might find this useful as well. Thank you :smile:

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "angular-svg-progress",
3-
"version": "0.0.1",
3+
"version": "1.1.1",
44
"peerDependencies": {
55
"@angular/common": "^7.2.0",
66
"@angular/core": "^7.2.0"

src/lib/angular-svg-progress.component.html

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,19 @@
4747
>
4848
{{ svgProgress }}%
4949
</text>
50+
<text
51+
y="55%"
52+
x="50%"
53+
*ngIf="showMiddleText && !showPercentage"
54+
text-anchor="middle"
55+
[attr.font-weight]="middleTextStyle.fontWeight"
56+
alignment-baseline="middle"
57+
[attr.font-size]="middleTextStyle.textSize"
58+
[attr.fill]="middleTextStyle.fillColor"
59+
fill="blue"
60+
>
61+
{{middleTextStyle.text}}
62+
</text>
5063
</g>
5164
</svg>
5265
</span>
@@ -94,6 +107,19 @@
94107
>
95108
{{ svgProgress }}%
96109
</text>
110+
<text
111+
y="55%"
112+
x="50%"
113+
*ngIf="showMiddleText && !showPercentage"
114+
text-anchor="middle"
115+
[attr.font-weight]="middleTextStyle.fontWeight"
116+
alignment-baseline="middle"
117+
[attr.font-size]="middleTextStyle.textSize"
118+
[attr.fill]="middleTextStyle.fillColor"
119+
fill="blue"
120+
>
121+
{{middleTextStyle.text}}
122+
</text>
97123
</g>
98124
</svg>
99125
</span>
@@ -137,6 +163,19 @@
137163
>
138164
{{ svgProgress }}%
139165
</text>
166+
<text
167+
y="55%"
168+
x="50%"
169+
*ngIf="showMiddleText && !showPercentage"
170+
text-anchor="middle"
171+
[attr.font-weight]="middleTextStyle.fontWeight"
172+
alignment-baseline="middle"
173+
[attr.font-size]="middleTextStyle.textSize"
174+
[attr.fill]="middleTextStyle.fillColor"
175+
fill="blue"
176+
>
177+
{{middleTextStyle.text}}
178+
</text>
140179
</g>
141180
</svg>
142181
</span>

src/lib/angular-svg-progress.component.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
import { Component, OnInit, Input, SimpleChanges } from '@angular/core';
22

3+
export interface CenterTextStyle {
4+
text: string;
5+
textSize: number;
6+
fillColor: string;
7+
fontWeight: number | number;
8+
}
39
@Component({
410
selector: 'angular-svg-progress',
511
templateUrl: 'angular-svg-progress.component.html'
@@ -12,7 +18,9 @@ export class AngularSvgProgressComponent implements OnInit {
1218
@Input() height: number = 100;
1319
@Input() shape: string = 'rectangle';
1420
@Input() borderColor: string = 'black';
15-
@Input() showPercentage: boolean;
21+
@Input() showPercentage: boolean = true;
22+
@Input() showMiddleText: boolean;
23+
@Input() middleTextStyle: CenterTextStyle;
1624
@Input() percentageColor: string = 'black';
1725
@Input() direction: string = 'horizontal';
1826
@Input() backgroundFill: string = '#eee8dc';

0 commit comments

Comments
 (0)