Python 绘声绘色的仪表盘显示在jupyter笔记本中,但不显示在仪表盘应用程序中?

Python 绘声绘色的仪表盘显示在jupyter笔记本中,但不显示在仪表盘应用程序中?,python,plotly-dash,Python,Plotly Dash,我有下面的createtable函数,它在Jupyter笔记本中也可以相应地工作,但是当我在Dash应用程序中调用它时,什么都不会呈现 def create_table(dataframe): fig = go.Figure(data=[go.Table( # header=dict(values=['A Scores', 'B Scores'], # line_color='darkslategray', # fi

我有下面的createtable函数,它在Jupyter笔记本中也可以相应地工作,但是当我在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()
以下是我的破折号逻辑:

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)

有什么建议吗

仪表板应用程序不要使用fig.show()。它使用fig对象生成显示。您不需要调用.show()方法

然后:

import dash_core_components as dcc
app = dash.Dash()

app.layout = html.Div(style={'backgroundColor': colors['background']},
children=[

    #Title
    html.Div(html.H1(children="My Dashboard "))

    #Generate Dash table

    ,dcc.Graph(figure=fig),


    ,

                    ])

if __name__ == '__main__':
    app.run_server(debug=False, port=3005)
您的数据帧(
df_1
)是否正确加载?也许打开
debug
并检查错误报告?
import dash_core_components as dcc
app = dash.Dash()

app.layout = html.Div(style={'backgroundColor': colors['background']},
children=[

    #Title
    html.Div(html.H1(children="My Dashboard "))

    #Generate Dash table

    ,dcc.Graph(figure=fig),


    ,

                    ])

if __name__ == '__main__':
    app.run_server(debug=False, port=3005)