簡體   English   中英

圖形不更新下拉選擇 Dash Plotly python

[英]Graph not updating with dropdown selection Dash Plotly python

我正在嘗試使用虛線繪制條形圖,並且在選擇下拉列表時,無法使用下拉列表中的選定值刷新頁面。 我是 Dash 的新手。 任何幫助將不勝感激。該圖可以選擇默認值(在這種情況下為“FII”),但是當我在 Client_Type 中選擇不同的值(我有 FII、DII、Pro、Total)值時。

    df = df1[df1['Month'].isin([2,3])]
    app = dash.Dash()
    df = df1[df1['Month'].isin([2,3])]
    app = dash.Dash()
    party_data = []
    for client in df['Client_Type'].unique():
         party_data.append({'label': client, 'value': 'Client_Type'})


   app.layout = html.Div([
   dcc.Graph(id='graph'),
   dcc.Dropdown(id='client-picker',options=party_data,value= 'FII' )

])

  @app.callback(Output('graph', 'figure'),
          [Input('client-picker', 'value')])
def update_figure(abc):
df1 = df[df.Client_Type == abc]
print(df1.head())
date1 = df1['Date']
Fut_Index_Long1 = df1['Fut_Index_Long']

return {
    'data': [go.Bar(x=date1, y=Fut_Index_Long1)]
}

   if __name__ == '__main__':
app.run_server(debug=True)

我認為您的下拉列表的選項配置錯誤。 dict 中的標簽是 Dropdown 中顯示的值的名稱。 首先我會嘗試:

   for client in df['Client_Type'].unique():
             party_data.append({'label': client, 'value': client})

您可以稍后格式化的標簽。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM