Black Lives Matter. Please consider donating to Black Girls Code today.

Offline/Python embedding plotly charts in iframe

I’m very new to programming, and Plotly as well - apologies if this is a silly mistake on my part

When creating plots as an HTML page, i can easily embed them in an iframe without issue - but this uses quite a bit of space and isn’t the desirable method/increases runtime (thousands of charts)

I attempted to plot using
somevar = plotly.offline.plot([trace], output_type='div', show_link=False, include_plotlyjs=False)
This portion works fine, and I attempt to embed it in a webpage how this gentlemen does it https://gist.github.com/jackparmer/eed4fa204650f03fe8a4 , simply by replacing pieces of a giant html string - the iframe is never able to display the charts. Ive included plotly.js from the CDN, so im unsure of whats going on. Even setting include_plotlyjs to True fails to work

Has anybody been able to use offline charting/ output=‘div’ to embed multiple charts? Do I need to extract a portion of the somevar string?

Thank you kindly for any response

very new to plotly so take with a grain of salt. I am using flask as my python back end. WhenI generate the plot with plotly I use output type=‘div’ and then save the output to a mongo document. then I just embed the div into my html using flask. The reason for mongo (any database will work) is so that I don’t reprocess the data every time I call the webpage. I basically check how old the data is and refresh every few hours.

1 Like