From e5adcc4955b5ff526eaab65cf0c8b836b53a5c4b Mon Sep 17 00:00:00 2001 From: Oesterd Date: Sun, 3 Mar 2024 19:48:01 -0300 Subject: [PATCH] =?UTF-8?q?Adicionando=20Multi-Selects=20na=20p=C3=A1gina?= =?UTF-8?q?=204=20para=20seccionamento=20dos=20dados=20(experimental)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Reusables/Sidebars.py | 21 ------------- src/app.py | 64 +++++++++++++++++++++++++++++++++------ src/pages/pg4.py | 13 +++++++- 3 files changed, 67 insertions(+), 31 deletions(-) diff --git a/src/Reusables/Sidebars.py b/src/Reusables/Sidebars.py index e63b1a4..cf0ad5b 100644 --- a/src/Reusables/Sidebars.py +++ b/src/Reusables/Sidebars.py @@ -154,27 +154,6 @@ def pg3(): -def pg4(): - content = \ - html.Div([ - html.Div( - [ - html.H2("Opções", style={"color": "black"}), - ], - style={'text-align': 'center'} - ), - - html.Div([ - dmc.Select(id='dropdown41', label='Escolha o eixo y:', value='Média turma', - data=['Média turma', 'AP', 'RM', 'RF', 'RMF'], clearable=False), - ]), - ] - ) - - return content - - - def pg5(): content = \ html.Div([ diff --git a/src/app.py b/src/app.py index 67dfde4..5d83248 100644 --- a/src/app.py +++ b/src/app.py @@ -11,6 +11,20 @@ server = app.server +Dados_notas = pd.read_excel('https://github.com/Oesterd/Dash-learning-analytics/raw/master/dados_teste.xlsx') +Notas_df = Dados_notas.iloc[:, 0:10] +Notas_df = Notas_df.to_dict('records') + + +Turmas_df = pd.read_excel('https://github.com/Oesterd/Dash-learning-analytics/raw/master/Dados_turma.xlsx') +Dados = pd.DataFrame(Turmas_df) +Disc = Dados['Disciplina'].unique() +Prof = Dados['Professor'].unique() +Disc.sort(), Prof.sort() +Turmas_df = Turmas_df.to_dict('records') + + + page = list(dash.page_registry.values()) @@ -98,7 +112,7 @@ dmc.Col( html.Div( children=[ - "Estatísticas acadêmicas" + "Estatísticas acadêmicas (GS)" ], style={'fontSize': 30, 'textAlign': 'left'}), span='content', offset=2), @@ -131,7 +145,12 @@ 'styles': { 'root': {'width': '95%'} } - } + }, + 'MultiSelect': { + 'styles': { + 'root': {'width': '95%'} + } + }, } }, children=[ @@ -142,7 +161,7 @@ width={"base": navwidth}, position='right', style={ - "overflow": "hidden", + "overflow": "auto", "transition": "width 0.3s ease-in-out", "background-color": "#f4f6f9", }, @@ -180,11 +199,7 @@ - - - - -#--------------------------------------------------------------------------------------------------------- +#-------------------------------------------------------------------- filename = 'Reusables/Sidebars.py' exec(open(filename, encoding="utf-8").read()) @@ -208,6 +223,37 @@ def gather_data(n_intervals): return Notas_df, Turmas_df +def pg4(): + + content = \ + html.Div([ + html.Div( + [ + html.H2("Opções", style={"color": "black"}), + ], + style={'text-align': 'center'} + ), + + + html.Div([ + dmc.MultiSelect(id='Mdropdown41', label='Escolha a(s) disciplina(s)', value=[], + data=Disc, searchable=True, clearable=True) + ]), + + html.Div([ + dmc.MultiSelect(id='Mdropdown42', label='Escolha o(s) professor(es)', value=[], + data=Prof, searchable=True, clearable=True) + ]), + + + html.Div([ + dmc.Select(id='dropdown41', label='Escolha o eixo y:', value='Média turma', + data=['Média turma', 'AP', 'RM', 'RF', 'RMF'], clearable=False), + ]), + ] + ) + + return content @@ -244,7 +290,7 @@ def nav_content(url): def drawer_demo(opened, width): if width["base"] == navwidth: - return {"base": 250} + return {"base": 400} else: return {"base": navwidth} diff --git a/src/pages/pg4.py b/src/pages/pg4.py index 6ab685c..16445c4 100644 --- a/src/pages/pg4.py +++ b/src/pages/pg4.py @@ -60,10 +60,21 @@ @callback( Output('grid3', 'rowData'), Input('Dados_turmas', 'data'), + Input(component_id='Mdropdown41', component_property='value'), + Input(component_id='Mdropdown42', component_property='value'), ) -def Grid_maker(data): +def Grid_maker(data, mdrop1, mdrop2): + df = pd.DataFrame(data) + + if mdrop1: + df = df[df['Disciplina'].isin(mdrop1)] + + if mdrop2: + df = df[df['Professor'].isin(mdrop2)] + + data = df.to_dict('records') return data