Open In App

Angular PrimeNG Radar Chart Component

Last Updated : 30 Nov, 2022
Improve
Improve
Like Article
Like
Save
Share
Report

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 see the Radar Chart Component in Angular PrimeNG.

A Radar Chart is a graphical method for rendering multivariate data that is represented in a 2D chart of three or more quantitative variables represented on axes beginning from the same point.

Syntax:

<p-chart type="radar" 
         [data]="data" 
         [options]="chartOptions" >
</p-chart>

Creating Angular application & Module Installation:

Step 1: Create an Angular application using the following command.

ng new appname

Step 2:  After creating your project folder i.e. appname, move to it using the following command.

cd appname

Step 3: Install PrimeNG in your given directory.

npm install primeng --save
npm install primeicons --save
npm install chart.js --save

Project Structure: It will look like the following:

 

Example 1: This example describes the basic usage of the Radar Chart Component in Angular PrimeNG, where we display a single dataset in a Radar chart.

  • app.component.html

HTML




<div id="GFG">
    <h1 style="color:green">
        GeeksforGeeks
    </h1>
    <h2>Angular PrimeNG Radar Chart </h2>
    <div style="width:30%;">
        <p-chart type="radar" 
                 [data]="data" 
                 [style]="{'width': '40%'}">
        </p-chart>
    </div>
</div>


  • app.component.ts

Javascript




import { Component } from '@angular/core';
  
@Component({
    selector: 'app-root',
    templateUrl: './app.component.html',
})
export class AppComponent {
    title = 'GFG';
    data = {
        labels: ['GeeksforGeeks', 'Tutorial Point', 'W3 Schools'
                 'Javatpoint', 'Indiabix', 'Codechef', 'Hackerrank'],
        datasets: [
            {
                label: 'Single Dataset',
                data: [75, 49, 95, 71, 66, 65, 45],
                backgroundColor: 'lightgreen',
                borderColor: 'lightgreen',
                pointHoverBackgroundColor: '#fff',
                pointHoverBorderColor: 'lightgreen',
            }
        ]
    };
}


  • app.module.ts

Javascript




import { NgModule } from '@angular/core';
import { BrowserModule } 
    from '@angular/platform-browser';
import { AppComponent } from './app.component';
import { ChartModule } from 'primeng/chart';
  
@NgModule({
    declarations: [
        AppComponent,
  
    ],
    imports: [
        BrowserModule,
        ChartModule
    ],
    providers: [],
    bootstrap: [AppComponent]
})
export class AppModule { }


Output:

 

Example 2: This example describes the basic usage of the Radar Chart Component in Angular PrimeNG, we are representing multiple datasets in Radar Chart.

  • app.component.html

HTML




<div id="GFG">
    <h1 style="color:green">
        GeeksforGeeks
    </h1>
    <h2>Angular PrimeNG Radar Chart </h2>
    <div style="width:30%;">
        <p-chart type="radar" 
                 [data]="data" 
                 [style]="{'width': '40%'}">
        </p-chart>
    </div>
</div>


  • app.component.ts

Javascript




import { Component } from '@angular/core';
  
@Component({
    selector: 'app-root',
    templateUrl: './app.component.html'
})
export class AppComponent {
    title = 'GFG';
    data = {
        labels: ['GeeksforGeeks', 'Tutorial Point', 'W3 Schools'
                 'Javatpoint', 'Indiabix', 'Codechef', 'Hackerrank'],
        datasets: [
            {
                label: 'First Dataset',
                data: [75, 49, 95, 71, 66, 65, 45],
                backgroundColor: 'lightgreen',
                borderColor: 'lightgreen',
                pointHoverBorderColor: 'lightgreen',
  
            },
            {
                label: 'Second dataset',
                data: [85, 99, 75, 41, 86, 56, 55],
                backgroundColor: 'pink',
                borderColor: 'pink',
                pointHoverBorderColor: 'pink',
            }
        ]
    };
}


  • app.module.ts

Javascript




import { NgModule } from '@angular/core';
import { BrowserModule } 
    from '@angular/platform-browser';
import { AppComponent } from './app.component';
import { ChartModule } from 'primeng/chart';
  
@NgModule({
    declarations: [
        AppComponent,
  
    ],
    imports: [
        BrowserModule,
        ChartModule
    ],
    providers: [],
    bootstrap: [AppComponent]
})
export class AppModule { }


Output:

 

Reference: http://primefaces.org/primeng/chart/radar



Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads