Pie Chart


A pie chart is a circular chart looking like a pie divided into slices (sectors). Slices show the percentage each value contributes to a total, the area of each slice being proportional to the quantity it represents, and the circle representing 100%. A pie chart with a blank circular area in the center is called a doughnut chart.

Pie charts are used very widely with small sets of data to compare categories. They cannot be multi-series and should not be used when there are more than just a few categories.

This article explains how to create a basic Pie chart as well as configure settings that are specific to the type. You can also see the table below to get a brief overview of the Pie chart's characteristics:

Data Fieldsx, value
Multiple SeriesN/A
3D3D Pie
Error BarsN/A
Chartopedia: Pie Chart
General Settings

Quick Start

To create a Pie chart, use the anychart.pie() chart constructor, like in the following sample:

// create data
var data = [
  {x: "A", value: 637166},
  {x: "B", value: 721630},
  {x: "C", value: 148662},
  {x: "D", value: 78662},
  {x: "E", value: 90000}

// create a chart and set the data
var chart = anychart.pie(data);

// set the container id

// initiate drawing the chart


General Settings

In AnyChart there are many settings that are configured in the same way for all chart types, including the Pie chart (for example, legend and interactivity settings).

Read the overview of general settings: General Settings.

Special Settings


Here is a full list of methods used to configure visual settings that are available for the Pie chart:

You can learn more from the Appearance Settings section.

In the sample below, there a Pie chart with some of the appearance settings configured:

// configure visual settings
chart.fill("#0066cc", 0.5);
chart.hoverFill("#0066cc", 0.6);
chart.hatchFill("backwarddiagonal", "#808080");
chart.hoverHatchFill("backwarddiagonal", "#0066cc", 3);
chart.stroke("#808080", 3);
chart.hoverStroke("#0066cc", 3);


There is also a special visual setting available for the Pie chart – Aqua Style. To apply it, use the fill() method with the "aquastyle" parameter:

// enable aqua style


Please note that the methods listed above affect the whole chart. The appearance of particular slices can be configured by adding special fields to the data, which should be set in object notation:

// create data
var data = [
  {x: "Pacman", value: 400, fill: "#ffff00", hatchFill: "percent50"},
  {x: "Not Pacman", value: 130, fill: "#404040"},


You can learn more from the Appearance Settings article.


Labels are text or image elements that can be placed anywhere on any chart (you can enable them on a whole series or in a single point). For text labels, font settings and text formatters are available.

Outer Labels

By default, labels are placed on the Pie chart. However, you can place them outside of the chart by using the position() method with the "outside" parameter:

// set the position of labels

To configure connectors (the lines connecting labels with slices), call the connectorStroke() method:

// configure connectors
chart.connectorStroke({color: "#595959", thickness: 2, dash:"2 2"});

Other settings available for outer labels are outsideLabelsSpace() and outsideLabelsCriticalAngle().

In this sample, there are outside labels with customized connectors:



A Tooltip is a text box displayed when a point on a chart is hovered. There is a number of visual and other settings available: for example, you can edit the text by using font settings and text formatters, change the style of background, adjust the position of a tooltip, and so on.

Start Angle

You can set the start angle of the first slice by using the startAngle() method. The angle is 0° by default.

In the sample below, the start angle of the first chart is not configured, and for the second chart it is set to 90°:

// set the start angle


Sorting Order

In AnyChart you can sort the slices of a Pie chart in an ascending or descending order if you use the sort() method and "asc" or "desc" as a parameter (there is no sorting by default):

// set the sorting mode


Exploded Slices

By default, there is no spaces between the slices of a Pie chart, and when a user clicks a slice, it "explodes", moving away from the others.

You can configure the range of explosion by using the explode() method:

// set the explosion range
chart.explode (30);

To make some slices exploded by default, use the explodeSlice() method with two parameters. The first one is the number of a slice (numbering starts from 0), and the second one is a boolean value that enables explosion:

// explode the third slice
chart.explodeSlice(2, true);

Another way to enable explosion is to add a special field to your data, which should be set as an object:

// create a data
var data = [
  {x: "A", value: 637166},
  {x: "B", value: 721630},
  {x: "C", value: 148662},
  {x: "D", value: 78662, exploded: true},
  {x: "E", value: 90000}

In this sample, there is a Pie chart with two slices exploded by default and the explosion range set to 30:



To set the radius of a Pie chart, call the radius() method and specify either a value or a percentage of the chart's bounds.

In the following sample, the radius of the first Pie chart is not configured, and the radius of the second one is set to 30%:

// set the radius


The innerRadius() method allows you to set the inner radius of a Pie chart (which is 0 by default), thus turning it into a Doughnut chart. Read more in the Doughnut Chart article.

You are looking at an outdated v7 version of this document. Switch to the v8 version to see the up to date information.