Bharat issar
Bharat issar

Reputation: 11

How can I integrate google graphs at an AMP page?

Google provides its Javascript APIs for Google Graphs, but I cannot write any js on page as it is an AMP page

I have following solutions: Make a different non AMP page, integrate google graphs there and add an iframe of the page on my AMP page, but my page is on HTTP and google does not allows HTTP iframe link on AMP Page.

Can anyone think of any other solution?

It would be great if you could help.

Upvotes: 1

Views: 960

Answers (1)

Sebastian Benz
Sebastian Benz

Reputation: 4288

amp-iframe is the correct approach in this case. You have two options:

  1. serve the iframe from a different origin which support https, e.g. using firebase static hosting.
  2. use the srcdoc attribute to directly embed the iframe content into your AMP:

    <amp-iframe width="500" height="281" layout="responsive" sandbox="allow-scripts allow-popups" allowfullscreen frameborder="0" srcdoc="<h1>Hello</h1>"> </amp-iframe>

Upvotes: 2

Related Questions