У меня проблема с загрузкой таблицы данных da sh при выборе выпадающего списка. Диаграмма может загружаться, но не имеет данных da sh. Там не выдается ошибка. Кто-нибудь сможет помочь посоветовать в чем здесь ошибка? Заранее спасибо.
Ниже приведены фрагменты кода
'' 'server = flask. Flask ( name ) app = da sh .Da sh ( имя , сервер = сервер)
# Populate the layout with HTML and graph components
app.layout = html.Div([
html.H5("SALES Report"),
#Drop Down
html.Div(
[
dcc.Dropdown(
id="SALESRange",
options=[{
'label': i,
'value': i
} for i in SALES_Range_Options],
value='All SALES Range'
)
],
style={'width': '25%',
'display': 'inline-block'}),
#CHART
html.Div([dcc.Graph(id='summarybargraph') ]),
#TABLE
html.H6("Details list"),
html.Div([
dash_table.DataTable(id='detailsresults') ]),
])
# Add the callbacks to support the interactive componets
@app.callback(
Output('summarybargraph', 'figure'),
[Input('SALESRange', 'value')])
def generate_graph(SALESRange):
if SALESRange == "All SALES Range" :
df_plot = SALES_Range_CAT_df.copy()
else:
df_plot = SALES_Range_CAT_df[SALES_Range_CAT_df['SALES_RANGE'] == SALESRange]
trace1 = go.Bar(x=df_plot['SALES_RANGE'],
y=df_plot['Patron_count'],
name='No of Patrons',
text =df_plot['Patron_count'],
#textposition='auto',
#marker_color=colors # marker color can be a single color value or an iterable
)
return {
'data': [trace1],
'layout':
go.Layout(
title='SALES Range for {}'.format(SALESRange)
)
}
def generate_table(dataframe):
'''Given dataframe, return template generated using Dash components
'''
return html.Div( [dash_table.DataTable(
#id='match-results',
data=dataframe.to_dict('records'),
columns=[{"name": i, "id": i} for i in dataframe.columns],
style_header={'backgroundColor': "#FFD700",
'fontWeight': 'bold',
'textAlign': 'center',},
style_table={'overflowX': 'scroll'},
style_cell={'minWidth': '180px', 'width': '180px',
'maxWidth': '180px','whiteSpace': 'normal'},
row_selectable="multi"),
html.Hr()
])
@app.callback(
Output('detailsresults', 'data'),
[
Input('SALESRange', 'value'),
]
)
def load_results(SALESRange):
results = GR_df[GR_df['SALES_RANGE'] == SALESRange]
return generate_table(results)
if __name__ == '__main__':
app.run_server(debug=False)
'' '