I’m trying to plot a different graph for each option selected in the Dropdown (The options correspond to the Dataframe columns) when I run the code the graph appears empty… where am I going wrong?
My code:
opcoes = df[['Rnd','ACS','K:D','KAST','ADR','KPR','APR','FKPR','FDPR','HS%','CL%','CL','KMax','K','D','A','FK','FD']].columns.values
app.layout = html.Div(children=[
html.H5('Opcões'),
dcc.Dropdown(opcoes, value = 'ACS' , id='check_opcao'),
dcc.Graph( id='grafico_gc_players')
])
@app.callback(
Output('grafico_gc_players', 'figure'),
[
Input('check_opcao', 'value'),
])
def renderizar_graficos(check_opcao):
if check_opcao == 'ACS':
fig = px.bar(df.nlargest(10, ['Rnd','ACS','K:D','KAST','ADR','KPR','APR','FKPR','FDPR','HS%','CL%','KMax','K','D','A','FK','FD']), x='Player', y= check_opcao, title='Top 10 jogadores em: ' + check_opcao, color='Player', barmode = 'stack',
labels={
'Player': 'Nome e Time',
'ACS': 'ACS'}, template='plotly_dark', text='ACS')
elif check_opcao == 'HS%':
# #tabela_filtrada = df.loc[df['Colunas'] == value,:]
fig = px.scatter(df, x="Player", y= check_opcao, title='Os 10 Jogadores com a maior taxa de HS e seu KD no Valorant Champions:',
color="Player",
labels={
'Player': 'Jogador',
'HS%': 'HS%'}, size='ACS',
hover_data=['Player'] , template='plotly_dark', text='HS%')
# elif check_opcao == 'HS%':
# fig_hs = px.scatter(df.nlargest(10, ['Rnd','ACS','K:D','KAST','ADR','KPR','APR','FKPR','FDPR','HS%','CL%','KMax','K','D','A','FK','FD']), x="Player", y=check_opcao, title='Os 10 Jogadores com a maior taxa de HS e seu KD no Valorant Champions:',
# color="K:D",
# labels={
# 'Player': 'Jogador',
# 'HS%': 'HS%'}, size='ACS',
# hover_data=['Player'] , template='plotly_dark', text='HS%')
else :
fig = px.bar(df.nlargest(10, ['Rnd','ACS','K:D','KAST','ADR','KPR','APR','FKPR','FDPR','HS%','CL%','KMax','K','D','A','FK','FD']), x='Player', y= check_opcao, color= check_opcao, title='Top 10 jogadores em: ' + check_opcao, barmode = 'stack',
labels={
'Player': 'Nome e Time'}, text= check_opcao, template='plotly_dark')
return fig