
Google Sheet 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.
Here, In the example, we are using one simple table and generated piecharts showing data of expenses and saving of income. We assume that you already know to create a pie chart. And its default generated pie charts look like this.
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 Sheet version :
1 First click on the piechart
2 Click on 3 dots on the top right corner of Pie Charts
3 Click on Edit Chart
4 Click on Customize panel
5 Expand Pie chart section.
6 Under slice label dropdown select 'value'
Now your pie chart looks like this.
Suppose you want both number and percent in a pie slice then just select "Value and Percentage" from the Slice label as shown below.
Using Google Script 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.
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 mention Pie. And setPosition() will set the position of the chart and finally build() function is called which will build piechart and then insertChart() function is called which bind the chart to the google sheet.
Just insert below one line as shown below
Complete Google App Script look 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); }