繁体   English   中英

如何将交互式仪表板应用程序导出到 html 独立文件中以将其嵌入您的网站?

[英]How to export an interactive dashboard app into a html standalone file to embed it to your website?

所以我在 python 中使用 plotly 制作了一个交互式仪表板。 我部署了应用程序并将可视化图转换为 static html 文件。 但是,如果我也想嵌入包括非静态组件在内的整个仪表板怎么办。 我的目标是开发一个简单的交互式仪表板,它将 csv 作为输入,并以文本中的几行可视化数据,以后可以将其作为一个整体嵌入到预先存在的 xml/html 页面中。像这样: 在此处输入图像描述

我使用回调为最终用户提供了一些交互式过滤器:

@app.callback(
Output(component_id='release_choice', component_property='options'),
[Input(component_id='Tech_choice', component_property='value')])

def get_options(Tech_choice):
    dff = df[df.Technology == Tech_choice]
    return [{'label': i, 'value': i} for i in dff['SystemRelease'].unique()]

@app.callback(
    Output(component_id='release_choice', component_property='value'),
    [Input(component_id='release_choice', component_property='options')])
def get_values(release_choice):
    return [k['value'] for k in release_choice][1]

@app.callback(
    [Output(component_id='date_choice', component_property='start_date'),
    Output(component_id='date_choice', component_property='end_date')],
    [Input(component_id='release_choice', component_property='value')])
def get_options(date_choice):
    dff = df[df.date2 == date_choice]
    return [{'label': i, 'value': i} for i in dff['date2']]


@app.callback(Output(component_id='my-graph', component_property='figure'),
              [Input(component_id='release_choice', component_property='value'),
              Input(component_id='Tech_choice', component_property='value'),
              Input(component_id='date_choice', component_property='start_date'),
              Input(component_id='date_choice', component_property='end_date')], )

我使用 pandas 和 plotly 做了一个类似的破折号,如下所示:
在此处输入图像描述

我使用 fig.write_image 来获取 html 文件,但它再次只是 static。 那么你的建议是什么? 我认为 plotly 不会做预期的工作。 我还能在 python 中使用什么?

您可以使用 html 的 iframe 标签:

 <iframe src="https://www.w3schools.com" title="W3Schools Free Online Web Tutorials"></iframe>

只需将“src”替换为您网站的 URL,这样您的 plotly 网站就会嵌入到任何其他 HTML 页面中。 动态元素仍然有效。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM