I have built a chart which I want to embed into an HTML file. If I use plotly
online, it works as intended. However, if I use OFFLINE the offline chart works (i.e. It opens up a separate HTML chart with it in it), but it is not embedding into the HTML (nick.html) i.e. the iframe
is empty.
This is my code:
fig = dict(data=data, layout=layout)
plotly.tools.set_credentials_file(username='*****', api_key='*****')
aPlot = plotly.offline.plot(fig, config={"displayModeBar": False}, show_link=False,
filename='pandas-continuous-error-bars.html')
html_string = '''
<html>
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css">
<style>body{ margin:0 100; background:whitesmoke; }</style>
</head>
<body>
<h1>Monthly Report</h1>
<!-- *** Section 1 *** --->
<h2></h2>
<iframe width="1000" height="550" frameborder="0" seamless="seamless" scrolling="no" \
src="''' + aPlot + '''.embed?width=800&height=550"></iframe>
<p> (Insights).</p>
</body>
</html>'''
f = open("C:/Users/nicholas\Desktop/nick.html",'w')
f.write(html_string)
f.close()
Anyone know why it isn't embedding and how to fix it?