我想在我自己的html文件中嵌入绘图。 使用Dash,我可以在API本地服务器中生成相同的图。在
但是对于我自己的HTML文件,我没有得到任何解决方案:
我的Dash解决方案:
import dash
import dash_core_components as dcc
import dash_html_components as html
app = dash.Dash()
app.layout = html.Div(children=[
html.H1(children='Dash Tutorials'),
dcc.Graph(
id='example',
figure={
'data': [
{'x': [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], 'y': [9, 6, 2, 1, 5, 4, 6, 8, 1, 3], 'type': 'bar', 'name': 'Boats'},
{'x': [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], 'y': [19, 36, 12, 1, 35, 4, 6, 8, 1, 3], 'type': 'bar', 'name': 'Cars'},
],
'layout': {
'title': 'Basic graph'
}
})
])
if __name__ == '__main__':
app.run_server(debug=True)
如何通过绘图生成相同的图形嵌入到我自己的html中?在
只需遵循以下两个步骤:
1-生成(通过python)嵌入html文件的代码
你会得到:
^{pr2}$2-将生成的代码嵌入html文件中
相关问题 更多 >
编程相关推荐