Including html plotly graphs in dash app

Thank you a lot Emmanuelle for the real quick and helpful answer! I feel indeed very welcome.

I tried to use nedned’s example that works just fine for embedding youtube videos:

import dash
import dash_html_components as html

app = dash.Dash()
app.layout = html.Div([
    html.Iframe(id='target',
                src='https://www.youtube.com/embed/sea2K4AuPOk')
    ])

if __name__ == '__main__':
    app.run_server(debug=True)

But when I try to display the locally saved html, i just get an empty Frame:

import dash
import dash_html_components as html


app = dash.Dash()
app.layout = html.Div([
    html.Iframe(id='target',
                src='D:/some_directory/plotly_figure.html')
    ])

if __name__ == '__main__':
    app.run_server(debug=True)

So I am not sure if the answer works for html figures. Is there another solution?

BTW:
What I mean by “html figures” are figures that are created by Plotly:

import plotly.graph_objects as go
import numpy as np
import plotly.offline as py

x = np.arange(10)
figure = go.Figure(data=go.Scatter(x=x, y=x**2))
py.plot(figure, filename='D:/some_directory/plotly_figure.html')

I dont want to display a “static” image, but one where the user of the webapp can zoom into the figure etc.

1 Like