When using the getCharts() method of a Google Sheet instance, no charts are returned. This seems to be caused by the chart being a combo chart (rather than a more basic column, bar or pie chart). I modified the chart to be a column chart and getCharts() worked...returning a chart.
I can't find any confirmation that combo charts are completely ignored by the Spreadsheet App Script API.
Does anyone know of any SO questions, forum posts or official documentation that clarifies support (or lack thereof) for combo charts?
While there is no ComboChartBuilder for the Sheet class, I was hoping for something a little more explicit than the absence of a ComboChartBuilder. I would have thought getCharts() should return a Chart even if it's not modifiable.
There isn't a way to get a chart that isnt possible to build with apps script. You already found out the 'builder' class is missing.
There isnt a list of the unsupported ones, just the list of charts you can build with gas which are the sames you can get.
Related
In this Google Sheets workbook, I have conditional formatting based on checkboxes. I'd like to create a pie chart that will update based on the user-input data (boolean yielded from the checkbox data validation).
Here's a link if you'd like to tinker with it directly.
In the sheet, there are three questions, and the user checks a box to indicate their response. The responses trigger a yellow warning, then orange warning, then red warning color formatted across the row.
I'd like to create a chart in the workbook for a quick glance at the user's "health," with all the unformatted rows (enumerated by the user in the Number column) showing green, and the yellow/orange/red updating respectively.
I've been pulling data from the Number, Q1, Q1, and Q3 columns for this chart and pulling my hair out trying to graph it properly.
In an answer to a similar question, one of the only responses was from a user saying we'd need to script for this function.
Does anyone here know the necessary scripting? Would it be in Sheets API or Google Apps Script?
Thanks!
I sorted it out with a much easier fix!
You'll see in the workbook a chart now, on the "Health" sheet. I made a little data pull counting the boolean results and used that to format.
Dear Brain, we don't always need to complicate things.
Simplify, and simplify again.
Thanks!
I want to write a Apps Script in Google Sheets that pulls data from a sheet and uses the conditional formatting of cells to colour the corresponding columns in a columns chart. This is easy to do in Sheets itself: once you've created the column chart you can just double-click on a individual column and then modify the format (or go to the Chart Editor, Customize, Series, Format then "Format data point). However, it seems to be missing from the chart configuration options: https://developers.google.com/apps-script/chart-configuration-options?hl=en#column-config-options
Am I correct that this is a missing option? If so, is there some way I could work around this?
Answer:
In spreadsheet embedded charts, it is not possible to specify the color for a specific column programmatically.
Reference:
Here is the list of methods for building and customizing a column chart: EmbeddedColumnChartBuilder. It doesn't include any method for this. setColors(cssValues) simply modifies the color of all columns in the chart, using the first value in the provided array.
This doesn't seem to be accessible in Sheets API either (see ChartSpec).
File a feature request:
If you think this functionality could be useful, I'd suggest you to request it in Issue Tracker using this template.
Simply, I have created a chart by inserting a chart and adding range/settings etc.
But I have realised that when resizing the chart (by recording a macro) all the settings are lost.
Is there a way to convert the Google Sheets Chart into Google Apps Script, otherwise I think I will have to re-create the graph in Google Apps Script. Just hoping to save some time with this query.
Thank you in advance.
I understood that you want to create a graph in Apps Script in a similar way that you did in a Sheet. If I understood it right, then you can complete your aim by using Charts Service. You can see a full example in the linked documentation.
Just to clarify it, first you would need to create a table using DataTableBuilder. This table should be equal to the one in your Sheet. After that you can create a graph based on that table. Please, ask me any question if you still have doubts.
I have a Google spreadsheet that contains charts which are properly displayed. When I am using a GAS to copy these charts to a Google document some of the charts are properly displayed in the document while others (which are displayed properly in the spreadsheet) are displaying the message "All series on a given axis must be of the same data type".
Since these are working charts I am not sure why I get this message. Is there a workaround to this problem or a known issue?
Any advise will help.
Thx!
Based on KRR answer. Even though the chart might be working in Google spreadsheet it appears that the getBlob of the chart rechecks the source values of the chart. You need to make sure that the source values (in my case above from a spreadsheet) all have the same data type.
I have created a UI web app in google apps script which access a database in a spreadsheet, manipulates the data and then puts it into a chart. Now my problem is that I get get the chart to be displayed back into the Ui. I don't even know if that is a possibility, but something along those lines. This is what i have tried thus far:
First I created a chart in the doGet function and then tried to
access and edit after i took in some info from the user. The problem
was that when i .build() the chart it become a generic object and
cannot be edited.
Second I tried to .add the chart to the Ui after taking in info, but
i could not get the ui to update. again i don't know the right way
to do this.
Let me know if you need any additional info.
In order for the UI to update you need to ensure that you return the application (UiInstance) in the handler function.