Reputation: 1
I use a function to update charts in my presentation. This presentation needs to be shared, but will also be updated periodically. Now, I copy the presentation to keep the original presentation for updates, and unlink all charts one-by-one. I am searching for a function that will unlink all charts once I copied the presentation to be able to share it.
Is there a function that will solve this issue?
function createRefreshSheetsChartsRequests(presentation) { var objectIds = []; var slides = presentation.slides;
for (var i = 6; i < slides.length - slides.length + 9; i++) {
var slide = slides[i];
var pageElements = slide.pageElements;
for (var j = 0; j < pageElements.length; j++) {
var pageElement = pageElements[j];
if (pageElement.sheetsChart) {
objectIds.push(pageElement.objectId);
}
}
}
return objectIds.map(function(objectId) {
return {refreshSheetsChart: {objectId: objectId}};
});
}
Upvotes: 0
Views: 3479
Reputation: 11
Simple. Download Google Presentation as a PowerPoint. Don't even bother opening in with PowerPoint - just re-upload it again to your Google Drive. Same Google Presentation re-appears, but WITHOUT the links. Beautiful
Upvotes: 1
Reputation: 598
There's no API to unlink a chart in the Slides API. You have a few options though:
Delete the chart and reinsert as an image. You can do this either with CreateSheetsChartRequest with LinkingMode.NOT_LINKED_IMAGE
or with CreateImageRequest using the URL you get from the GET APIs in the SheetsChart.content_url
field. You'll have to take care that the new chart is positioned and sized to match the existing one.
Update the sharing permissions on the spreadsheet the chart came from. If the user you share the presentation with doesn't have read access to the underlying spreadsheet, they cannot refresh the chart in Slides, so can't see the new data.
If you're interested in an unlink API, you can file a feature request here.
Upvotes: 1