In this article, I have explained how to build custom charts based on the Sharepoint list using chartJs library.
Now I am going to create a simple task list in SharePoint, then I am going to build a doughnut/Pie chart based on list data.
Let’s get started, I have a task list with some information already entered.
![New task]()
After that now I'm going to download the chartjs library from their CDN.
https://cdnjs.com/libraries/Chart.js
You can download it from the above link.
Create an HTML file in your SharePoint site assets folder and paste the below HTML snippet.
Now create a function named GetChartData(); then query the task list using REST API or using SharePoint PNP JS Library and Process the data to render the chart inside your content editor or script editor web part.
_.countBy helps you to calculate the number of items counted based on the “Status” Column.
Here we go -- finally we can see the chart has been successfully rendered.
![In progress]()
I have made some changes to control the width and height of the chart.
Full code
Happy Coding!