{"id":5085,"date":"2017-12-06T07:47:55","date_gmt":"2017-12-06T07:47:55","guid":{"rendered":"https:\/\/www.anychart.com\/blog\/?p=5085"},"modified":"2022-08-13T10:56:39","modified_gmt":"2022-08-13T10:56:39","slug":"pie-chart-create-javascript","status":"publish","type":"post","link":"https:\/\/www.anychart.com\/blog\/2017\/12\/06\/pie-chart-create-javascript\/","title":{"rendered":"How to Create Pie Chart with JavaScript"},"content":{"rendered":"<p><img decoding=\"async\" class=\"alignnone size-full wp-image-5147\" src=\"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2017\/11\/creating-javascript-pie-chart-___-.jpg\" alt=\"Bulding an interactive JavaScript pie chart\" width=\"100%\" srcset=\"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2017\/11\/creating-javascript-pie-chart-___-.jpg 1100w, https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2017\/11\/creating-javascript-pie-chart-___--300x194.jpg 300w, https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2017\/11\/creating-javascript-pie-chart-___--768x496.jpg 768w, https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2017\/11\/creating-javascript-pie-chart-___--1024x661.jpg 1024w\" sizes=\"(max-width: 1100px) 100vw, 1100px\" \/>Have you ever wondered, how web developers create and integrate <strong>interactive JavaScript pie charts<\/strong> into HTML5 apps and web pages? If the answer is yes \u2013 keep on reading! This article explains how to create, change and integrate a <a href=\"https:\/\/www.anychart.com\/chartopedia\/chart-types\/pie-chart\/\">pie chart<\/a> into your web page. <strong>Beware!<\/strong>\u00a0A hot-button political issue is present in this article. But we <strong>will not<\/strong> offend anyone!<\/p>\n<p>Pie chart is one of the most popular chart types. Mathematically speaking it looks like a circle divided into sectors which represent a part of a whole. For the most of us, pie charts look like real pies or pizzas cut into several slices. In this article, you will find a detailed tutorial on how to build one, with JS chart code samples.<\/p>\n<p><!--more Read the JS charting tutorial \u00bb--><\/p>\n<h2>Creating JavaScript Pie Chart<\/h2>\n<p>There are four basic steps you should do to\u00a0make a chart of any type with a JavaScript charting library. Spend 5 minutes and you will\u00a0learn to add an interactive JS (HTML5) pie chart that looks like this to your web page:<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-5152\" src=\"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2017\/11\/js-pie-chart.gif\" alt=\"JavaScript pie chart being created along this JS chart tutorial\" width=\"100%\" \/><\/p>\n<h3>Step 1. Create an HTML page<\/h3>\n<p>The very first thing you need to do is to create a file in which you will put your chart later. Create a simple HTML page, set its title and create a container for the future chart:<\/p>\n<pre><code class=\"html\">&lt;!DOCTYPE html&gt;\r\n&lt;html&gt;\r\n  &lt;head&gt;\r\n    &lt;title&gt;JavaScript Pie Chart&lt;\/title&gt;\r\n  &lt;\/head&gt;\r\n  &lt;body&gt;\r\n    &lt;div id=\"container\" style=\"width: 100%; height: 100%\"&gt;&lt;\/div&gt;\r\n  &lt;\/body&gt;\r\n&lt;\/html&gt;\r\n<\/code><\/pre>\n<p>The <code>width<\/code> and <code>height<\/code> parameters of the container can be set in percents or in pixels. They are responsible for the chart\u2019s width and height. Setting them to &#8220;100%&#8221; will make the chart fill the whole page.<\/p>\n<h3>Step 2. Reference all necessary files<\/h3>\n<p>The second step is about adding links into the <code>&lt;head&gt;<\/code> section. It is necessary to load the JavaScript charting library and create a tag where the whole code of our future pie chart sample will be put in:<\/p>\n<pre><code class=\"html\">&lt;!DOCTYPE html&gt;\r\n&lt;html&gt;\r\n  &lt;head&gt;\r\n      &lt;title&gt;JavaScript Pie Chart&lt;\/title&gt;\r\n      &lt;script src=\"https:\/\/cdn.anychart.com\/releases\/8.0.1\/js\/anychart-core.min.js\"&gt;&lt;\/script&gt;\r\n      &lt;script src=\"https:\/\/cdn.anychart.com\/releases\/8.0.1\/js\/anychart-pie.min.js\"&gt;&lt;\/script&gt;\r\n  &lt;\/head&gt;\r\n  &lt;body&gt;\r\n    &lt;div id=\"container\" style=\"width: 100%; height: 100%\"&gt;&lt;\/div&gt;\r\n    &lt;script&gt;\r\n        &lt;!-- chart code will be here --&gt;\r\n    &lt;\/script&gt;\r\n  &lt;\/body&gt;\r\n&lt;\/html&gt;\r\n<\/code><\/pre>\n<h3>Step 3. Put the data together<\/h3>\n<p>The main purpose of creating a chart is to visualize data. So, it is clear that your data is the most important part of a chart and charting is only\u00a0a way to present data in a graphical, visual manner.<\/p>\n<p>If you choose\u00a0a wrong chart type to\u00a0visualize the data, you may mislead yourself or a chart viewer. So choose\u00a0the chart type wisely! If you don&#8217;t know what&#8217;s the difference between chart types, check out the <a href=\"https:\/\/www.anychart.com\/blog\/category\/choosing-chart-type\/\">Choosing Chart Type<\/a>\u00a0series of articles on our blog. You are also welcome to use this nifty tool,\u00a0<a href=\"https:\/\/www.anychart.com\/chartopedia\/\">Chartopedia;<\/a>\u00a0you&#8217;ll find <a href=\"https:\/\/www.anychart.com\/chartopedia\/chart-types\/pie-chart\/\">Pie Chart<\/a> there and see that\u00a0this chart type is good to show <a href=\"https:\/\/www.anychart.com\/chartopedia\/usage-type\/chart-to-show-part-of-the-whole\/\">Part Of The Whole<\/a>.<\/p>\n<p>Showing what some whole consists of is exactly what we are going to do now. We&#8217;ll see the composition of the <strong>whole<\/strong> American nation in terms of race. To\u00a0find out, let&#8217;s check out <a href=\"https:\/\/www.census.gov\/prod\/cen2010\/briefs\/c2010br-02.pdf\" target=\"_blank\" rel=\"nofollow\">U.S. Department of Commerce Economics and Statistics Overview of Race and Hispanic Origin: 2010<\/a> and take some data from there:<\/p>\n<table border=\"1\">\n<tbody>\n<tr>\n<td style=\"padding: 15px; text-align: center; font-size: 14pt;\" colspan=\"2\"><b>Population by Race for the United States: 2010 Census<\/b><\/td>\n<\/tr>\n<tr>\n<td style=\"padding: 6px 15px; text-align: center;\"><b>Race<\/b><\/td>\n<td style=\"padding: 6px 15px; text-align: center;\"><b>Number<\/b><\/td>\n<\/tr>\n<tr>\n<td style=\"padding: 6px 15px;\">White<\/td>\n<td style=\"padding: 6px 15px;\">223,553,265<\/td>\n<\/tr>\n<tr>\n<td style=\"padding: 6px 15px;\">Black or African American<\/td>\n<td style=\"padding: 6px 15px;\">38,929,319<\/td>\n<\/tr>\n<tr>\n<td style=\"padding: 6px 15px;\">American Indian and Alaska Native<\/td>\n<td style=\"padding: 6px 15px;\">2,932,248<\/td>\n<\/tr>\n<tr>\n<td style=\"padding: 6px 15px;\">Asian<\/td>\n<td style=\"padding: 6px 15px;\">14,674,252<\/td>\n<\/tr>\n<tr>\n<td style=\"padding: 6px 15px;\">Native Hawaiian and Other Pacific Islander<\/td>\n<td style=\"padding: 6px 15px;\">540,013<\/td>\n<\/tr>\n<tr>\n<td style=\"padding: 6px 15px;\">Some Other Race<\/td>\n<td style=\"padding: 6px 15px;\">19,107,368<\/td>\n<\/tr>\n<tr>\n<td style=\"padding: 6px 15px;\">Two or More Races<\/td>\n<td style=\"padding: 6px 15px;\">9,009,073<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>If you looked at the original data table in the Census Brief, you may have noticed there is a separate column with percentages. The great thing about JavaScript charts is that you don&#8217;t need it, you can put in data, and the chart calculates everything:<\/p>\n<pre><code class=\"javascript\">\/\/ set the data\r\nvar data = [\r\n    {x: \"White\", value: 223553265},\r\n    {x: \"Black or African American\", value: 38929319},\r\n    {x: \"American Indian and Alaska Native\", value: 2932248},\r\n    {x: \"Asian\", value: 14674252},\r\n    {x: \"Native Hawaiian and Other Pacific Islander\", value: 540013},\r\n    {x: \"Some Other Race\", value: 19107368},\r\n    {x: \"Two or More Races\", value: 9009073}\r\n];\r\n<\/code><\/pre>\n<h3>Step 4. Write the chart code<\/h3>\n<p>This is the finishing step in creating an interactive JavaScript pie chart. Add the <code>anychart.onDocumentReady<\/code> function. This function is executed when the page is ready. Create the chart entity, put it into the container and connect the data with the chart.<\/p>\n<pre><code class=\"javascript\">anychart.onDocumentReady(function() {\r\n\r\n  \/\/ set the data\r\n  var data = [\r\n      {x: \"White\", value: 223553265},\r\n      {x: \"Black or African American\", value: 38929319},\r\n      {x: \"American Indian and Alaska Native\", value: 2932248},\r\n      {x: \"Asian\", value: 14674252},\r\n      {x: \"Native Hawaiian and Other Pacific Islander\", value: 540013},\r\n      {x: \"Some Other Race\", value: 19107368},\r\n      {x: \"Two or More Races\", value: 9009073}\r\n  ];\r\n\r\n  \/\/ create the chart\r\n  var chart = anychart.pie();\r\n\r\n  \/\/ set the chart title\r\n  chart.title(\"Population by Race for the United States: 2010 Census\");\r\n\r\n  \/\/ add the data\r\n  chart.data(data);\r\n\r\n  \/\/ display the chart in the container\r\n  chart.container('container');\r\n  chart.draw();\r\n\r\n});\r\n<\/code><\/pre>\n<p>Here&#8217;s how it looks:<\/p>\n<p class=\"codepen\" data-height=\"476\" data-theme-id=\"dark\" data-slug-hash=\"RjaxLx\" data-default-tab=\"result\" data-user=\"AnyChart\" data-embed-version=\"2\" data-pen-title=\"Creating a JavaScript Pie Chart: Basic Example\">See the Pen <a href=\"https:\/\/codepen.io\/AnyChart\/pen\/RjaxLx\/\" target=\"_blank\" rel=\"nofollow\">Creating a JavaScript Pie Chart: Basic Example<\/a> by AnyChart JS Charts (<a href=\"https:\/\/codepen.io\/AnyChart\" target=\"_blank\" rel=\"nofollow\">@AnyChart<\/a>) on <a href=\"https:\/\/codepen.io\" target=\"_blank\" rel=\"nofollow\">CodePen<\/a>.<\/p>\n<p><script async src=\"https:\/\/production-assets.codepen.io\/assets\/embed\/ei.js\"><\/script><\/p>\n<p>That\u2019s it! A simple pie chart created with a JavaScript charting library is ready!<\/p>\n<h2>Change Chart Appearance<\/h2>\n<p>This section is optional. If you are not satisfied with the chart appearance and want it to be more remarkable and attractive, you can make the necessary changes.<\/p>\n<p>JS pie charts have a lot of settings. You can learn about them in the\u00a0<a href=\"https:\/\/docs.anychart.com\/Basic_Charts\/Pie_Chart\" target=\"_blank\" rel=\"nofollow\">Pie Chart Settings<\/a> article and grab some ideas and code from the <a href=\"https:\/\/www.anychart.com\/products\/anychart\/gallery\/Pie_and_Donut_Charts\/\">Pie Chart Gallery<\/a>.<\/p>\n<p>Let\u2019s get our modifications started!<\/p>\n<h3>Legend<\/h3>\n<p>Pie charts have a special control element: legend. Also known as the chart&#8217;s key, the legend is linked to the data that&#8217;s displayed\u00a0on\u00a0the chart.<\/p>\n<p>By default, the legend is placed at the bottom of the chart and it is not looking good in this particular case.<\/p>\n<p>To move the legend to the right and make its elements stack vertically, add the following setting to the code:<\/p>\n<pre><code class=\"javascript language-javascript \">\/\/ set legend position\r\nchart.legend().position(\"right\");\r\n\/\/ set items layout\r\nchart.legend().itemsLayout(\"vertical\");\r\n<\/code><\/pre>\n<p>Look how these modifications changed the pie chart:<\/p>\n<p class=\"codepen\" data-height=\"476\" data-theme-id=\"dark\" data-slug-hash=\"RjaxxQ\" data-default-tab=\"result\" data-user=\"AnyChart\" data-embed-version=\"2\" data-pen-title=\"Creating a JavaScript Pie Chart: Move Legend\">See the Pen <a href=\"https:\/\/codepen.io\/AnyChart\/pen\/RjaxxQ\/\" target=\"_blank\" rel=\"nofollow\">Creating a JavaScript Pie Chart: Move Legend<\/a> by AnyChart JS Charts (<a href=\"https:\/\/codepen.io\/AnyChart\" target=\"_blank\" rel=\"nofollow\">@AnyChart<\/a>) on <a href=\"https:\/\/codepen.io\" target=\"_blank\" rel=\"nofollow\">CodePen<\/a>.<\/p>\n<p><script async src=\"https:\/\/production-assets.codepen.io\/assets\/embed\/ei.js\"><\/script><\/p>\n<p>Much better, right?<\/p>\n<h3>Sort<\/h3>\n<p>Another thing we can change is the order of slices in a pie to facilitate the visual data analysis. Let&#8217;s sort things out:<\/p>\n<pre><code>\/\/ sort elements\r\nchart.sort(\"desc\");\r\n<\/code><\/pre>\n<p>And the picture becomes clearer:<\/p>\n<p class=\"codepen\" data-height=\"476\" data-theme-id=\"dark\" data-slug-hash=\"eeZyVN\" data-default-tab=\"result\" data-user=\"AnyChart\" data-embed-version=\"2\" data-pen-title=\"Creating a JavaScript Pie Chart: Sort Slices\">See the Pen <a href=\"https:\/\/codepen.io\/AnyChart\/pen\/eeZyVN\/\" target=\"_blank\" rel=\"nofollow\">Creating a JavaScript Pie Chart: Sort Slices<\/a> by AnyChart JS Charts (<a href=\"https:\/\/codepen.io\/AnyChart\" target=\"_blank\" rel=\"nofollow\">@AnyChart<\/a>) on <a href=\"https:\/\/codepen.io\" target=\"_blank\" rel=\"nofollow\">CodePen<\/a>.<\/p>\n<p><script async src=\"https:\/\/production-assets.codepen.io\/assets\/embed\/ei.js\"><\/script><\/p>\n<h3>Explode<\/h3>\n<p>There is one last thing we can do to highlight the hot-button issue we mentioned in the beginning. Let&#8217;s make the majority group stand out visually. To do so, we change the data by mean of a special setting:<\/p>\n<pre><code>{x: \"White\", value: 223553265, exploded: true},\r\n<\/code><\/pre>\n<p>And the final JavaScript pie\u00a0chart looks as follows:<\/p>\n<p class=\"codepen\" data-height=\"476\" data-theme-id=\"dark\" data-slug-hash=\"eeZyMp\" data-default-tab=\"result\" data-user=\"AnyChart\" data-embed-version=\"2\" data-pen-title=\"Creating a JavaScript Pie Chart: Explode\">See the Pen <a href=\"https:\/\/codepen.io\/AnyChart\/pen\/eeZyMp\/\" target=\"_blank\" rel=\"nofollow\">Creating a JavaScript Pie Chart: Explode<\/a> by AnyChart JS Charts (<a href=\"https:\/\/codepen.io\/AnyChart\" target=\"_blank\" rel=\"nofollow\">@AnyChart<\/a>) on <a href=\"https:\/\/codepen.io\" target=\"_blank\" rel=\"nofollow\">CodePen<\/a>.<\/p>\n<p><script async src=\"https:\/\/production-assets.codepen.io\/assets\/embed\/ei.js\"><\/script><\/p>\n<p>This pie chart could be a good addendum to many articles on the state of racial relations in the USA. &#8220;<a href=\"http:\/\/wapo.st\/2a1qxfa\" target=\"_blank\" rel=\"nofollow\">America really is more divided than ever<\/a>&#8221; is the name of a <em>Washington Post<\/em> article by Joel Achenbach and Scott Clement. &#8220;<a href=\"https:\/\/www.ft.com\/content\/1456e78c-589a-11e6-9f70-badea1b336d4\" target=\"_blank\" rel=\"nofollow\">America is more racially divided than it has been in decades<\/a>,&#8221; echoes Carol Anderson in the <em>Financial Times<\/em>. These are troubling times and everyone hopes that the society will remember Barack Obama&#8217;s words: <em>\u201cThat\u2019s the path out of moments like these. Not to withdraw, or shout each other down, but to reach out to each other \u2014 even if it\u2019s difficult \u2014 and find some common ground.\u201d<\/em><\/p>\n<h2>Conclusion<\/h2>\n<p>This small tutorial explains how to build a pie chart using the AnyChart JavaScript charting library. Go to the official <a href=\"https:\/\/www.anychart.com\">AnyChart JS Charts website<\/a> for more information and, in particular, visit the <a href=\"https:\/\/www.anychart.com\/products\/gallery\/anychart\/\">JavaScript Chart Gallery<\/a> for more chart types illustrated. The <a href=\"https:\/\/docs.anychart.com\" target=\"_blank\" rel=\"nofollow\">AnyChart Charts Documentation<\/a> and <a href=\"https:\/\/api.anychart.com\" target=\"_blank\" rel=\"nofollow\">AnyChart JavaScript API<\/a> will help you to build and adjust your HTML5 charts with ease.<\/p>\n<p><!-- SyntaxHighlighter \n--><link rel=\"stylesheet\" href=\"\/\/cdnjs.cloudflare.com\/ajax\/libs\/highlight.js\/9.12.0\/styles\/default.min.css\"\n><link rel=\"stylesheet\" href=\"\/\/cdnjs.cloudflare.com\/ajax\/libs\/highlight.js\/9.12.0\/styles\/atom-one-light.min.css\"\n><script src=\"\/\/cdnjs.cloudflare.com\/ajax\/libs\/highlight.js\/9.12.0\/highlight.min.js\"\n><\/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>Have you ever wondered, how web developers create and integrate interactive JavaScript pie charts into HTML5 apps and web pages? If the answer is yes \u2013 keep on reading! This article explains how to create, change and integrate a pie chart into your web page. Beware!\u00a0A hot-button political issue is present in this article. But [&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":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,23,13,279,4],"tags":[53,127,44,54,32,55,61,144,36,141,81,57,60,58,65,56,59,84,30,172],"class_list":["post-5085","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-anychart","tag-chart-types","tag-charts-and-art","tag-data-visualization","tag-html5","tag-html5-charts","tag-html5-pie","tag-infographics","tag-javascript","tag-javascript-charting","tag-javascript-charting-library","tag-javascript-charts","tag-javascript-pie-chart","tag-js-chart","tag-js-charting","tag-js-charts","tag-js-pie-chart","tag-pie-charts","tag-tips-and-tricks","tag-tutorial","wpautop"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.1.1 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Pie Chart: How to Create Interactive One with JavaScript<\/title>\n<meta name=\"description\" content=\"Have you ever wondered how web developers create and integrate an interactive JavaScript pie chart into HTML5 apps, web pages? Read this tutorial to learn.\" \/>\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\/2017\/12\/06\/pie-chart-create-javascript\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Create Pie Chart with JavaScript\" \/>\n<meta property=\"og:description\" content=\"Read this tutorial to learn how web developers create and integrate an interactive JavaScript pie chart into HTML5 apps, web pages.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.anychart.com\/blog\/2017\/12\/06\/pie-chart-create-javascript\/\" \/>\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=\"2017-12-06T07:47:55+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-08-13T10:56:39+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2017\/11\/creating-javascript-pie-chart-___-.jpg\" \/>\n<meta name=\"author\" content=\"Timothy Loginov\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:title\" content=\"How to Create Pie Chart with JavaScript\" \/>\n<meta name=\"twitter:description\" content=\"Read this tutorial to learn how web developers create and integrate an interactive JavaScript pie chart into HTML5 apps, web pages.\" \/>\n<meta name=\"twitter:image\" content=\"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2017\/11\/creating-javascript-pie-chart-___-.jpg\" \/>\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=\"Timothy Loginov\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"7 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.anychart.com\/blog\/2017\/12\/06\/pie-chart-create-javascript\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.anychart.com\/blog\/2017\/12\/06\/pie-chart-create-javascript\/\"},\"author\":{\"name\":\"Timothy Loginov\",\"@id\":\"https:\/\/www.anychart.com\/blog\/#\/schema\/person\/a944a69f34509440ab4a9b5ead73caa6\"},\"headline\":\"How to Create Pie Chart with JavaScript\",\"datePublished\":\"2017-12-06T07:47:55+00:00\",\"dateModified\":\"2022-08-13T10:56:39+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.anychart.com\/blog\/2017\/12\/06\/pie-chart-create-javascript\/\"},\"wordCount\":1086,\"commentCount\":29,\"image\":{\"@id\":\"https:\/\/www.anychart.com\/blog\/2017\/12\/06\/pie-chart-create-javascript\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2017\/11\/creating-javascript-pie-chart-___-.jpg\",\"keywords\":[\"AnyChart\",\"chart types\",\"Charts and Art\",\"Data Visualization\",\"HTML5\",\"html5 charts\",\"html5 pie\",\"infographics\",\"JavaScript\",\"javascript charting\",\"JavaScript charting library\",\"javascript charts\",\"javascript pie chart\",\"js chart\",\"js charting\",\"js charts\",\"js pie chart\",\"pie charts\",\"Tips and tricks\",\"tutorial\"],\"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\/2017\/12\/06\/pie-chart-create-javascript\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.anychart.com\/blog\/2017\/12\/06\/pie-chart-create-javascript\/\",\"url\":\"https:\/\/www.anychart.com\/blog\/2017\/12\/06\/pie-chart-create-javascript\/\",\"name\":\"Pie Chart: How to Create Interactive One with JavaScript\",\"isPartOf\":{\"@id\":\"https:\/\/www.anychart.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.anychart.com\/blog\/2017\/12\/06\/pie-chart-create-javascript\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.anychart.com\/blog\/2017\/12\/06\/pie-chart-create-javascript\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2017\/11\/creating-javascript-pie-chart-___-.jpg\",\"datePublished\":\"2017-12-06T07:47:55+00:00\",\"dateModified\":\"2022-08-13T10:56:39+00:00\",\"author\":{\"@id\":\"https:\/\/www.anychart.com\/blog\/#\/schema\/person\/a944a69f34509440ab4a9b5ead73caa6\"},\"description\":\"Have you ever wondered how web developers create and integrate an interactive JavaScript pie chart into HTML5 apps, web pages? Read this tutorial to learn.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.anychart.com\/blog\/2017\/12\/06\/pie-chart-create-javascript\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.anychart.com\/blog\/2017\/12\/06\/pie-chart-create-javascript\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.anychart.com\/blog\/2017\/12\/06\/pie-chart-create-javascript\/#primaryimage\",\"url\":\"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2017\/11\/creating-javascript-pie-chart-___-.jpg\",\"contentUrl\":\"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2017\/11\/creating-javascript-pie-chart-___-.jpg\",\"width\":1100,\"height\":710},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.anychart.com\/blog\/2017\/12\/06\/pie-chart-create-javascript\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.anychart.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Create Pie Chart with 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\/a944a69f34509440ab4a9b5ead73caa6\",\"name\":\"Timothy Loginov\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.anychart.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/00860a412d134244a5234231874065a30044d4d59f78aef4cca746e1e2dd3691?s=96&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/00860a412d134244a5234231874065a30044d4d59f78aef4cca746e1e2dd3691?s=96&r=g\",\"caption\":\"Timothy Loginov\"},\"url\":\"https:\/\/www.anychart.com\/blog\/author\/timothy-loginov\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Pie Chart: How to Create Interactive One with JavaScript","description":"Have you ever wondered how web developers create and integrate an interactive JavaScript pie chart into HTML5 apps, web pages? Read this tutorial to learn.","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\/2017\/12\/06\/pie-chart-create-javascript\/","og_locale":"en_US","og_type":"article","og_title":"How to Create Pie Chart with JavaScript","og_description":"Read this tutorial to learn how web developers create and integrate an interactive JavaScript pie chart into HTML5 apps, web pages.","og_url":"https:\/\/www.anychart.com\/blog\/2017\/12\/06\/pie-chart-create-javascript\/","og_site_name":"AnyChart News","article_publisher":"https:\/\/www.facebook.com\/AnyCharts","article_published_time":"2017-12-06T07:47:55+00:00","article_modified_time":"2022-08-13T10:56:39+00:00","og_image":[{"url":"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2017\/11\/creating-javascript-pie-chart-___-.jpg","type":"","width":"","height":""}],"author":"Timothy Loginov","twitter_card":"summary_large_image","twitter_title":"How to Create Pie Chart with JavaScript","twitter_description":"Read this tutorial to learn how web developers create and integrate an interactive JavaScript pie chart into HTML5 apps, web pages.","twitter_image":"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2017\/11\/creating-javascript-pie-chart-___-.jpg","twitter_creator":"@AnyChart","twitter_site":"@AnyChart","twitter_misc":{"Written by":"Timothy Loginov","Est. reading time":"7 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.anychart.com\/blog\/2017\/12\/06\/pie-chart-create-javascript\/#article","isPartOf":{"@id":"https:\/\/www.anychart.com\/blog\/2017\/12\/06\/pie-chart-create-javascript\/"},"author":{"name":"Timothy Loginov","@id":"https:\/\/www.anychart.com\/blog\/#\/schema\/person\/a944a69f34509440ab4a9b5ead73caa6"},"headline":"How to Create Pie Chart with JavaScript","datePublished":"2017-12-06T07:47:55+00:00","dateModified":"2022-08-13T10:56:39+00:00","mainEntityOfPage":{"@id":"https:\/\/www.anychart.com\/blog\/2017\/12\/06\/pie-chart-create-javascript\/"},"wordCount":1086,"commentCount":29,"image":{"@id":"https:\/\/www.anychart.com\/blog\/2017\/12\/06\/pie-chart-create-javascript\/#primaryimage"},"thumbnailUrl":"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2017\/11\/creating-javascript-pie-chart-___-.jpg","keywords":["AnyChart","chart types","Charts and Art","Data Visualization","HTML5","html5 charts","html5 pie","infographics","JavaScript","javascript charting","JavaScript charting library","javascript charts","javascript pie chart","js chart","js charting","js charts","js pie chart","pie charts","Tips and tricks","tutorial"],"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\/2017\/12\/06\/pie-chart-create-javascript\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.anychart.com\/blog\/2017\/12\/06\/pie-chart-create-javascript\/","url":"https:\/\/www.anychart.com\/blog\/2017\/12\/06\/pie-chart-create-javascript\/","name":"Pie Chart: How to Create Interactive One with JavaScript","isPartOf":{"@id":"https:\/\/www.anychart.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.anychart.com\/blog\/2017\/12\/06\/pie-chart-create-javascript\/#primaryimage"},"image":{"@id":"https:\/\/www.anychart.com\/blog\/2017\/12\/06\/pie-chart-create-javascript\/#primaryimage"},"thumbnailUrl":"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2017\/11\/creating-javascript-pie-chart-___-.jpg","datePublished":"2017-12-06T07:47:55+00:00","dateModified":"2022-08-13T10:56:39+00:00","author":{"@id":"https:\/\/www.anychart.com\/blog\/#\/schema\/person\/a944a69f34509440ab4a9b5ead73caa6"},"description":"Have you ever wondered how web developers create and integrate an interactive JavaScript pie chart into HTML5 apps, web pages? Read this tutorial to learn.","breadcrumb":{"@id":"https:\/\/www.anychart.com\/blog\/2017\/12\/06\/pie-chart-create-javascript\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.anychart.com\/blog\/2017\/12\/06\/pie-chart-create-javascript\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.anychart.com\/blog\/2017\/12\/06\/pie-chart-create-javascript\/#primaryimage","url":"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2017\/11\/creating-javascript-pie-chart-___-.jpg","contentUrl":"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2017\/11\/creating-javascript-pie-chart-___-.jpg","width":1100,"height":710},{"@type":"BreadcrumbList","@id":"https:\/\/www.anychart.com\/blog\/2017\/12\/06\/pie-chart-create-javascript\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.anychart.com\/blog\/"},{"@type":"ListItem","position":2,"name":"How to Create Pie Chart with 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\/a944a69f34509440ab4a9b5ead73caa6","name":"Timothy Loginov","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.anychart.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/00860a412d134244a5234231874065a30044d4d59f78aef4cca746e1e2dd3691?s=96&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/00860a412d134244a5234231874065a30044d4d59f78aef4cca746e1e2dd3691?s=96&r=g","caption":"Timothy Loginov"},"url":"https:\/\/www.anychart.com\/blog\/author\/timothy-loginov\/"}]}},"_links":{"self":[{"href":"https:\/\/www.anychart.com\/blog\/wp-json\/wp\/v2\/posts\/5085","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\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.anychart.com\/blog\/wp-json\/wp\/v2\/comments?post=5085"}],"version-history":[{"count":38,"href":"https:\/\/www.anychart.com\/blog\/wp-json\/wp\/v2\/posts\/5085\/revisions"}],"predecessor-version":[{"id":15489,"href":"https:\/\/www.anychart.com\/blog\/wp-json\/wp\/v2\/posts\/5085\/revisions\/15489"}],"wp:attachment":[{"href":"https:\/\/www.anychart.com\/blog\/wp-json\/wp\/v2\/media?parent=5085"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.anychart.com\/blog\/wp-json\/wp\/v2\/categories?post=5085"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.anychart.com\/blog\/wp-json\/wp\/v2\/tags?post=5085"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}