{"id":16671,"date":"2023-06-13T08:29:27","date_gmt":"2023-06-13T08:29:27","guid":{"rendered":"https:\/\/www.anychart.com\/blog\/?p=16671"},"modified":"2023-06-14T08:12:40","modified_gmt":"2023-06-14T08:12:40","slug":"donut-chart-js","status":"publish","type":"post","link":"https:\/\/www.anychart.com\/blog\/2023\/06\/13\/donut-chart-js\/","title":{"rendered":"How to Create Donut Chart Using JavaScript"},"content":{"rendered":"<p><a href=\"https:\/\/www.anychart.com\/blog\/2023\/06\/13\/donut-chart-js\/\"><img decoding=\"async\" src=\"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2023\/06\/donut-chart.png\" alt=\"Interactive Donut Chart Built Using JavaScript\" width=\"100%\" class=\"alignnone size-full wp-image-16680\" srcset=\"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2023\/06\/donut-chart.png 1800w, https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2023\/06\/donut-chart-300x153.png 300w, https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2023\/06\/donut-chart-768x390.png 768w, https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2023\/06\/donut-chart-1024x521.png 1024w\" sizes=\"(max-width: 1800px) 100vw, 1800px\" \/><\/a>Visualizing data isn\u2019t just insightful, it\u2019s also a lot of fun! One of the simplest and most enjoyable charts you can create is the donut chart. And now, I will show you how to make an awesome interactive one using JavaScript effortlessly!<\/p>\n<p>Aptly named because it looks like a donut, a <a href=\"https:\/\/www.anychart.com\/chartopedia\/chart-type\/donut-chart\/\">donut chart<\/a> is essentially a <a href=\"https:\/\/www.anychart.com\/chartopedia\/chart-type\/pie-chart\/\">pie chart<\/a> with a hole in the center. It can be nice for representing categorical data with a moderate number of categories, where each slice represents a percentage of the whole. Throughout this tutorial, we will apply the donut charting technique to visualize the impressive Grand Slam title tally of a tennis legend, <a href=\"https:\/\/en.wikipedia.org\/wiki\/Roger_Federer\" target=\"_blank\" rel=\"nofollow\">Roger Federer<\/a>. So you\u2019ll have a real-world example to work with and enhance your understanding.<\/p>\n<p>I\u2019ll guide you through each step, ensuring a seamless learning experience. By the end of the tutorial, you\u2019ll have all the skills and knowledge required to create your very own personalized and impressive JS donut chart. So let\u2019s embark on this exciting journey and get started!<\/p>\n<p><!--more Read the JS charting tutorial \u00bb--><\/p>\n<h2>Donut Chart Preview<\/h2>\n<p>Here\u2019s a sneak peek at the donut chart we\u2019ll build by the end of this tutorial (and it will be interactive).<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2023\/06\/donut-chart-js-preview-.gif\" alt=\"JS Donut Chart Preview\" width=\"100%\" class=\"alignnone size-full wp-image-16681\" \/><\/p>\n<h2>Building a JavaScript Donut Chart in Four Steps<\/h2>\n<p>Let\u2019s dive into how you can quickly and easily create a beautiful and functional donut chart using JavaScript. The process can be split into four steps:<\/p>\n<ol>\n<ol>\n<li>Create a basic HTML page.<\/li>\n<li>Include the necessary JavaScript files.<\/li>\n<li>Add the data.<\/li>\n<li>Write the JS code.<\/li>\n<\/ol>\n<\/ol>\n<h3>1. Create a basic HTML page<\/h3>\n<p>To begin, let\u2019s create a basic HTML page with a <code>&lt;div&gt;<\/code> element to hold the donut chart. Give it an ID. Set the width and height to 100% with no margins or padding if you want to ensure that the chart renders full screen.<\/p>\n<pre><code class=\"html\">&lt;html&gt;\r\n  &lt;head&gt;\r\n    &lt;title&gt;JavaScript Donut Chart&lt;\/title&gt;\r\n    &lt;style type=\"text\/css\"&gt;      \r\n      html, body, #container { \r\n        width: 100%; height: 100%; margin: 0; padding: 0; \r\n      } \r\n    &lt;\/style&gt;\r\n  &lt;\/head&gt;\r\n  &lt;body&gt;\r\n    &lt;div id=\"container\"&gt;&lt;\/div&gt;\r\n  &lt;\/body&gt;\r\n&lt;\/html&gt;<\/code><\/pre>\n<h3>2. Include the necessary JavaScript files<\/h3>\n<p>JavaScript charting libraries provide ready-to-use features that simplify chart development, even for those without extensive technical skills. There are many out there and the core principles are the same.<\/p>\n<p>For this tutorial, we\u2019ll use a JS charting library called <a href=\"https:\/\/www.anychart.com\/\">AnyChart<\/a> to create the donut. It\u2019s a lightweight and flexible data viz tool with many <a href=\"https:\/\/www.anychart.com\/products\/anychart\/gallery\/\">examples<\/a> and comprehensive <a href=\"https:\/\/www.anychart.com\/\">documentation<\/a> to help you get started. To build a JavaScript donut chart, we need to include two scripts in our HTML page\u2019s <code>&lt;head&gt;<\/code> section: the core module and the pie module.<\/p>\n<pre><code class=\"html\">&lt;html&gt;\r\n  &lt;head&gt;\r\n    &lt;title&gt;JavaScript Donut Chart&lt;\/title&gt;\r\n    &lt;script src=\"https:\/\/cdn.anychart.com\/releases\/8.11.1\/js\/anychart-core.min.js\"&gt;&lt;\/script&gt;\r\n    &lt;script src=\"https:\/\/cdn.anychart.com\/releases\/8.11.1\/js\/anychart-pie.min.js\"&gt;&lt;\/script&gt;\r\n    &lt;style type=\"text\/css\"&gt;      \r\n      html, body, #container { \r\n        width: 100%; height: 100%; margin: 0; padding: 0; \r\n      } \r\n    &lt;\/style&gt;\r\n  &lt;\/head&gt;\r\n  &lt;body&gt;  \r\n    &lt;div id=\"container\"&gt;&lt;\/div&gt;\r\n    &lt;script&gt;\r\n      \/\/ All the code for the JS donut chart will come here\r\n    &lt;\/script&gt;\r\n  &lt;\/body&gt;\r\n&lt;\/html&gt;<\/code><\/pre>\n<h3>3. Add the data<\/h3>\n<p>So, let\u2019s take a look at the composition of Roger Federer\u2019s Grand Slam title tally. You\u2019ve probably heard of him even if you\u2019re not a tennis fan. Given his recent retirement, it\u2019s an interesting data set to explore.<\/p>\n<p>Let\u2019s add this data (collated from <a href=\"https:\/\/en.wikipedia.org\/wiki\/Roger_Federer\" target=\"_blank\" rel=\"nofollow\">Wikipedia<\/a>) as a simple array:<\/p>\n<pre><code class=\"javascript\">var data = anychart.data.set([\r\n  [\"Wimbledon\", 8],\r\n  [\"Australian Open\", 6],\r\n  [\"US Open\", 5],\r\n  [\"Roland Garros\", 1]\r\n]);<\/code><\/pre>\n<h3>4. Write the JavaScript code for our chart<\/h3>\n<p>Here\u2019s the exciting part: creating the donut chart visualization with just a few lines of JavaScript code.<\/p>\n<p>First, add the <code>anychart.onDocumentReady()<\/code> function that ensures the web page is ready before executing the code. The rest of the JS code is to be placed within this function, and let&#8217;s start with setting the data:<\/p>\n<pre><code class=\"javascript\">anychart.onDocumentReady(function () {\r\n  var data = anychart.data.set([\r\n    [\"Wimbledon\", 8],\r\n    [\"Australian Open\", 6],\r\n    [\"U.S. Open\", 5],\r\n    [\"French Open\", 1]\r\n  ]);\r\n});<\/code><\/pre>\n<p>Then, in the same function, create a pie chart and define an inner radius to give it that donut appearance.<\/p>\n<pre><code class=\"javascript\">var chart = anychart.pie(data)\r\n  .innerRadius('50%');<\/code><\/pre>\n<p>Let\u2019s also give the chart a title. Then set the container. And finally, draw the chart.<\/p>\n<pre><code class=\"javascript\">chart.title('Grand Slam Titles Won by Roger Federer');\r\nchart.container('container');\r\nchart.draw();<\/code><\/pre>\n<p>Aha! Look at that lovely, functional, JavaScript-based donut chart we\u2019ve created! Let\u2019s be honest here \u2014 it was as smooth as Roger Federer\u2019s backhand! You can check out the interactive version with the entire code on the <a href=\"https:\/\/playground.anychart.com\/sLOWpq2o\" target=\"_blank\" rel=\"nofollow\">playground<\/a> and even click on the slices to see the cool slicing animation. Don\u2019t forget to explore the automatically generated legend by clicking on it too!<\/p>\n<p><iframe loading=\"lazy\" class=\"anychart-embed anychart-embed-sLOWpq2o\" src=\"https:\/\/playground.anychart.com\/sLOWpq2o\/iframe\" width=\"300\" height=\"150\" frameborder=\"0\" sandbox=\"allow-scripts allow-pointer-lock allow-same-origin allow-popups allow-modals allow-forms\" allowfullscreen=\"allowfullscreen\"><br \/>\n<\/iframe><br \/>\n<script type=\"text\/javascript\">(function(){\nfunction ac_add_to_head(el){\n\tvar head = document.getElementsByTagName('head')[0];\n\thead.insertBefore(el,head.firstChild);\n}\nfunction ac_add_style(css){\n\tvar ac_style = document.createElement('style');\n\tif (ac_style.styleSheet) ac_style.styleSheet.cssText = css;\n\telse ac_style.appendChild(document.createTextNode(css));\n\tac_add_to_head(ac_style);\n}\nac_add_style(\".anychart-embed-sLOWpq2o{width:100%;height:600px;}\");\n})();<\/script><\/p>\n<pre><code class=\"html\">&lt;html&gt;\r\n  &lt;head&gt;\r\n    &lt;title&gt;JavaScript Donut Chart&lt;\/title&gt;\r\n    &lt;script src=\"https:\/\/cdn.anychart.com\/releases\/8.11.1\/js\/anychart-core.min.js\"&gt;&lt;\/script&gt;\r\n    &lt;script src=\"https:\/\/cdn.anychart.com\/releases\/8.11.1\/js\/anychart-pie.min.js\"&gt;&lt;\/script&gt;\r\n    &lt;style type=\"text\/css\"&gt;      \r\n      html, body, #container { \r\n        width: 100%; height: 100%; margin: 0; padding: 0; \r\n      } \r\n    &lt;\/style&gt;\r\n  &lt;\/head&gt;\r\n  &lt;body&gt;  \r\n    &lt;div id=\"container\"&gt;&lt;\/div&gt;\r\n    &lt;script&gt;\r\n      anychart.onDocumentReady(function () {  \r\n        \/\/ add the data\r\n        var data = anychart.data.set([\r\n          [\"Wimbledon\", 8],\r\n          [\"Australian Open\", 6],\r\n          [\"U.S. Open\", 5],\r\n          [\"French Open\", 1]\r\n        ]);\r\n        \/\/ create a pie chart instance with the passed data\r\n        var chart = anychart\r\n          .pie(data)\r\n          \/\/ set the inner radius to make a donut chart\r\n          .innerRadius(\"55%\");\r\n        \/\/ set the chart title\r\n        chart.title(\"Grand Slam Titles Won by Roger Federer\");\r\n        \/\/ set the container id for the chart\r\n        chart.container(\"container\");\r\n        \/\/ draw the resulting chart\r\n        chart.draw();\r\n      });\r\n    &lt;\/script&gt;\r\n  &lt;\/body&gt;\r\n&lt;\/html&gt;<\/code><\/pre>\n<p>Now that we have our donut chart, let\u2019s take it up a notch and make it even cooler and more eye-catching. Here\u2019s how you can customize the chart.<\/p>\n<h2>Customizing a Donut Chart<\/h2>\n<p>When working with JavaScript charting libraries, you can create charts quickly and have the flexibility to customize them to your liking. In the case of a donut chart, numerous options are available to enhance its aesthetic appeal and information presentation. The following section will explore various customization choices to make your JS donut chart more visually pleasing and informative.<\/p>\n<h3>Changing the color palette<\/h3>\n<p>To add visual coherence, let\u2019s color the slices based on the prominent colors in the respective Grand Slam logos. This can be achieved by defining the required colors and setting the chart\u2019s color palette.<\/p>\n<pre><code class=\"javascript\">\/\/ create a color palette\r\nvar palette = anychart.palettes.distinctColors();\r\n  \r\n\/\/ add the colors according to the brands\r\npalette.items([\r\n  { color: \"#563783\" },\r\n  { color: \"#1b8cca\" },\r\n  { color: \"#022789\" },\r\n  { color: \"#d35220\" }\r\n]);\r\n\r\n\/\/ create a pie chart instance with the passed data\r\nvar chart = anychart\r\n  .pie(data)\r\n  \/\/ set the inner radius to make a donut chart\r\n  .innerRadius(\"50%\")\r\n  \/\/ set the color palette\r\n  .palette(palette);<\/code><\/pre>\n<p><iframe loading=\"lazy\" class=\"anychart-embed anychart-embed-d6WmVlRu\" src=\"https:\/\/playground.anychart.com\/d6WmVlRu\/iframe\" width=\"300\" height=\"150\" frameborder=\"0\" sandbox=\"allow-scripts allow-pointer-lock allow-same-origin allow-popups allow-modals allow-forms\" allowfullscreen=\"allowfullscreen\"><br \/>\n<\/iframe><br \/>\n<script type=\"text\/javascript\">(function(){\nfunction ac_add_to_head(el){\n\tvar head = document.getElementsByTagName('head')[0];\n\thead.insertBefore(el,head.firstChild);\n}\nfunction ac_add_style(css){\n\tvar ac_style = document.createElement('style');\n\tif (ac_style.styleSheet) ac_style.styleSheet.cssText = css;\n\telse ac_style.appendChild(document.createTextNode(css));\n\tac_add_to_head(ac_style);\n}\nac_add_style(\".anychart-embed-d6WmVlRu{width:100%;height:600px;}\");\n})();<\/script><\/p>\n<h3>Setting the labels<\/h3>\n<p>Since this donut chart has only four categories, we can add the name of each Grand Slam directly on the corresponding slice. We can also disable the automatic legend, as it may not be necessary in such a situation.<\/p>\n<pre><code class=\"javascript\">chart.labels().format(\"{%x}: {%y}\").fontSize(14);\r\nchart.legend(false);<\/code><\/pre>\n<p><iframe loading=\"lazy\" class=\"anychart-embed anychart-embed-KWYeuPc1\" src=\"https:\/\/playground.anychart.com\/KWYeuPc1\/iframe\" width=\"300\" height=\"150\" frameborder=\"0\" sandbox=\"allow-scripts allow-pointer-lock allow-same-origin allow-popups allow-modals allow-forms\" allowfullscreen=\"allowfullscreen\"><br \/>\n<\/iframe><br \/>\n<script type=\"text\/javascript\">(function(){\nfunction ac_add_to_head(el){\n\tvar head = document.getElementsByTagName('head')[0];\n\thead.insertBefore(el,head.firstChild);\n}\nfunction ac_add_style(css){\n\tvar ac_style = document.createElement('style');\n\tif (ac_style.styleSheet) ac_style.styleSheet.cssText = css;\n\telse ac_style.appendChild(document.createTextNode(css));\n\tac_add_to_head(ac_style);\n}\nac_add_style(\".anychart-embed-KWYeuPc1{width:100%;height:600px;}\");\n})();<\/script><\/p>\n<h3>Changing the click aesthetics<\/h3>\n<p>As an additional customization feature, let\u2019s modify the appearance of the clicked slice. Instead of the default behavior, we\u2019ll make all slices look the same when clicked.<\/p>\n<pre><code class=\"javascript\">\/\/ set the fill when selected\r\nchart.selected().fill(\"#007247\");\r\n  \r\n\/\/ customize the outline when selected\r\nchart\r\n  .selected()\r\n  .outline()\r\n  .fill(function () {\r\n    return anychart.color.lighten(\"#007247\", 0.55);\r\n  });<\/code><\/pre>\n<p>These small yet impactful changes make the donut chart look so much more personalized.<\/p>\n<p><iframe loading=\"lazy\" class=\"anychart-embed anychart-embed-2hPJ15zl\" src=\"https:\/\/playground.anychart.com\/2hPJ15zl\/iframe\" width=\"300\" height=\"150\" frameborder=\"0\" sandbox=\"allow-scripts allow-pointer-lock allow-same-origin allow-popups allow-modals allow-forms\" allowfullscreen=\"allowfullscreen\"><br \/>\n<\/iframe><br \/>\n<script type=\"text\/javascript\">(function(){\nfunction ac_add_to_head(el){\n\tvar head = document.getElementsByTagName('head')[0];\n\thead.insertBefore(el,head.firstChild);\n}\nfunction ac_add_style(css){\n\tvar ac_style = document.createElement('style');\n\tif (ac_style.styleSheet) ac_style.styleSheet.cssText = css;\n\telse ac_style.appendChild(document.createTextNode(css));\n\tac_add_to_head(ac_style);\n}\nac_add_style(\".anychart-embed-2hPJ15zl{width:100%;height:600px;}\");\n})();<\/script><\/p>\n<h3>Adding the center content<\/h3>\n<p>To maximize insights, it\u2019s possible to utilize the central part of the donut chart, which is typically empty. You can add extra information by placing a standalone label in the center. Let\u2019s use HTML to style the text, set the height and width to 100%, and position it at the center of the donut.<\/p>\n<pre><code class=\"javascript\">\/\/ create a standalone label\r\nvar label = anychart.standalones.label();\r\n\r\nlabel\r\n  .useHtml(true)\r\n  .text(\r\n    '&lt;span style = \"color: #313136; font-size:18px;\"&gt;Total titles: 20&lt;\/span&gt;' +\r\n      '&lt;br&gt;&lt;br&gt;&lt;span style = \"color: #313136; font-size:18px;\"&gt;Total finals: 41&lt;\/span&gt;'\r\n  )\r\n  .position(\"center\")\r\n  .anchor(\"center\")\r\n  .hAlign(\"center\")\r\n  .vAlign(\"middle\");\r\n\r\nlabel.width(\"100%\");\r\nlabel.height(\"100%\");\r\n\r\n\/\/ set the label as the center content\r\nchart.center().content(label);<\/code><\/pre>\n<p><iframe loading=\"lazy\" class=\"anychart-embed anychart-embed-kDimz3v1\" src=\"https:\/\/playground.anychart.com\/kDimz3v1\/iframe\" width=\"300\" height=\"150\" frameborder=\"0\" sandbox=\"allow-scripts allow-pointer-lock allow-same-origin allow-popups allow-modals allow-forms\" allowfullscreen=\"allowfullscreen\"><br \/>\n<\/iframe><br \/>\n<script type=\"text\/javascript\">(function(){\nfunction ac_add_to_head(el){\n\tvar head = document.getElementsByTagName('head')[0];\n\thead.insertBefore(el,head.firstChild);\n}\nfunction ac_add_style(css){\n\tvar ac_style = document.createElement('style');\n\tif (ac_style.styleSheet) ac_style.styleSheet.cssText = css;\n\telse ac_style.appendChild(document.createTextNode(css));\n\tac_add_to_head(ac_style);\n}\nac_add_style(\".anychart-embed-kDimz3v1{width:100%;height:600px;}\");\n})();<\/script><\/p>\n<h3>Improving the tooltip and the title<\/h3>\n<p>As the final steps, we\u2019ll enhance the donut chart tooltip by including the percentage value alongside the name of the Grand Slam on the label.<\/p>\n<pre><code class=\"javascript\">chart.tooltip().format(\"Percent of total wins: {%PercentValue}%\");<\/code><\/pre>\n<p>And we\u2019ll improve the chart\u2019s title and add a subtitle by enabling HTML formatting.<\/p>\n<pre><code class=\"javascript\">chart\r\n  .title()\r\n  .enabled(true)\r\n  .useHtml(true)\r\n  .text(\r\n    '&lt;span style = \"color: #111; font-size:20px; margin-bottom:10px; dy:20px\"&gt;Grand Slam Titles Won by Roger Federer&lt;\/span&gt;' +\r\n      '&lt;br\/&gt;&lt;span style=\"color:#007247; font-size: 15px;\"&gt;The French Open (Roland-Garros) is apparently his least favorite major&lt;\/span&gt;'\r\n  );<\/code><\/pre>\n<p>Voila! We\u2019ve created a totally trendy JS donut chart! You can find the final code for this data visualization example below and play with it on the <a href=\"https:\/\/playground.anychart.com\/ApkP0sjX\" target=\"_blank\" rel=\"nofollow\">playground<\/a>.<\/p>\n<p><iframe loading=\"lazy\" class=\"anychart-embed anychart-embed-ApkP0sjX\" src=\"https:\/\/playground.anychart.com\/ApkP0sjX\/iframe\" width=\"300\" height=\"150\" frameborder=\"0\" sandbox=\"allow-scripts allow-pointer-lock allow-same-origin allow-popups allow-modals allow-forms\" allowfullscreen=\"allowfullscreen\"><br \/>\n<\/iframe><br \/>\n<script type=\"text\/javascript\">(function(){\nfunction ac_add_to_head(el){\n\tvar head = document.getElementsByTagName('head')[0];\n\thead.insertBefore(el,head.firstChild);\n}\nfunction ac_add_style(css){\n\tvar ac_style = document.createElement('style');\n\tif (ac_style.styleSheet) ac_style.styleSheet.cssText = css;\n\telse ac_style.appendChild(document.createTextNode(css));\n\tac_add_to_head(ac_style);\n}\nac_add_style(\".anychart-embed-ApkP0sjX{width:100%;height:600px;}\");\n})();<\/script><\/p>\n<pre><code class=\"html\">&lt;html&gt;\r\n  &lt;head&gt;\r\n    &lt;title&gt;JavaScript Donut Chart&lt;\/title&gt;\r\n    &lt;script src=\"https:\/\/cdn.anychart.com\/releases\/8.11.1\/js\/anychart-core.min.js\"&gt;&lt;\/script&gt;\r\n    &lt;script src=\"https:\/\/cdn.anychart.com\/releases\/8.11.1\/js\/anychart-pie.min.js\"&gt;&lt;\/script&gt;\r\n    &lt;style type=\"text\/css\"&gt;      \r\n      html, body, #container { \r\n        width: 100%; height: 100%; margin: 0; padding: 0; \r\n      } \r\n    &lt;\/style&gt;\r\n  &lt;\/head&gt;\r\n  &lt;body&gt;  \r\n    &lt;div id=\"container\"&gt;&lt;\/div&gt;\r\n    &lt;script&gt;\r\n      anychart.onDocumentReady(function () {\r\n        \/\/ add the data\r\n        var data = anychart.data.set([\r\n          [\"Wimbledon\", 8],\r\n          [\"Australian Open\", 6],\r\n          [\"U.S. Open\", 5],\r\n          [\"French Open\", 1]\r\n        ]);\r\n        \/\/ create a color palette\r\n        var palette = anychart.palettes.distinctColors();\r\n        \/\/ add the colors according to the brands\r\n        palette.items([\r\n          { color: \"#563783\" },\r\n          { color: \"#1b8cca\" },\r\n          { color: \"#022789\" },\r\n          { color: \"#d35220\" }\r\n        ]);\r\n        \/\/ create a pie chart instance with the passed data\r\n        var chart = anychart\r\n          .pie(data)\r\n          \/\/ set the inner radius to make a donut chart\r\n          .innerRadius(\"50%\")\r\n          \/\/ set the color palette\r\n          .palette(palette);\r\n        \/\/ set the position of the labels\r\n        chart.labels().format(\"{%x}: {%y}\").fontSize(14);\r\n        \/\/ disable the legend\r\n        chart.legend(false);\r\n        \/\/ set the fill when selected\r\n        chart.selected().fill(\"#007247\");\r\n        \/\/ customize the outline when selected\r\n        chart\r\n          .selected()\r\n          .outline()\r\n          .fill(function () {\r\n            return anychart.color.lighten(\"#007247\", 0.55);\r\n          });\r\n       \/\/ create a standalone label\r\n        var label = anychart.standalones.label();\r\n        label\r\n          .useHtml(true)\r\n          .text(\r\n            '&lt;span style = \"color: #313136; font-size:18px;\"&gt;Total titles: 20&lt;\/span&gt;' +\r\n              '&lt;br&gt;&lt;br&gt;&lt;span style = \"color: #313136; font-size:18px;\"&gt;Total finals: 41&lt;\/span&gt;'\r\n          )\r\n          .position(\"center\")\r\n          .anchor(\"center\")\r\n          .hAlign(\"center\")\r\n          .vAlign(\"middle\");\r\n        label.width(\"100%\");\r\n        label.height(\"100%\");\r\n        \/\/ set the label as the center content\r\n        chart.center().content(label);\r\n        \/\/ format the tooltip\r\n        chart.tooltip().format(\"Percent of total wins: {%PercentValue}%\");\r\n        \/\/ set the chart title\r\n        chart\r\n          .title()\r\n          .enabled(true)\r\n          .useHtml(true)\r\n          .text(\r\n            '&lt;span style = \"color: #111; font-size:20px; margin-bottom:10px; dy:20px\"&gt;Grand Slam Titles Won by Roger Federer&lt;\/span&gt;' +\r\n              '&lt;br\/&gt;&lt;span style=\"color:#007247; font-size: 15px;\"&gt;The French Open (Roland-Garros) is apparently his least favorite major&lt;\/span&gt;'\r\n          );\r\n        \/\/ set the container id for the chart\r\n        chart.container(\"container\");\r\n        \/\/ draw the resulting chart\r\n        chart.draw();\r\n      });\r\n    &lt;\/script&gt;\r\n  &lt;\/body&gt;\r\n&lt;\/html&gt;<\/code><\/pre>\n<h2>Conclusion<\/h2>\n<p>As you can see, creating and customizing a JS donut chart is pretty straightforward. Donut charts are simple yet widely used, making them a great option to learn at the beginning of your data visualization journey. If you have any questions or doubts, please let me know. Remember, creating interactive JS charts is not as tough as achieving Roger Federer\u2019s feat, so go ahead and create some exciting donut and other charts without any excuses!<\/p>\n<hr \/>\n<p><strong><em>Published with the permission of Shachee Swadia. Originally appeared on <a href=\"https:\/\/levelup.gitconnected.com\/creating-a-donut-chart-with-javascript-ea50c22596c4\" target=\"_blank\" rel=\"nofollow\">Level Up Coding<\/a> with the title &#8220;Creating a Donut Chart with JavaScript&#8221; on June 11, 2023.<\/p>\n<p>You may also like to see the <a href=\"https:\/\/www.anychart.com\/blog\/2021\/07\/06\/donut-charts-javascript\/\">JavaScript Donut Chart Tutorial<\/a> originally published here earlier.<\/p>\n<p>Check out more <a href=\"https:\/\/www.anychart.com\/blog\/category\/javascript-chart-tutorials\/\">JavaScript charting tutorials<\/a> on our blog.<\/p>\n<p>Would you like to create some amazing guest post for us? <a href=\"https:\/\/www.anychart.com\/support\/\">Let&#8217;s discuss your idea!<\/a><\/strong><\/p>\n<hr \/>\n<p><!-- SyntaxHighlighter --><link rel=\"stylesheet\" href=\"\/\/cdnjs.cloudflare.com\/ajax\/libs\/highlight.js\/9.12.0\/styles\/default.min.css\"><link rel=\"stylesheet\" href=\"\/\/cdnjs.cloudflare.com\/ajax\/libs\/highlight.js\/9.12.0\/styles\/atom-one-light.min.css\"><script src=\"\/\/cdnjs.cloudflare.com\/ajax\/libs\/highlight.js\/9.12.0\/highlight.min.js\"><\/script><script>hljs.initHighlightingOnLoad();<\/script><\/p>\n<!-- AddThis Advanced Settings generic via filter on the_content --><!-- AddThis Share Buttons generic via filter on the_content -->","protected":false},"excerpt":{"rendered":"<p>Visualizing data isn\u2019t just insightful, it\u2019s also a lot of fun! One of the simplest and most enjoyable charts you can create is the donut chart. And now, I will show you how to make an awesome interactive one using JavaScript effortlessly! Aptly named because it looks like a donut, a donut chart is essentially [&hellip;]<!-- AddThis Advanced Settings generic via filter on get_the_excerpt --><!-- AddThis Share Buttons generic via filter on get_the_excerpt --><\/p>\n","protected":false},"author":20,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,23,13,279,4],"tags":[843,619,618,53,3173,3563,260,1758,3149,284,160,471,266,620,1292,806,193,1759,3352,509,2220,2838,1389,1760,2757,256,3377,1111,844,165,313,1370,133,774,3369,177,1155,103,1498,3564,805,3558,1762,2013,2014,32,55,77,61,1335,144,2979,2016,167,146,433,79,152,80,36,907,141,249,81,57,76,1238,142,96,99,2904,60,58,65,56,101,3526,3556,3424,64,84,3559,3561,609,3099,3557,172,3562,807,808,954,610,3100,3565,3494,2015,2816,1763,804,3407,996,1181,1182,3560],"class_list":["post-16671","post","type-post","status-publish","format-standard","hentry","category-anychart-charting-component","category-html5","category-javascript","category-javascript-chart-tutorials","category-tips-and-tricks","tag-advanced-data-visualization","tag-analysis","tag-analytics","tag-anychart","tag-app-development","tag-australian-open","tag-best-data-visualization-examples","tag-chart-design","tag-chart-development","tag-chart-examples","tag-dashboard-design","tag-data-analysis","tag-data-analytics","tag-data-analytics-examples","tag-data-chart","tag-data-charts","tag-data-composition","tag-data-design","tag-data-graphic","tag-data-graphics","tag-data-visual","tag-data-visualisation","tag-data-visualization-best-pracices","tag-data-visualization-design","tag-data-visualization-development","tag-data-visualization-examples","tag-data-visualization-guide","tag-data-visualization-practice","tag-data-visualization-tutorial","tag-data-visualizations","tag-data-visuals","tag-data-viz-examples","tag-dataviz","tag-dataviz-examples","tag-developers","tag-donut-chart","tag-donut-chart-example","tag-donut-charts","tag-example","tag-french-open","tag-front-end-development","tag-grand-slam","tag-guest-post","tag-html","tag-html-charts","tag-html5","tag-html5-charts","tag-html5-dashboards","tag-html5-pie","tag-infographic","tag-infographics","tag-information-graphics","tag-information-visualization","tag-interactive-charts","tag-interactive-data-visualization","tag-interactive-graphics","tag-interactive-html5-dashboard","tag-interactive-infographic","tag-interactive-javascript-dashboard","tag-javascript","tag-javascript-chart-tutorial","tag-javascript-charting","tag-javascript-charting-api","tag-javascript-charting-library","tag-javascript-charts","tag-javascript-dashboards","tag-javascript-graph","tag-javascript-graphics","tag-javascript-graphics-library","tag-javascript-library","tag-javascript-map-tutorial","tag-javascript-pie-chart","tag-js-chart","tag-js-charting","tag-js-charts","tag-js-graphics","tag-js-library","tag-level-up-coding","tag-part-to-whole-relationships","tag-pie-chart","tag-pie-charts","tag-roger-federer","tag-roland-garros","tag-storytelling","tag-storytelling-examples","tag-tennis","tag-tutorial","tag-us-open","tag-visual-analysis","tag-visual-analytics","tag-visual-data-analytics","tag-visual-storytelling","tag-visual-storytelling-examples","tag-wanderu","tag-web-chart","tag-web-charts","tag-web-design","tag-web-developers","tag-web-development","tag-website-development","tag-wikipedia","tag-wikipedia-data","tag-wikipedia-data-visualization","tag-wimbledon","wpautop"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.1.1 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>How to Create a Donut Chart in JavaScript - Tutorial<\/title>\n<meta name=\"description\" content=\"Learn how to easily create an interactive donut chart using JavaScript, visualizing Roger Federer&#039;s Grand Slam title tally step by step. See the tutorial!\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.anychart.com\/blog\/2023\/06\/13\/donut-chart-js\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Create a Donut Chart in JavaScript\" \/>\n<meta property=\"og:description\" content=\"Learn how to easily create an interactive JS donut chart, visualizing Roger Federer&#039;s Grand Slam title tally step by step. See the tutorial!\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.anychart.com\/blog\/2023\/06\/13\/donut-chart-js\/\" \/>\n<meta property=\"og:site_name\" content=\"AnyChart News\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/AnyCharts\" \/>\n<meta property=\"article:published_time\" content=\"2023-06-13T08:29:27+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-06-14T08:12:40+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2023\/06\/donut-chart.png\" \/>\n<meta name=\"author\" content=\"Shachee Swadia\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:title\" content=\"How to Create a Donut Chart in JavaScript\" \/>\n<meta name=\"twitter:description\" content=\"Learn how to easily create an interactive JS donut chart, visualizing Roger Federer&#039;s Grand Slam title tally step by step. See the tutorial!\" \/>\n<meta name=\"twitter:image\" content=\"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2023\/06\/donut-chart.png\" \/>\n<meta name=\"twitter:creator\" content=\"@AnyChart\" \/>\n<meta name=\"twitter:site\" content=\"@AnyChart\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Shachee Swadia\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"10 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.anychart.com\/blog\/2023\/06\/13\/donut-chart-js\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.anychart.com\/blog\/2023\/06\/13\/donut-chart-js\/\"},\"author\":{\"name\":\"Shachee Swadia\",\"@id\":\"https:\/\/www.anychart.com\/blog\/#\/schema\/person\/273255f98371177b5ac1f4775610bb51\"},\"headline\":\"How to Create Donut Chart Using JavaScript\",\"datePublished\":\"2023-06-13T08:29:27+00:00\",\"dateModified\":\"2023-06-14T08:12:40+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.anychart.com\/blog\/2023\/06\/13\/donut-chart-js\/\"},\"wordCount\":1125,\"commentCount\":0,\"image\":{\"@id\":\"https:\/\/www.anychart.com\/blog\/2023\/06\/13\/donut-chart-js\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2023\/06\/donut-chart.png\",\"keywords\":[\"advanced data visualization\",\"analysis\",\"analytics\",\"AnyChart\",\"app development\",\"Australian Open\",\"best data visualization examples\",\"chart design\",\"chart development\",\"chart examples\",\"dashboard design\",\"data analysis\",\"data analytics\",\"data analytics examples\",\"data chart\",\"data charts\",\"data composition\",\"data design\",\"data graphic\",\"data graphics\",\"data visual\",\"data visualisation\",\"data visualization best practices\",\"data visualization design\",\"data visualization development\",\"data visualization examples\",\"data visualization guide\",\"data visualization practice\",\"data visualization tutorial\",\"data visualizations\",\"data visuals\",\"data viz examples\",\"dataviz\",\"dataviz examples\",\"developers\",\"donut chart\",\"donut chart example\",\"donut charts\",\"example\",\"French Open\",\"front-end development\",\"Grand Slam\",\"guest post\",\"HTML\",\"HTML charts\",\"HTML5\",\"html5 charts\",\"html5 dashboards\",\"html5 pie\",\"infographic\",\"infographics\",\"information graphics\",\"information visualization\",\"interactive charts\",\"interactive data visualization\",\"interactive graphics\",\"interactive html5 dashboard\",\"interactive infographic\",\"interactive javascript dashboard\",\"JavaScript\",\"javascript chart tutorial\",\"javascript charting\",\"javascript charting api\",\"JavaScript charting library\",\"javascript charts\",\"javascript dashboards\",\"javascript graph\",\"javascript graphics\",\"JavaScript graphics library\",\"JavaScript library\",\"javascript map tutorial\",\"javascript pie chart\",\"js chart\",\"js charting\",\"js charts\",\"JS graphics\",\"js library\",\"Level Up Coding\",\"part-to-whole relationships\",\"pie chart\",\"pie charts\",\"Roger Federer\",\"Roland-Garros\",\"storytelling\",\"storytelling examples\",\"tennis\",\"tutorial\",\"US Open\",\"visual analysis\",\"visual analytics\",\"visual data analytics\",\"visual storytelling\",\"visual storytelling examples\",\"Wanderu\",\"web chart\",\"web charts\",\"web design\",\"web developers\",\"web development\",\"website development\",\"wikipedia\",\"Wikipedia data\",\"Wikipedia data visualization\",\"Wimbledon\"],\"articleSection\":[\"AnyChart Charting Component\",\"HTML5\",\"JavaScript\",\"JavaScript Chart Tutorials\",\"Tips and Tricks\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.anychart.com\/blog\/2023\/06\/13\/donut-chart-js\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.anychart.com\/blog\/2023\/06\/13\/donut-chart-js\/\",\"url\":\"https:\/\/www.anychart.com\/blog\/2023\/06\/13\/donut-chart-js\/\",\"name\":\"How to Create a Donut Chart in JavaScript - Tutorial\",\"isPartOf\":{\"@id\":\"https:\/\/www.anychart.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.anychart.com\/blog\/2023\/06\/13\/donut-chart-js\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.anychart.com\/blog\/2023\/06\/13\/donut-chart-js\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2023\/06\/donut-chart.png\",\"datePublished\":\"2023-06-13T08:29:27+00:00\",\"dateModified\":\"2023-06-14T08:12:40+00:00\",\"author\":{\"@id\":\"https:\/\/www.anychart.com\/blog\/#\/schema\/person\/273255f98371177b5ac1f4775610bb51\"},\"description\":\"Learn how to easily create an interactive donut chart using JavaScript, visualizing Roger Federer's Grand Slam title tally step by step. See the tutorial!\",\"breadcrumb\":{\"@id\":\"https:\/\/www.anychart.com\/blog\/2023\/06\/13\/donut-chart-js\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.anychart.com\/blog\/2023\/06\/13\/donut-chart-js\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.anychart.com\/blog\/2023\/06\/13\/donut-chart-js\/#primaryimage\",\"url\":\"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2023\/06\/donut-chart.png\",\"contentUrl\":\"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2023\/06\/donut-chart.png\",\"width\":1800,\"height\":915},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.anychart.com\/blog\/2023\/06\/13\/donut-chart-js\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.anychart.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Create Donut Chart Using JavaScript\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.anychart.com\/blog\/#website\",\"url\":\"https:\/\/www.anychart.com\/blog\/\",\"name\":\"AnyChart News\",\"description\":\"AnyChart JS Charts\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.anychart.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.anychart.com\/blog\/#\/schema\/person\/273255f98371177b5ac1f4775610bb51\",\"name\":\"Shachee Swadia\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.anychart.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/50ebd5c61e4e46e052898a5ddbcef5996666132cf07c614be4725f028ec7eae3?s=96&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/50ebd5c61e4e46e052898a5ddbcef5996666132cf07c614be4725f028ec7eae3?s=96&r=g\",\"caption\":\"Shachee Swadia\"},\"url\":\"https:\/\/www.anychart.com\/blog\/author\/shachee-swadia\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Create a Donut Chart in JavaScript - Tutorial","description":"Learn how to easily create an interactive donut chart using JavaScript, visualizing Roger Federer's Grand Slam title tally step by step. See the tutorial!","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.anychart.com\/blog\/2023\/06\/13\/donut-chart-js\/","og_locale":"en_US","og_type":"article","og_title":"How to Create a Donut Chart in JavaScript","og_description":"Learn how to easily create an interactive JS donut chart, visualizing Roger Federer's Grand Slam title tally step by step. See the tutorial!","og_url":"https:\/\/www.anychart.com\/blog\/2023\/06\/13\/donut-chart-js\/","og_site_name":"AnyChart News","article_publisher":"https:\/\/www.facebook.com\/AnyCharts","article_published_time":"2023-06-13T08:29:27+00:00","article_modified_time":"2023-06-14T08:12:40+00:00","og_image":[{"url":"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2023\/06\/donut-chart.png","type":"","width":"","height":""}],"author":"Shachee Swadia","twitter_card":"summary_large_image","twitter_title":"How to Create a Donut Chart in JavaScript","twitter_description":"Learn how to easily create an interactive JS donut chart, visualizing Roger Federer's Grand Slam title tally step by step. See the tutorial!","twitter_image":"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2023\/06\/donut-chart.png","twitter_creator":"@AnyChart","twitter_site":"@AnyChart","twitter_misc":{"Written by":"Shachee Swadia","Est. reading time":"10 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.anychart.com\/blog\/2023\/06\/13\/donut-chart-js\/#article","isPartOf":{"@id":"https:\/\/www.anychart.com\/blog\/2023\/06\/13\/donut-chart-js\/"},"author":{"name":"Shachee Swadia","@id":"https:\/\/www.anychart.com\/blog\/#\/schema\/person\/273255f98371177b5ac1f4775610bb51"},"headline":"How to Create Donut Chart Using JavaScript","datePublished":"2023-06-13T08:29:27+00:00","dateModified":"2023-06-14T08:12:40+00:00","mainEntityOfPage":{"@id":"https:\/\/www.anychart.com\/blog\/2023\/06\/13\/donut-chart-js\/"},"wordCount":1125,"commentCount":0,"image":{"@id":"https:\/\/www.anychart.com\/blog\/2023\/06\/13\/donut-chart-js\/#primaryimage"},"thumbnailUrl":"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2023\/06\/donut-chart.png","keywords":["advanced data visualization","analysis","analytics","AnyChart","app development","Australian Open","best data visualization examples","chart design","chart development","chart examples","dashboard design","data analysis","data analytics","data analytics examples","data chart","data charts","data composition","data design","data graphic","data graphics","data visual","data visualisation","data visualization best practices","data visualization design","data visualization development","data visualization examples","data visualization guide","data visualization practice","data visualization tutorial","data visualizations","data visuals","data viz examples","dataviz","dataviz examples","developers","donut chart","donut chart example","donut charts","example","French Open","front-end development","Grand Slam","guest post","HTML","HTML charts","HTML5","html5 charts","html5 dashboards","html5 pie","infographic","infographics","information graphics","information visualization","interactive charts","interactive data visualization","interactive graphics","interactive html5 dashboard","interactive infographic","interactive javascript dashboard","JavaScript","javascript chart tutorial","javascript charting","javascript charting api","JavaScript charting library","javascript charts","javascript dashboards","javascript graph","javascript graphics","JavaScript graphics library","JavaScript library","javascript map tutorial","javascript pie chart","js chart","js charting","js charts","JS graphics","js library","Level Up Coding","part-to-whole relationships","pie chart","pie charts","Roger Federer","Roland-Garros","storytelling","storytelling examples","tennis","tutorial","US Open","visual analysis","visual analytics","visual data analytics","visual storytelling","visual storytelling examples","Wanderu","web chart","web charts","web design","web developers","web development","website development","wikipedia","Wikipedia data","Wikipedia data visualization","Wimbledon"],"articleSection":["AnyChart Charting Component","HTML5","JavaScript","JavaScript Chart Tutorials","Tips and Tricks"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.anychart.com\/blog\/2023\/06\/13\/donut-chart-js\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.anychart.com\/blog\/2023\/06\/13\/donut-chart-js\/","url":"https:\/\/www.anychart.com\/blog\/2023\/06\/13\/donut-chart-js\/","name":"How to Create a Donut Chart in JavaScript - Tutorial","isPartOf":{"@id":"https:\/\/www.anychart.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.anychart.com\/blog\/2023\/06\/13\/donut-chart-js\/#primaryimage"},"image":{"@id":"https:\/\/www.anychart.com\/blog\/2023\/06\/13\/donut-chart-js\/#primaryimage"},"thumbnailUrl":"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2023\/06\/donut-chart.png","datePublished":"2023-06-13T08:29:27+00:00","dateModified":"2023-06-14T08:12:40+00:00","author":{"@id":"https:\/\/www.anychart.com\/blog\/#\/schema\/person\/273255f98371177b5ac1f4775610bb51"},"description":"Learn how to easily create an interactive donut chart using JavaScript, visualizing Roger Federer's Grand Slam title tally step by step. See the tutorial!","breadcrumb":{"@id":"https:\/\/www.anychart.com\/blog\/2023\/06\/13\/donut-chart-js\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.anychart.com\/blog\/2023\/06\/13\/donut-chart-js\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.anychart.com\/blog\/2023\/06\/13\/donut-chart-js\/#primaryimage","url":"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2023\/06\/donut-chart.png","contentUrl":"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2023\/06\/donut-chart.png","width":1800,"height":915},{"@type":"BreadcrumbList","@id":"https:\/\/www.anychart.com\/blog\/2023\/06\/13\/donut-chart-js\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.anychart.com\/blog\/"},{"@type":"ListItem","position":2,"name":"How to Create Donut Chart Using JavaScript"}]},{"@type":"WebSite","@id":"https:\/\/www.anychart.com\/blog\/#website","url":"https:\/\/www.anychart.com\/blog\/","name":"AnyChart News","description":"AnyChart JS Charts","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.anychart.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.anychart.com\/blog\/#\/schema\/person\/273255f98371177b5ac1f4775610bb51","name":"Shachee Swadia","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.anychart.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/50ebd5c61e4e46e052898a5ddbcef5996666132cf07c614be4725f028ec7eae3?s=96&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/50ebd5c61e4e46e052898a5ddbcef5996666132cf07c614be4725f028ec7eae3?s=96&r=g","caption":"Shachee Swadia"},"url":"https:\/\/www.anychart.com\/blog\/author\/shachee-swadia\/"}]}},"_links":{"self":[{"href":"https:\/\/www.anychart.com\/blog\/wp-json\/wp\/v2\/posts\/16671","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.anychart.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.anychart.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.anychart.com\/blog\/wp-json\/wp\/v2\/users\/20"}],"replies":[{"embeddable":true,"href":"https:\/\/www.anychart.com\/blog\/wp-json\/wp\/v2\/comments?post=16671"}],"version-history":[{"count":19,"href":"https:\/\/www.anychart.com\/blog\/wp-json\/wp\/v2\/posts\/16671\/revisions"}],"predecessor-version":[{"id":16692,"href":"https:\/\/www.anychart.com\/blog\/wp-json\/wp\/v2\/posts\/16671\/revisions\/16692"}],"wp:attachment":[{"href":"https:\/\/www.anychart.com\/blog\/wp-json\/wp\/v2\/media?parent=16671"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.anychart.com\/blog\/wp-json\/wp\/v2\/categories?post=16671"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.anychart.com\/blog\/wp-json\/wp\/v2\/tags?post=16671"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}