- Chart.js - Discussion
- Chart.js - Useful Resources
- Chart.js - Quick Guide
- Chart.js - Radial Axis
- Chart.js - Category Axis
- Chart.js - Cartesian Axis
- Chart.js - Mixed Chart
- Chart.js - Scatter Chart
- Chart.js - Bubble Chart
- Chart.js - Polar Area Chart
- Chart.js - Pie Chart
- Chart.js - Doughnut Chart
- Chart.js - Radar Chart
- Chart.js - Bar Chart
- Chart.js - Line Chart
- Chart.js - Tooltip
- Chart.js - Animation
- Chart.js - Title
- Chart.js - Legend
- Chart.js - Interactions
- Chart.js - Options
- Chart.js - Color
- Chart.js - Basics
- Chart.js - Syntax
- Chart.js - Installation
- Chart.js - Introduction
- Chart.js - Home
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
Chart.js - Doughnut Chart
Chart.js doughnut chart is one of the most used charts to represent the data sets. Doughnut charts spanided into various segments in which the arc of each segment shows the proportional value of each piece of data. If you want to show the relational proportions between data, doughnut chart is an excellent choice.
Following are the namespaces to be used in doughnut chart for dataset properties −
data.datasets[index] − It provides options for this dataset only.
options.datasets.doughnut − It provides options for all doughnut datasets.
options.elements.arc − It provides options for all the arc elements.
Options − It provides options for the whole chart
We need to use type: ’doughnut’ for creating the doughnut chart.
Example
Let’s take an example with the help of which we will create a doughnut chart −
<!DOCTYPE> <html> <head> <meta charset- "UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1" /> <title>chart.js</title> </head> <body> <canvas id="chartId" aria-label="chart" height="350" width="580"></canvas> <script src="https://cdnjs.cloudflare.com/ajax/pbs/Chart.js/3.1.1/chart.min.js"></script> <script> var chrt = document.getElementById("chartId").getContext("2d"); var chartId = new Chart(chrt, { type: doughnut , data: { labels: ["HTML", "CSS", "JAVASCRIPT", "CHART.JS", "JQUERY", "BOOTSTRP"], datasets: [{ label: "onpne tutorial subjects", data: [20, 40, 13, 35, 20, 38], backgroundColor: [ yellow , aqua , pink , pghtgreen , gold , pghtblue ], hoverOffset: 5 }], }, options: { responsive: false, }, }); </script> </body> </html>