Apps Developer Blog

Information for Google Apps Developers

Programmatically Managing Charts in Spreadsheets

June 19, 2012
Share on Google+ Share on Twitter Share on Facebook
Google
Labels: Apps Script , Guest Post

14 comments :

Blackfireshocker said...

Been waiting for a feature like this to match Excel's Dynamic Charts for a while now. Thanks Google!

June 20, 2012 at 9:01 AM
Michael said...

This is awesome, and the first example sounds like you've been reading my own personal spreadsheets. :-)

Wouldn't it be easier if we could define ranges like A2:B in charts like we can in the rest of the spreadsheet? Any chance that's next on your 20% list, Kevin?

June 20, 2012 at 10:44 AM
Magnus Kwan said...

Couldn't find the reference for function getSheetValues() in rangeShouldExpand_();

Should that be the second getRange() in https://developers.google.com/apps-script/class_sheet#getRange ?

June 20, 2012 at 5:44 PM
It Combine said...

This is awesome... thankx google.


Converage Integrated Media Solutions

June 21, 2012 at 4:32 AM
Kevin said...

@Michael - as a warmup exercise, I actually made it possible to pass a Range object (from a Sheet) to the Chart Builder setDataTable method (this isn't very well documented). However, this simply copies the current data from the range to use as a DataTable - it won't update as the sheet's data changes. If you want that, you can either use an EmbeddedChart or set a datasourceUrl instead of a DataTable/Range: https://developers.google.com/chart/interactive/docs/spreadsheets

@Magnus Kwan, you're right, that should be getRange(...).getValues() instead of getSheetValues(...) - good catch.

June 21, 2012 at 6:21 AM
rosek said...

Thanks guys! I've been waiting over a year for this feature!

June 24, 2012 at 4:43 AM
Nathan said...

This is the perfect solution for a project that just came up. This will eliminate the need for any other external software or resources.

I do have a question though. It appears that you can't access a chart that has been moved into it's own sheet. I've tried accessing them by name, etc, but it appears they don't show up in the sheet list.

I've got 2 "normal" sheets and 4 charts in their own sheets for a total of 6 sheets. However, if I do:

SpreadsheetApp.getActiveSpreadsheet().getNumSheets(); returns 2, not 6.

So, it appears that charts in their own sheet aren't accessible, or am I missing something obvious?

Thanks for the fantastic updates!

July 1, 2012 at 2:12 PM
Kevin said...

Hi Nathan,
I'm sorry that doesn't work yet - those special sheets aren't exposed. It'll take some work to get them exposed properly (so that you can create, delete, etc them instead of just editing the chart) - I'll see what we can do.

July 2, 2012 at 7:58 AM
Nathan said...

Thanks Kevin, at least I know I'm not totally botching something.

I'll play around with it a bit, I'm sure I can figure out some sort of a workaround. I'm thinking I'll look at the configuration of each chart by copying it and then trying to duplicate it with this new API.

If I can do that, then I'll just create an actual sheet and embed the chart in it, instead of moving it to it's own sheet.

Thanks again!

July 2, 2012 at 2:51 PM
Guillermo Ermel said...

Hi Kevin! Is there a way to set DataTable Rolse roles (as in https://developers.google.com/chart/interactive/docs/roles#assigningarole). The goal is to have decent error bars coming from a cell value (min/max)...

Best,
Guillermo

September 25, 2012 at 9:43 AM
Valentina said...

Hi Kevin, this has been very usefull in my proyect but I'm having a problem, I'm traying to graph more than 30 arrows but it only shows 20 in the graphic. It has something to do with the code??

Thanks

March 25, 2013 at 8:23 PM
Valentina said...

Hi Kevin, this has been very usefull in my proyect, but I'm having a problem, I'm traying to graph more than 30 rows but in the graphic it shows 20 only, Is it have something to do with the code?

Thanks

March 25, 2013 at 8:26 PM
Qiang said...

Hi Kevin,
Does any way for use Spreadsheet charts from gae Spreadsheet api?


Thanks

September 3, 2013 at 3:04 AM
Alessandro Iacopetti said...

how do you build a chart with 2 series, one on the left vertical axis and one on the right vertical axis?
i just can't find any option for that, even though you can easily build it with the gui.

September 22, 2013 at 2:41 AM

Post a Comment

  

Labels


  • .NET 3
  • #io15 1
  • Admin SDK 4
  • Administrative APIs 26
  • AdSense 1
  • analytics 4
  • Android 5
  • App Engine 5
  • Apps Script 98
  • Auth 1
  • billing 4
  • Charts 1
  • Chrome OS 1
  • classroom 1
  • Cloud Storage API 1
  • Community 1
  • Developers 5
  • Directory API 1
  • Drive 2
  • Drive SDK 38
  • execution API 1
  • Firebase 1
  • Freemium 1
  • Fusion Tables 2
  • Gadgets 5
  • Gmail APIs 16
  • Google APIs 3
  • Google Apps 3
  • Google Apps Directory API 1
  • Google Apps Marketplace 3
  • Google Apps Script 1
  • Google Calendar API 20
  • Google Contacts API 3
  • Google Data Protocol 7
  • google docs 3
  • Google Docs API 20
  • Google Drive 2
  • Google Forms 4
  • Google I/O 3
  • Google Prediction API 3
  • Google Profiles API 2
  • Google sheets 2
  • Google Sites API 4
  • Google Spreadsheets API 4
  • Google Talk 1
  • Google Tasks API 6
  • Google+ 3
  • googlenew 1
  • Groups 2
  • Guest Post 42
  • ISVs 2
  • java 1
  • JavaScript 3
  • marketing 3
  • Marketplace 47
  • Marketplace ISV Guest 21
  • Migration 1
  • Mobile 1
  • mpstaffpick 1
  • oauth 11
  • OpenID 7
  • PHP 1
  • python 4
  • realtime API 1
  • Resellers 2
  • Ruby 1
  • SaaS 1
  • security 1
  • Staff Picks 2
  • webinar 2


Archive


  •     2015
    • Oct
    • Sep
    • Aug
    • Jul
    • Jun
    • May
    • Apr
    • Mar
    • Feb
  •     2014
    • Dec
    • Oct
    • Sep
    • Aug
    • Jul
    • Jun
    • May
    • Mar
    • Feb
    • Jan
  •     2013
    • Dec
    • Nov
    • Oct
    • Sep
    • Aug
    • Jul
    • Jun
    • May
    • Apr
    • Mar
    • Feb
    • Jan
  •     2012
    • Dec
    • Nov
    • Oct
    • Sep
    • Aug
    • Jul
    • Jun
    • May
    • Apr
    • Mar
    • Feb
    • Jan
  •     2011
    • Dec
    • Nov
    • Oct
    • Sep
    • Aug
    • Jul
    • Jun
    • May
    • Apr
    • Mar
    • Feb
    • Jan
  •     2010
    • Dec
    • Nov
    • Oct
    • Sep
    • Aug
    • Jul
    • Jun
    • May
    • Apr
    • Mar
    • Feb

Feed

Company-wide

  • Official Google Blog
  • Public Policy Blog
  • Student Blog

Products

  • Android Blog
  • Chrome Blog
  • Lat Long Blog

Developers

  • Developers Blog
  • Ads Developer Blog
  • Android Developers Blog
  • Google
  • Privacy
  • Terms