Created
May 31, 2023 12:26
-
-
Save franzenzenhofer/f73d79df63a708bb1e6db300a6d87365 to your computer and use it in GitHub Desktop.
GSC Devices Bar Chart
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function generateCharts() { | |
// Access the sheet | |
var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Devices'); | |
// Sort Column A | |
sheet.getRange('A2:E4').sort(1); | |
// Get the range for your data | |
var dataRange = sheet.getRange('A1:E4'); | |
// Create a pie chart for Clicks | |
var pieChartBuilder = sheet.newChart(); | |
pieChartBuilder.addRange(dataRange) | |
.setChartType(Charts.ChartType.PIE) | |
.setOption('title', 'Clicks per Device') | |
.setPosition(5, 6, 0, 0) | |
.setOption('sliceVisibilityThreshold', 0) // Ensures that all slices are shown | |
.asPieChart(); | |
sheet.insertChart(pieChartBuilder.build()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment