Reputation: 239
I'm creating a new Google Slide file based on template, once created I need to stop the embedded charts from updating if the source sheet changes (this is for monthly reports where the underlying will change regularly).
I'm using the Google Slides API for Google Apps Script library (thanks to Wesley Chun and Martin Hawksey) and can have got search and replace working for text.
I'm not however seeing anything in the library that would permit a change the chart properties. I can create a new chart or force a refresh.
Any help appreciated.
Upvotes: 0
Views: 1215
Reputation: 239
I've gone with the following which deletes and recreates all charts in the slides file;
for (var j in SLIDES.presentationsGet(DECK_ID).slides) {
var slide = SLIDES.presentationsGet(DECK_ID).slides[j];
for (var i in slide['pageElements']){
var obj = slide['pageElements'][i];
if (obj['sheetsChart']) {
// delete it and recreate as static image
var reqs = [
{'deleteObject': {'objectId': obj['objectId']}},
{'createSheetsChart': {
'spreadsheetId' : obj["sheetsChart"]["spreadsheetId"],
'chartId' : obj["sheetsChart"]["chartId"],
'elementProperties' : {
'pageObjectId': slide['objectId'],
'size' : obj["size"],
'transform' : obj["transform"],
}
}
}
];
SLIDES.presentationsBatchUpdate(DECK_ID, {'requests': reqs})
}
}
Upvotes: 0
Reputation: 598
There isn't API support for unlinking an existing chart to prevent users from refreshing it. Your best bet is likely to delete the chart and recreate it in your final presentation. You should be able to get the chart ID, spreadsheet ID and page element transform off of a presentation.get()
or presentation.pages.get()
and use that to reinsert the chart to preserve the position and content.
Upvotes: 1