我想创建一个 div,我想通过在仪表板中选择年份(在滑块中)来调用今年和上一年的销售额,但它给了我一个错误。我可以输出多个值吗?我做错了什么?
html.Div([
html.Div(id = 'text1'),
html.Div(id = 'text2'),
],className='create_container2 three columns')
@app.callback(Output('text1', 'children'),
Output('text2','children')
[Input('select_years', 'value')],)
def update_graph(select_years):
sales8=df.groupby(['Year'])['Sales'].sum().reset_index()
current_year = sales8[(sales8['Year'] == select_years)]['Sales'].sum()
sales9=df.groupby('Year')['Sales'].sum().reset_index()
sales9['PY']=sales9['Sales'].shift(1)
previous_year=sales9[(sales9['Year']==select_years)]['PY'].sum()
return [
html.H6(children='Current Year',id='text1',
style={'textAlign': 'center',
'color': 'white'}),
html.P('${0:,.2f}'.format(current_year),
style={'textAlign': 'center',
'color': 'black',
'fontSize': 15,
'margin-top': '-10px'}),
html.H6(children='Current Year',id='text2',
style={'textAlign': 'center',
'color': 'white'}),
html.P('${0:,.2f}'.format(previous_year),
style={'textAlign': 'center',
'color': 'black',
'fontSize': 15,
'margin-top': '-10px'}),
]