How To Use Pie Chart In Google Sheets

Google Sheets, a powerful, free-to-use tool that allows you to create, edit, and store spreadsheets online, provides a variety of features, one of which is the ability to create pie charts. A pie chart is a circular graph that is divided into slices to illustrate numerical proportion. In this blog post, we will guide you on how to use pie chart in Google Sheets.

Creating a Pie Chart

Here’s a step-by-step guide on how to create a pie chart in Google Sheets:

  1. Prepare your data: The first step in creating a pie chart is to have your data ready in Google Sheets. Ensure that your data is organized in a way that one column should contain the item names and one column should contain the corresponding values.
  2. Select your data: Highlight the entire data set that you want to include in your pie chart, including the headers. You can do this by clicking and dragging over the cells that contain your data.
  3. Insert chart: From the menu at the top of your screen, click on Insert and then Chart.
  4. Select Pie Chart: In the chart editor on the right side of the screen, click on the Chart Type dropdown. Scroll down and select Pie chart.
  5. Customize your chart: You can customize your chart by adding a chart title, changing the color of the pie slices, or adding data labels. These options are available under the Customize tab in the Chart Editor.

Sample Code

You can also create a Pie Chart in Google Sheets using Google Apps Script. Below is a sample code:

function createPieChart() {
  var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Sheet1');
  var data = sheet.getRange("A1:B5").getValues();
  var chart = sheet.newChart()
     .setChartType(Charts.ChartType.PIE)
     .addRange(sheet.getRange("A1:B5"))
     .setPosition(5, 5, 0, 0)
     .build();
  sheet.insertChart(chart);
}

The above script will create a pie chart based on the values in the range A1:B5 of ‘Sheet1’.

In conclusion, whether it’s for business, school, or personal use, pie charts are an effective way to visualize data. Google Sheets makes it incredibly easy to create these diagrams with just a few clicks!