I've got a Google line chart, and I'd like to hide the X axis values
Changes need to be in JSON (got no clue), and anything I've tried from the Google KB returned error
Thanks
Related
I am trying to use an if formula in a data validation drop-down list in Google Sheets. It clearly shows that formulas are acceptable, but everytime I try, I get an error that says it's not a valid range. Is my syntax incorrect, or is this even possible?
Here is the code:
=if($I$1$="Hour(s)",code!$A$2:$A$24,code!$B$2:$B7)
Image of the problem
This is my first question here, though I've had some helpful guidance from lots of questions before. I hope I don't miss anything important in this question.
I am currently writing a script in Google Apps Script to send some charts from a Google Sheets document by email, as images. My issue is that with Combined Charts, when I try to read them and get them as images, I get an error.
I've reduced the code to the minimum that will still throw the error I'm talking about.
function test_chart_fails(){
let gdoc_id = "xxxxxxxxxxxx";
let sheet_name = "test2";
let document = SpreadsheetApp.openById(gdoc_id);
let sheet = document.getSheetByName(sheet_name);
let charts = sheet.getCharts();
let chart = charts[2];
let inLineImages = {};
inLineImages["chartC"] = chart.getAs('image/png');
}
I get the following error:
Exception: Service Spreadsheets failed while accessing document with id xxxxxxxxxxxxxxxxxxxxxxxxxx.
test_chart_fails # AppsScriptFile.gs:305
Where 305 is the last line of my sample code (the one with 'chart.getAs').
Now some additional info that may be relevant (or not):
The sheet in question has 9 charts in total. I get this error if I try to access 7 of the 9, which are only the combined charts. Other charts will work fine, and I can put them in an email sent through MailApp. All the charts were created manually in the Gsheets document.
Regarding the data in the sheet that builds the charts, the sheet has 103 rows and 44 columns. All data in the sheet is formulas, not values.
I've searched for existing questions in this and other sites where this error message appears, but I didn't find a question where the error was related to Chart retrieval - specifically no instance related to Combo Charts. One instance mentioned an error related to the sheet size, so I mentioned the data size (rows x columns), but I don't think that is the issue - because the script runs fine for non-Combo Charts based on the same dataset.
Is this expected for combined charts? Is there a way I can 'retrieve' them and send them in an email like I do the others?
This appears to be a bug
https://issuetracker.google.com/182701055
SpreadsheetApp.getActive().getSheetByName().getCharts().getAs() returns this error: "Service Spreadsheets failed while accessing document with id" ... when the line chart has a right vertical axis
I would encourage you to go and star this issue to let Google know that it affects you and to subscribe to updates.
You are also encouraged to post any further reproduction steps and workarounds there if they haven't been mentioned yet.
Workaround you mentioned
How to obtain a correct image of a ComboChart with Google App Script?
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.
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.
My goal is to retrieve the 13 last data logged to a Google Spreadsheet through a Google Form and to display them in a Chart on a Google Site.
To do so, I created a Google Script associated with the Google Spreadsheet which reads the last 13 rows of the Spreadsheet and create a new chart based on them. Then I have embedded the chart on my Google Site with Live Mode.
When I enter a new value through the form, the chart created by the script on the Spreadsheet is correctly updated and show 13 values. But the version embedded on the Google Site adds the new value to the range without hiding the 14th thus showing 14 ones (and as more values as I enter afterwards).
To fix the issue, I retrieve the Google Site in the script and every time delete the previous chart and embed the new chart generated by the Google Spreadsheet. However the SitesApps does not seem to enable to retrieve and manage the Chart object easily.
My questions are:
- Do you see an easier way to do what I currently what to do ?
- Do you know a way to retrieve and manage the Chart Object embedded in a Google Site through Google Script ?
What I want to do looks like that :
var site = SitesApp.getSiteByUrl('siteUrl');
var page = Site.getChildByName('home');
var chart = page.getHtmlContent(). ??? Function to get the Chart object ???
Thanks in advance for your help.
Not really. You'll have to search for the text you want to replace in the HTML content. What you could do instead, though, is make a UiApp gadget that generates the charts whenever it's loaded.