0

I have a google doc that I show inside an iframe in my website for public editing, it contains linked charts from a public spreadsheet,

I change the chart data with spreadsheet api, but the chart in the doc does not refresh automatically, and I can't clic update or update all in the doc because the "update button" is disabled,

SO I wanted to use google docs api or apps script to refresh charts, I did not find how to do it with google docs api, and apps script does not trigger inside the iframe,

Can you please give me any idea how to do this, Thank you.

1 Answer 1

0

Unfortunately there is no way to refresh charts programatically in a Google Document. You should definitely submit a feature request for SheetsChart support as there is in Google Slide App Script Service.

Workaround with Slides

Since the update feature is currently available for Slides you could achieve to style a Slide as a document and use it in your iFrame. Following this update logic you will be able to trigger a SheetsChart refresh every minute for example:

function myFunction() {
  ScriptApp.newTrigger('updateCharts').timeBased().everyMinutes(1).create();
}

function updateCharts() {
  let slides = SlidesApp.getActivePresentation().getSlides();
  slides.forEach(slide => {
                 let charts = slide.getSheetsCharts();
                 charts.forEach(chart=> chart.refresh());
                 });
}

Workaround with Documents

However, since your goal is to provide your website viewers with the last version of the iFrame this can be done automatically on Document save:

File > Publish on the Web > check Automatically republish when changes are made

You will have to update manually the chart in your Document though. But this change will be reflected in your webpage automatically.

Sign up to request clarification or add additional context in comments.

2 Comments

Thank you for your suggestion, Actually I don't update the charts data manually, I do it through google spreadsheet API triggered by the client's click, that's why I needed to refresh the linked charts in the doc automatically
Then there is no way to update a chart in a document automatically it at the moment. You could use a Google Slide App though, I think that if you style it properly you will achieve the same results.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.