python - 如何在 dash/plotly 中使用 iframe? ( python /HTML)

标签 python html iframe dashboard plotly-dash

我正在创建一个仪表板,我想使用这个交互式 map

网页链接:https://www.ons.gov.uk/peoplepopulationandcommunity/healthandsocialcare/causesofdeath/articles/deathsinvolvingcovid19interactivemap/2020-06-12

嵌入代码: <iframe height="1043px" width="100%" src="https://www.ons.gov.uk/visualisations/dvc914/map/index.html"></iframe>

现在我不太了解 HTML,但这就是我目前所了解的。我知道布局是错误的,但我已经被困了很长一段时间,谁能指出我正确的方向。非常感谢!

import dash
import dash_core_components as dcc
import dash_html_components as html
import plotly.express as px
import pandas as pd
from dash.dependencies import Input, Output

external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css']

app = dash.Dash(__name__, external_stylesheets=external_stylesheets)


#H1 = biggest heading,  Div = a box containhg info
app.layout = html.Div(children=[
    html.H1(children='Hello Dash'),

    html.Div(children='''
        Dash: A web application framework for Python.
    '''),

    dcc.Graph(
        id='example-graph',
        figure=fig
        
    <iframe height="1067px" width="100%" src="https://www.ons.gov.uk/visualisations/dvc914/map/index.html"></iframe>
    )
])

if __name__ == '__main__':
    app.run_server(debug=True,port=8049,host='127.0.0.1')

最佳答案

你快到了。只需将 iframe 元素的 <> 语法替换为您用于其他元素的破折号语法,

import dash
import dash_core_components as dcc
import dash_html_components as html

external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css']
app = dash.Dash(__name__, external_stylesheets=external_stylesheets)

app.layout = html.Div(children=[
    html.H1(children='Hello Dash'),

    html.Div(children='''
        Dash: A web application framework for Python.
    '''),

    dcc.Graph(
        id='example-graph',
        # figure=fig  # commented out to make the example runnable
    ),

    html.Iframe(src="https://www.ons.gov.uk/visualisations/dvc914/map/index.html",
                style={"height": "1067px", "width": "100%"})
])

if __name__ == '__main__':
    app.run_server(debug=True, port=8049, host='127.0.0.1')

关于python - 如何在 dash/plotly 中使用 iframe? ( python /HTML),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64736956/

相关文章:

python - Cuda 错误消息 : F ./tensorflow/core/util/cuda_launch_config.h :127] Check failed: work_element_count > 0 (0 vs. 0)

javascript - 下拉菜单没有反应

python - 为什么我的代码实际上什么也做不了?

处理导入错误的 Pythonic 方式

javascript - 在 ContentEditable Div 中创建链接

php - fancybox:打开外部子页面加载其后面的父页面

javascript - 计算 iframe 上的点击次数

javascript - 需要检测何时在 iframe 中按下按钮,JavaScript

python - 从列表中解压的类继承

html - 如何让 SVG 中的 <image> 改变颜色?