【发布时间】:2020-01-17 21:19:00
【问题描述】:
我有以下创建表函数,它在 Jupyter Notebook 中相应地工作,但是当我在 Dash 应用程序中调用它时,没有任何渲染。
def create_table(dataframe):
fig = go.Figure(data=[go.Table(
# header=dict(values=['A Scores', 'B Scores'],
# line_color='darkslategray',
# fill_color='lightskyblue',
# align='left'),
cells=dict(values=[dataframe.columns.values.tolist(), # 1st column
df_cohort_3.iloc[0:1].values.tolist()[0] # 2nd column
],
line_color='darkslategray',
fill_color='lightcyan',
align='left'))
])
#fig.update_layout(width=500, height=600)
return fig.show()
这是我的 Dash 逻辑:
app = dash.Dash()
app.layout = html.Div(style={'backgroundColor': colors['background']},
children=[
#Title
html.Div(html.H1(children="My Dashboard "))
#Generate Dash table
,create_table(df_1)
,
])
if __name__ == '__main__':
app.run_server(debug=False, port=3005)
有什么建议吗?
【问题讨论】:
-
您的数据框 (
df_1) 是否正确加载?也许打开debug并检查错误报告?
标签: python plotly-dash