Change number instead of percent in Google Sheet Pie chart


๐Ÿ‘คย Diwas Poudel ย ย  ๐Ÿ•’ 27 May 2023 ย ย  ๐Ÿ“ FIX

Google Sheets is a powerful free tool provided by Google which helps to plot your data into colorful charts and graphs. So that we can analyze the different information quickly. Google Sheets provides different types of charts like bar charts, pie charts, line charts, histograms, and many more.

In this article, we will explain one of the commonly asked questions ie. Change the number instead of percent in google sheet piecharts.

Piecharts are statistical graphs in which a circle is divided into slices(ie. sections) to represent values of relative sizes of data.


Here, In the example, we are using one simple table and generated pie charts showing data on expenses and savings of income. We assume that you already know to create a pie chart. And its default generated pie charts look like this.

default-piechart-googesheet

Also, read:ย How to use if a cell contains in google sheets?ย 

This shows the only percentage in the piecharts and now you want to get value instead of this then follow these steps.

Working with Google Sheets version :

1 First click on the piechart

2 Click on 3 dots in the top right corner of the Pie Charts

3 Click on Edit Chartย 

edit-chart-piechart-google-sheets

4 Click on Customize panel

5 Expand the Pie chart section.

6 Under the slice label dropdown select 'value'

slice-label-to-number

Now your pie chart looks like this.

number-piechart

Suppose you want both number and percent in a pie slice then just select "Value and Percentage" from the Slice label as shown below.

value-percent-piechart

Also read:ย Download one specific sheet from Google Sheets

Using Google Scripts to change Slice Level to number

Suppose you have generated Pie Chart using Google Apps Script or by Insert > Chart then it will not display any label.

The script for Generating Pie Chart looks like this:

function createPieChart() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];

var chart = sheet.newChart()
ย  ย  .setChartType(Charts.ChartType.PIE)
ย  ย  .addRange(sheet.getRange("F3:G10"))
ย  ย  .setPosition(5, 20, 0, 0)
ย  ย .build();
 sheet.insertChart(chart);

}

Note that F3:G10 is the value range and the setChartType() function accepts the type of the chart as a parameter. Here, we have mentioned Pie. And setPosition() will set the position of the chart and finally build() function is called which will build the piechart and then insertChart() function is called which binds the chart to the google sheet.ย 

Just insert one line as shown below

.setOption('pieSliceText', 'value')

Complete Google App Script looks like this:

function createPieChart() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];

var chart = sheet.newChart()
    .setChartType(Charts.ChartType.PIE)
    .addRange(sheet.getRange("F3:G10"))
    .setOption('pieSliceText', 'value')
    .setPosition(5, 20, 0, 0)

    .build();

sheet.insertChart(chart);
 }

How to adjust the font size of numbers in pie chart labels?

You can do the following to adjust the font size of numbers in pie chart labels:

  1. First, select the pie chart you want to adjust the font size.
  2. Click on the "Customize" tab
  3. Click on the "Slice label" dropdown under "Piechart".
  4. Select the "Custom" option
  5. You can change the font, size, and color of slice labels under "Slice label formatting"
  6. Click on "Save"

Changing this label format will affect the readability and clarity of your piechart.

Conclusion:

In this article, we explain two approaches for converting piechart percentages to numbers; nevertheless, the first method, in which we set the "pieSliceText" option to "value," is the method that I find most useful. The second one is useful if you are generating Piechart using Google Script.



ย