Angular Primeng MeterGroup Component
Last Updated :
03 Sep, 2024
Angular PrimeNG is an open-source framework that comes with a large collection of native Angular UI components for amazing style. It makes creating responsive websites a breeze. Multiple metrics or progress indicators are often displayed as a series of progress bars using PrimeNG's MeterGroupModule.
The MeterGroup Component is a tool from PrimeNG, a popular library from angular that helps you to create fancy and useful interfaces. The MeterGroup Component lets you display several meters together in one place.
Prerequisites
Approach
- value: Display The metergroup's current value.
- Min: Minimum boundary value.
- Max: Maximum boundary value.
- orientation: defines the component's layout; the values "horizontal" and "vertical" are acceptable.
- labelPosition: Specifies the label position of the component, valid values are 'start' and 'end'.
- labelOrientation: Specifies the label orientation of the component, valid values are 'horizontal' and 'vertical'.
Syntax:
<p-meterGroup
[value]="..."
[max]="..."
[max]="..."
[orientation]="..."
....
[style]="..."></p-meterGroup>
Steps To Implement MeterGroup Component
Step 1: Install Angular CLI
If you haven’t installed Angular CLI yet, install it using the following command
npm install -g @angular/cli
Step 2: Create an Angular application using the following command.
ng new metergroup
Folder Structure
Folder StructureDependencies
"dependencies": {
"@angular/animations": "^18.0.0",
"@angular/common": "^18.0.0",
"@angular/compiler": "^18.0.0",
"@angular/core": "^18.0.0",
"@angular/forms": "^18.0.0",
"@angular/platform-browser": "^18.0.0",
"@angular/platform-browser-dynamic": "^18.0.0",
"@angular/platform-server": "^18.0.0",
"@angular/router": "^18.0.0",
"@angular/ssr": "^18.0.0",
"express": "^4.18.2",
"primeicons": "^7.0.0",
"primeng": "^17.18.9",
"rxjs": "~7.8.0",
"tslib": "^2.3.0",
"zone.js": "~0.14.3"
}
Step 3: Install PrimeNG in your given directory.
npm install primeng --save
npm install primeicons --save
Basic MeterGroup Component
App Component
Below mentioned is code example of app component having a HTML file and ts file to display metergroup and import it in imports array.
HTML
<!-- src/app/app.component.html -->
<p-meterGroup [value]="value"></p-meterGroup>
JavaScript
// src/app/app.component.ts
import { Component } from '@angular/core';
import { RouterOutlet } from '@angular/router';
import { MeterGroupModule } from 'primeng/metergroup';
@Component({
selector: 'app-root',
standalone: true,
imports: [RouterOutlet, MeterGroupModule],
templateUrl: './app.component.html',
styleUrl: './app.component.css'
})
export class AppComponent {
title = 'metergroup';
value = [
{ label: 'Space used', value: 15, color: '#7A1CAC' }
];
}
Output:
Basic MeterComponentMultiple,Icon and Label MeterGroup Component
App Component
Below mentioned is code example of app component having a HTML file and ts file to display metergroup and t=import it in imports array.
HTML
<!-- src/app/app.component.html -->
<p-meterGroup [value]="value" labelPosition="start" labelOrientation="vertical"></p-meterGroup>
JavaScript
//src/app/app.component.ts
import { Component } from '@angular/core';
import { RouterOutlet } from '@angular/router';
import { MeterGroupModule } from 'primeng/metergroup';
@Component({
selector: 'app-root',
standalone: true,
imports: [RouterOutlet, MeterGroupModule],
templateUrl: './app.component.html',
styleUrl: './app.component.css'
})
export class AppComponent {
title = 'metergroup';
value = [
{ label: 'Apps', color: '#34d399', value: 16, icon: 'pi pi-table' },
{ label: 'Messages', color: '#fbbf24', value: 8, icon: 'pi pi-inbox' },
{ label: 'Media', color: '#60a5fa', value: 24, icon: 'pi pi-image' },
{ label: 'System', color: '#c084fc', value: 10, icon: 'pi pi-cog' }
];
}
Output:
Multiple, Icon and Label MeterGroup Component
Vertical and min ,max MeterGroup Component
App Component
Below mentioned is code example of app component having a HTML file and ts file to display metergroup and t=import it in imports array.
HTML
<!-- src/app/app.component.html -->
<p-meterGroup [value]="value" labelPosition="start" labelOrientation="vertical" orientation="vertical"
[style]="{ height: '150px' }" [max]="100" [min]="5"></p-meterGroup>
JavaScript
//src/app/app.component.ts
import { Component } from '@angular/core';
import { RouterOutlet } from '@angular/router';
import { MeterGroupModule } from 'primeng/metergroup';
@Component({
selector: 'app-root',
standalone: true,
imports: [RouterOutlet, MeterGroupModule],
templateUrl: './app.component.html',
styleUrl: './app.component.css'
})
export class AppComponent {
title = 'metergroup';
value = [
{ label: 'Apps', color: '#34d399', value: 16, icon: 'pi pi-table' },
{ label: 'Messages', color: '#fbbf24', value: 8, icon: 'pi pi-inbox' },
{ label: 'Media', color: '#60a5fa', value: 24, icon: 'pi pi-image' },
{ label: 'System', color: '#c084fc', value: 10, icon: 'pi pi-cog' }
];
}
Output:
Vertical and min, max Meter Group Component
Similar Reads
Angular PrimeNG InputGroup Component Angular PrimeNG is an open-source framework with a rich set of native Angular UI components that are used for great styling and this framework is used to make responsive websites with very much ease. In this article, we will know how to use the InputGroup component in angular primeNG. InputGroup com
2 min read
Angular PrimeNG Dock Component Angular PrimeNG is an open-source framework with a rich set of native Angular UI components that are used for great styling and this framework is used to make responsive websites with very much ease. It provides a lot of templates, components, theme design, an extensive icon library, and much more.
4 min read
Angular PrimeNG FilterService Component Angular PrimeNG is an open-source framework with a rich set of native Angular UI components that are used for great styling and this framework is used to make responsive websites with very much ease. It provides a lot of templates, components, theme design, an extensive icon library, and much more.
7 min read
Angular PrimeNG Form InputGroup Addons Component Angular PrimeNG is an open-source framework with a rich set of native Angular UI components that are used for great styling and this framework is used to make responsive websites with very much ease. In this article, we will learn how to use the InputGroup Addons Component in Angular PrimeNG. The In
3 min read
Angular PrimeNG tag Component Angular PrimeNG is an open-source framework with a rich set of native Angular UI components that are used for great styling and this framework is used to make responsive websites with very much ease. In this article, we will know how to use the tag component in Angular PrimeNG. tag component: It is
3 min read