• About Me
  • Contact Us
  • Privacy Policy
  • Terms and Conditions
  • Advertise / Sponsor

DOTNET DETAIL

Learn Microsoft .NET Technologies

  • Home
  • Tutorials
    • Angular
      • Angular 5
      • Angular 6
    • ASP.NET Core
    • Azure
    • React
    • Vue
  • Books
  • Courses
  • Cloud Hosting
  • Interview Questions
You are here: Home / Angular / How to add pie chart in Angular 6 and Asp Net Core application using chart.js

How to add pie chart in Angular 6 and Asp Net Core application using chart.js

September 16, 2018 by mebakar1005 Leave a Comment

In this tutorial, we are going to learn how to add static chart in Angular 6 and Asp Net Core project using chart.js. Displaying data in chart is very common in complex or business application. Because it makes your application user friendly. So, It’s very easy to implement chart in Angular 6 and Asp Net Core Application. So, after reading this tutorial, you will understand how to add pie chart in Angular 6 application.

Previous Tutorials of Angular 6 and Asp Net Core Series

  • How to setup a project using Angular CLI in VS Code?
  • How to Setup a project with Angular 6 and ASP.NET Core 2.1 ?
  • How to create CRUD Operations using Angular 6 and ASP.NET Core?
  • How to implement Search functionality in Angular 6 & ASP.NET Core?
  • How to implement server-side filtration in angular 6 & asp.net core ?
  • How to sort record using angular 6 and asp.net core?
  • Search, Sort, and Pagination in angular 6 and asp.net core.
  • How to create web api in angular 6 and asp.net core?
  • How to implement Angular 6 authentication and authorization using Asp Net Core?
  • How to upload file using Angular 6 and Asp Net web API?

Note: – we are not going to create a new project in this tutorial. If you don’t know how to create a new project using Angular 6 and Asp Net Core, then click here.

Learn how to add static pie chart in Angular 6 and Asp Net Core Application?

Let’s start to understand how to add chart in Angular 6 application in steps.

Step # 1 : Add Some Node Packages.

First-of-all, we need to install some node packages in our Angular 6 application. So, to do it, go to Visual Studio Code terminal => then write these below commands.

See also  How to Create an Angular 8 and Asp.Net Core 3 app using VS2019

=> npm install chart.js angular2-chartjs --save

This above command will create bunch of components that we can use in our project.

Step # 2 : Import the module into the App.Module.ts

Now in this step we need to import module into the app.module.ts file. So, go to project folder structure and open the app.module.ts file and then add the below line of code into the app.module.ts.

import {ChartModule} from 'angular2-chartjs';

Now, add the “ChartModule” into the imports block.

Step # 3 : Create A New Component

Now in this step we will create a new component to show pie chart in Angular 6 application. So, to do it, go to Visual Studio terminal and add the below Angular CLI command to create a new component. Note: – make sure you are creating new component in correct location.

=> ng g component pie-chart

After running this command, you will see a new folder with the name of pie-chart in your project folder directory with some files.

Note: – Don’t forget to add route of this component.

Step # 4 : Add Front-end code.

Now in this step we will add front-end code for pie chart in our angular 6 project. So, go to pie-chart folder and open “pie-chart.component.html” file and then add the code into this file as you see in the below line.

<chart type="pie" [data]="data"></chart>

Step # 5 : Add component code.

Now go to pie-chart.component.ts file and add the code as you see in the below file.

Step # 6 : Run your project

Now run your project and go to browser and write the url like this “http://localhost:5000/PieChart” and then you will see a beautiful pie chart as you see in the below screenshot.

See also  How to upgrade Asp.Net Core 3.1 App to Asp.Net Core 5

How to upload file using Angular 6 and Asp Net Core 2.1 web API
How to deploy Angular 6 and Asp Net Core Application in IIS 8?

Related

Filed Under: Angular, Angular 5, Angular 6, ASP.NET Core Tagged With: Angular 6 Pie Chart, Angular 6 Tutorial, Chart in Angular 6, Pie Chart

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Buy me a coffeeBuy me a coffee

Jobs

Dotnet Jobs

Join Us

Join Us

Subscribe to Blog via Email

Enter your email address to subscribe.

Recent Posts

  • Overland Park: más grande suburbio de Kansas City es en realidad un romántico Destino lleno de Exterior Actividades, Comida excelentes y Cultura
  • Lasting Online Dating Sites: Techniques For Survival
  • Very best Antiviruses Designed for PC Game enthusiasts
  • Very best Antivirus Software
  • Realmente Hace Él En absoluto como yo ?
  • Fiscal Planning — What You Need to Know
Copyright © 2022