Adding a line chart to a spreadsheet with a specific set-up of headers and rows

61 views
Skip to first unread message

Michał Fiech

unread,
Sep 11, 2020, 5:20:40 AM9/11/20
to Google Apps Script Community
Hey there,

I'm struggling with that for a couple of days already. I've coded a script for a spreadsheet that automates the experiment analysis via Apps Scripts connected to Google Analytics API.

The last thing I want to add is a chart based on the spreadsheet cells that the script output.
I managed to insert a blank chart to the spreadsheet and even added some ranges I'd interested in, but I couldn't find any reference on how to use Apps Scripts spreadsheet chart-related methods to achieve something like below:



Could anyone here help me how to achieve this based on the screenshot above?
Either a sample code, or pointing out to some examples/code references that will output the above chart will be much appreciated!
Note: Here I don't care that much about the styling, colors, titles, labels placement, etc., this I'll handle. It's about the chart setup and axis.
Screenshot 2020-09-11 at 11.18.37.png

Martin Hawksey

unread,
Sep 11, 2020, 6:53:06 AM9/11/20
to google-apps-sc...@googlegroups.com
Hi Michal,

I think you might find this episode of Sheets to Apps useful https://pulse.appsscript.info/p/2020/08/how-to-build-a-google-analytics-dashboard-with-apps-script-and-google-sites-sheets-to-apps/ - basically you can use the MAcro Recorder to record your actions for creating a chart which generates some Apps Script code you can modify/reuse

Hope that helps
Martin

--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/fc60b0c9-eb6f-40ff-b94d-cbb36f8ed355o%40googlegroups.com.


--
Martin Hawksey

Latest tweet (see how):

Google Apps Script is a great tool for programmers of all levels to explore new ideas. @mhawksey shares how Apps Script has removed barriers in education by easing administrative duties, allowing teachers more time to focus on students.

Learn more → https://t.co/HGgCjTgMuK pic.twitter.com/MFwEO9GZV0

— G Suite Developers (@GSuiteDevs) August 10, 2020

michal...@volders.de

unread,
Sep 11, 2020, 6:59:18 AM9/11/20
to Google Apps Script Community
Hey Martin,

wow! I had no idea there's a Record Macro feature, that then can be displayed as a script. That's amazing.
I'll jump right into debugging the recorded script.

Thanks!

Kim Nilsson

unread,
Sep 13, 2020, 1:30:20 PM9/13/20
to Google Apps Script Community
@Michal, please post back here with an example of your code, so the rest of use can learn what you do.

Users generally struggle when creating diagrams, so if I could give them a script that'd do it for them, I think they'd appreciate it. :-)
Reply all
Reply to author
Forward
0 new messages