▾
Proportion of college undergraduates in different regions, with each slice representing a region and the size of the slice corresponding to the number of undergraduates in that region.
What is a pie chart?
Pie charts group data into slices to visualize part-to-whole relationships, the size of the slices correspond to the proportion of each category to the whole.
Data configurations
This section covers a few data configuration examples for pie charts, each configured using the pie chart model. See the pie chart model reference for the full list of available properties and methods.
With category field
Pie chart with a category field will display the count of features for each category. A category field must be a string or integer.
- Set the
categoryproperty to"Region"to specify the category field.
28 collapsed lines
<html> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" /> <title>Pie Chart with Category Field</title> <style> html, body, arcgis-chart { height: 100%; margin: 0; } </style> <!-- Load the ArcGIS Maps SDK for JavaScript from CDN --> <script type="module" src="https://js.arcgis.com/5.2/"></script> </head> <body> <arcgis-chart></arcgis-chart> <script type="module"> const { createModel } = await $arcgis.import("@arcgis/charts-components/model/shared/setup-utils.js"); const FeatureLayer = await $arcgis.import("@arcgis/core/layers/FeatureLayer.js"); const featureLayer = new FeatureLayer({ portalItem: { id: "8871626e970a4f3e9d6113ec63a92f2f", }, }); const chartElement = document.querySelector("arcgis-chart"); const pieChartModel = await createModel({ layer: featureLayer, chartType: "pieChart" }); pieChartModel.category = "Region";10 collapsed lines
pieChartModel.labelCharacterLimit = 20; pieChartModel.dataLabelsVisibility = true; pieChartModel.alignDataLabels = true; pieChartModel.optimizeDataLabelsOverlapping = true; pieChartModel.titleText = "Percentage of College Undergraduates by Region"; chartElement.model = pieChartModel; chartElement.actionMode = "none"; </script> </body></html>With numeric fields
Pie chart with only numeric fields will display each numeric field as its own slice, with values aggregated using the sum.
- Set the
numericFieldsproperty to specify the numeric fields.
29 collapsed lines
<html> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" /> <title>Pie Chart with Numeric Fields</title> <style> html, body, arcgis-chart { height: 100%; margin: 0; } </style> <!-- Load the ArcGIS Maps SDK for JavaScript from CDN --> <script type="module" src="https://js.arcgis.com/5.2/"></script> </head> <body> <arcgis-chart></arcgis-chart> <script type="module"> const { createModel } = await $arcgis.import("@arcgis/charts-components/model/shared/setup-utils.js"); const FeatureLayer = await $arcgis.import("@arcgis/core/layers/FeatureLayer.js"); const featureLayer = new FeatureLayer({ portalItem: { id: "a8dd07c93e654c76b68951795a20a295", }, }); const chartElement = document.querySelector("arcgis-chart"); const pieChartModel = await createModel({ layer: featureLayer, chartType: "pieChart" });
pieChartModel.numericFields = [ "AGE_UNDER5", "AGE_5_17", "AGE_18_21", "AGE_22_29", "AGE_30_39", "AGE_40_49", "AGE_50_64", "AGE_65_UP", ];9 collapsed lines
pieChartModel.titleText = "Population by Age Groups in the United States"; pieChartModel.dataLabelsVisibility = true; pieChartModel.legendTitleText = "Age Group"; pieChartModel.legendPosition = "left"; chartElement.model = pieChartModel; chartElement.actionMode = "none"; </script> </body></html>With category and numeric fields
When both category and numeric fields are specified, the slices are aggregated by sum: the numeric field is summed for each unique value, and those totals are used to calculate each slice’s proportion.
- Set the
categoryproperty to"Region"to specify the category field. - Set the
numericFieldsproperty to["Undergrads"]to specify the numeric field to be aggregated for slice size.
28 collapsed lines
<html> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" /> <title>Pie Chart with Category and Numeric Fields</title> <style> html, body, arcgis-chart { height: 100%; margin: 0; } </style> <!-- Load the ArcGIS Maps SDK for JavaScript from CDN --> <script type="module" src="https://js.arcgis.com/5.2/"></script> </head> <body> <arcgis-chart></arcgis-chart> <script type="module"> const { createModel } = await $arcgis.import("@arcgis/charts-components/model/shared/setup-utils.js"); const FeatureLayer = await $arcgis.import("@arcgis/core/layers/FeatureLayer.js"); const featureLayer = new FeatureLayer({ portalItem: { id: "8871626e970a4f3e9d6113ec63a92f2f", }, }); const chartElement = document.querySelector("arcgis-chart"); const pieChartModel = await createModel({ layer: featureLayer, chartType: "pieChart" }); pieChartModel.category = "Region"; pieChartModel.numericFields = ["Undergrads"];12 collapsed lines
pieChartModel.labelCharacterLimit = 20; pieChartModel.dataLabelsVisibility = true; pieChartModel.alignDataLabels = true; pieChartModel.optimizeDataLabelsOverlapping = true; pieChartModel.titleText = "Sum of College Undergraduates by Region"; pieChartModel.legendTitleText = "Region"; pieChartModel.legendPosition = "right"; chartElement.model = pieChartModel; chartElement.actionMode = "none"; </script> </body></html>Customization options
Start and end angles
Pie charts can be customized to display a full circle, half circle, or any other arc by adjusting the start and end angles from the startAngle and endAngle properties of the pie chart model.
The angles are specified in degrees, with 0 degrees pointing to the right (3 o’clock position) and increasing counterclockwise.
| Default (full circle) | startAngle: -200endAngle: 20 | startAngle: -180endAngle: -90 | startAngle: 0endAngle: 180 |
|---|---|---|---|
![]() | ![]() | ![]() | ![]() |
Inner radius
The inner radius of a pie chart can be adjusted using the innerRadius property of the pie chart model.
This property controls the size of the inner circle, allowing you to create a donut chart by setting it to a value greater than 0, which can improve readability by providing more empty space in the center of the chart.
innerRadius: 10 | innerRadius: 50 | innerRadius: 80 |
|---|---|---|
![]() | ![]() | ![]() |
Display options for data labels, tooltips, and legend items
Pie chart data labels, tooltips, and legend items can be customized to display each slice’s category, numeric value, and percentage.
By default,
- Data labels display the category and percentage.
- Use the
displayCategoryOnDataLabel,displayNumericValueOnDataLabel, anddisplayPercentageOnDataLabelproperties to customize the data labels. - The ticks connecting the data labels to the slices can be customized using the
ticksVisibilityandticksSymbolproperties.
- Use the
- Tooltips display the category, numeric value, and percentage.
- Use the
displayCategoryValueOnTooltip,displayNumericValueOnTooltip, anddisplayPercentageOnTooltipproperties to customize the tooltips.
- Use the
- Legend items display the category and percentage.
- Use the
displayCategoryOnLegendItems,displayNumericValueOnLegendItems, anddisplayPercentageOnLegendItemsproperties to customize the legend items. - Round markers can be set by using the
legendRoundMarkerproperty.
- Use the
| Data labels | Tooltips | Legend items |
|---|---|---|
![]() | ![]() | ![]() |
Slice grouping
When a pie chart contains too many slices with small proportions, it might be difficult to read and interpret. In such cases, the smaller slices can be grouped into an “Other” category to improve readability.
- Set the
sliceGroupingproperty to customize the grouping slice. - Set the
percentageThresholdproperty to12, which means any slice with a proportion smaller than 12% will be grouped into the “Other” category. - Set the
labelproperty to"Less than 12%"to specify the name of the grouping slice. The legend item will be updated to reflect this label. - Set the
fillSymbolproperty to customize the fill symbol of the grouping slice. The legend item will be updated to reflect this symbol.
30 collapsed lines
<html> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" /> <title>Pie Chart with Category and Numeric Fields with Grouping</title> <style> html, body, arcgis-chart { height: 100%; margin: 0; } </style> <!-- Load the ArcGIS Maps SDK for JavaScript from CDN --> <script type="module" src="https://js.arcgis.com/5.2/"></script> </head> <body> <arcgis-chart></arcgis-chart> <script type="module"> const { createModel } = await $arcgis.import("@arcgis/charts-components/model/shared/setup-utils.js"); const FeatureLayer = await $arcgis.import("@arcgis/core/layers/FeatureLayer.js"); const featureLayer = new FeatureLayer({ portalItem: { id: "8871626e970a4f3e9d6113ec63a92f2f", }, }); const chartElement = document.querySelector("arcgis-chart"); const pieChartModel = await createModel({ layer: featureLayer, chartType: "pieChart" }); pieChartModel.category = "Region"; pieChartModel.numericFields = ["Undergrads"]; pieChartModel.sliceGrouping = { percentageThreshold: 12, label: "Less than 12%", fillSymbol: { type: "esriSFS", style: "esriSFSCross", color: [255, 0, 255, 255], outline: { type: "esriSLS", style: "esriSLSDot", color: [0, 0, 0, 255], width: 2, }, }, };12 collapsed lines
pieChartModel.labelCharacterLimit = 20; pieChartModel.dataLabelsVisibility = true; pieChartModel.alignDataLabels = true; pieChartModel.optimizeDataLabelsOverlapping = true; pieChartModel.titleText = "Sum of College Undergraduates by Region"; pieChartModel.legendTitleText = "Region"; pieChartModel.legendPosition = "right"; chartElement.model = pieChartModel; chartElement.actionMode = "none"; </script> </body></html>








