使用 Dash 和 Plotly 构建仪表板
Alex Scriven
Data Scientist
一个完整的 Dash 应用:
from dash import Dash, dcc
app = Dash()
app.layout = [dcc.Graph(id='example-graph', figure=bar_fig)]
if __name__ == '__main__':
app.run(debug=True)
print("f{my_variable}")
from dash import Dash, dcc
Dash 用于初始化应用 dcc 提供图表、输入等 UI 组件
app = Dash()app.layout = [dcc.Graph( id='example-graph', figure=bar_fig)]
Dash() 创建应用对象app.layoutdcc.Graph()figure = 要渲染的 Plotly 图形id = 之后用于回调的重要标识
if __name__ == '__main__':
app.run(debug=True)
python my_app.pydebug:测试时提供反馈
通过浏览器访问,如 Google Chrome
服务运行时,更新并保存 .py 文件,可在浏览器实时查看变化



使用 Dash 和 Plotly 构建仪表板