diff --git a/src/Reusables/Dist_notas.py b/src/Reusables/Dist_notas.py index 5f8a471..dac635b 100644 --- a/src/Reusables/Dist_notas.py +++ b/src/Reusables/Dist_notas.py @@ -44,7 +44,7 @@ {'field': 'Resultado'}, - {'field': 'Professor'} + {'field': 'Professor', 'filter': False}, ] diff --git a/src/Reusables/Sidebars.py b/src/Reusables/Sidebars.py index e63b1a4..d54d241 100644 --- a/src/Reusables/Sidebars.py +++ b/src/Reusables/Sidebars.py @@ -15,59 +15,58 @@ def pg1(): content = \ html.Div([ - html.Div( - [ - html.H2("Opções", style={"color": "black"}), - ], - style={'text-align': 'center'} - ), + html.Div([ + dmc.MultiSelect(id='Mdropdown11', label='Escolha o(s) professor(es):', value=[], + data=Prof_Notas, searchable=True, clearable=True), + ] + ), - html.Div([ - dmc.Select(id='dropdown11', label='Escolha o eixo x:', value='Média aluno', - data=list(Ops2.keys()), clearable=False), - ] - ), + html.Div([ + dmc.Select(id='dropdown11', label='Escolha o eixo x:', value='Média aluno', + data=list(Ops2.keys()), clearable=False), + ] + ), - html.Div([ + html.Div([ - dmc.Select(id='dropdown12', label='Divisão por cores:', value=None, - data=[ - {'label': 'Nenhuma', 'value': None}, - {'label': 'Professor', 'value': 'Professor'} - ], clearable=False), - ] - ), + dmc.Select(id='dropdown12', label='Divisão por cores:', value=None, + data=[ + {'label': 'Nenhuma', 'value': None}, + {'label': 'Professor', 'value': 'Professor'} + ], clearable=False), + ] + ), - html.Div([ - dmc.Select(data=list(Ops.keys()), label='Divisão por colunas:', value='Nenhuma', - id='dropdown13', clearable=False), - ] - ), + html.Div([ + dmc.Select(data=list(Ops.keys()), label='Divisão por colunas:', value='Nenhuma', + id='dropdown13', clearable=False), + ] + ), - html.Div([ - dmc.Select(id='dropdown14', label='Divisão por linhas:', value='Nenhuma', - data=['Nenhuma', 'Gênero', 'Etnia', 'Escola'], - clearable=False), - ] - ), + html.Div([ + dmc.Select(id='dropdown14', label='Divisão por linhas:', value='Nenhuma', + data=['Nenhuma', 'Gênero', 'Etnia', 'Escola'], + clearable=False), + ] + ), - html.Div([ - dmc.Select(id='dropdown15', label='Tipo de gráfico:', value='Histograma', - data=['Histograma', 'Cumulativo'], - clearable=False), - ] - ), + html.Div([ + dmc.Select(id='dropdown15', label='Tipo de gráfico:', value='Histograma', + data=['Histograma', 'Cumulativo'], + clearable=False), + ] + ), - html.Div([ - dmc.Select( - id='dropdown16', label='Tipo de normalização:', value=None, - data=[ - {'label': 'Contagem', 'value': None}, - {'label': 'Porcentagem', 'value': 'percent'}, - ], - clearable=False - ) - ]), + html.Div([ + dmc.Select( + id='dropdown16', label='Tipo de normalização:', value=None, + data=[ + {'label': 'Contagem', 'value': None}, + {'label': 'Porcentagem', 'value': 'percent'}, + ], + clearable=False + ) + ]), ], style={'display': 'flex', 'flexDirection': 'column', 'gap': 20, 'flex': 1}, ) @@ -75,33 +74,32 @@ def pg1(): return content + + def pg2(): content = \ html.Div([ - html.Div( - [ - html.H2("Opções", style={"color": "black"}), - ], - style={'text-align': 'center'} + html.Div([ + dmc.MultiSelect(id='Mdropdown21', label='Escolha o(s) professor(es):', value=[], + data=Prof_Notas, searchable=True, clearable=True), + ] ), html.Div([ - html.Div([ - dmc.Select(id='dropdown20', label='Escolha o eixo x:', value='Renda (R$)', - data=['Renda (R$)', 'Frequência'], clearable=False) - ]), + dmc.Select(id='dropdown21', label='Escolha o eixo x:', value='Renda (R$)', + data=['Renda (R$)', 'Frequência'], clearable=False) ]), html.Div([ - dmc.Select(data=list(Ops.keys()), label='Divisão por colunas:', value='Nenhuma', id='dropdown21', clearable=False), + dmc.Select(data=list(Ops.keys()), label='Divisão por colunas:', value='Nenhuma', id='dropdown22', clearable=False), ]), html.Div([ - dmc.Select(id='dropdown22', label='Divisão por linhas:', value='Nenhuma', data=['Nenhuma', 'Gênero', 'Escola'], clearable=False), + dmc.Select(id='dropdown23', label='Divisão por linhas:', value='Nenhuma', data=['Nenhuma', 'Gênero', 'Escola'], clearable=False), ]), html.Div([ - dmc.Select(id='dropdown23', label='Regressão linear:', value=None, + dmc.Select(id='dropdown24', label='Regressão linear:', value=None, data=[ {'label': 'Nenhuma', 'value': None}, {'label': 'Linear', 'value': 'ols'}, @@ -113,7 +111,7 @@ def pg2(): html.Div([ dmc.Select( - id='dropdown24', label='Escopo da regressão linear:', value='overall', + id='dropdown25', label='Escopo da regressão linear:', value='overall', data=[ {'label': 'Geral', 'value': 'overall'}, {'label': 'Legenda', 'value': 'trace'}, @@ -128,16 +126,11 @@ def pg2(): return content + + def pg3(): content = \ html.Div([ - html.Div( - [ - html.H2("Opções", style={"color": "black"}), - ], - style={'text-align': 'center'} - ), - html.Div([ dmc.Select( id='dropdown31', label='Tipo de gráfico:', value='stpf', @@ -154,47 +147,55 @@ def pg3(): + 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_turmas, 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), ]), - ] + ], + style={'display': 'flex', 'flexDirection': 'column', 'gap': 20, 'flex': 1} ) return content + def pg5(): content = \ html.Div([ - html.Div( - [ - html.H2("Opções", style={"color": "black"}), - ], - style={'text-align': 'center'} - ), - + html.Div([ + dmc.MultiSelect(id='Mdropdown51', label='Escolha a(s) disciplina(s)', value=[], + data=Disc, searchable=True, clearable=True) + ]), html.Div([ - html.Div([ - dmc.Select(id='dropdown51', label='Escolha o eixo y:', value='Média turma', - data=['Média turma', 'AP', 'RM', 'RF', 'RMF'], clearable=False), - ]), + dmc.MultiSelect(id='Mdropdown52', label='Escolha o(s) professor(es)', value=[], + data=Prof_turmas, searchable=True, clearable=True) ]), + html.Div([ + dmc.Select(id='dropdown51', label='Escolha o eixo y:', value='Média turma', + data=['Média turma', 'AP', 'RM', 'RF', 'RMF'], clearable=False), + ]), + html.Div([ dmc.Select(id='dropdown52', label='Regressão linear:', value=None, @@ -219,8 +220,7 @@ def pg5(): ], style={'display': 'flex', 'flexDirection': 'column', 'gap': 20, 'flex': 1} - ), + ) return content - diff --git a/src/Reusables/Turmas.py b/src/Reusables/Turmas.py index 2db8966..4400fd7 100644 --- a/src/Reusables/Turmas.py +++ b/src/Reusables/Turmas.py @@ -14,16 +14,14 @@ {'field': 'Código', "sortable": True}, - {'field': 'Disciplina', "sortable": True}, + {'field': 'Disciplina', "sortable": True, 'filter': False}, + + {'field': 'Professor', "sortable": True, 'filter': False}, {'field': 'Turma', "sortable": True, 'sort': 'asc', - # "valueGetter": {"function": date_obj}, - # "valueFormatter": {"function": f"d3.timeFormat('%Y/%m/%d')({date_obj})"}, - # "filter": "agDateColumnFilter" + 'filterParams': {'buttons': ['reset']} }, - {'field': 'Professor', "sortable": True}, - {'field': 'Av Professor', 'valueFormatter': gradeformat, 'filter': 'agNumberColumnFilter'}, @@ -59,10 +57,6 @@ 'cellClass': 'center-aligned-cell', 'resizable': True, 'filter': True, - 'filterParams': { - "alwaysShowBothConditions": True, - }, 'floatingFilter': True, 'suppressMenu': True, } - diff --git a/src/app.py b/src/app.py index 66e582d..093cb3d 100644 --- a/src/app.py +++ b/src/app.py @@ -11,12 +11,23 @@ server = app.server + Dados_notas = pd.read_excel('https://github.com/Oesterd/Dash-learning-analytics/raw/master/dados_teste.xlsx') +Prof_Notas = Dados_notas['Professor'].unique() 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') + +Disc = Turmas_df['Disciplina'].unique() +Prof_turmas = Turmas_df['Professor'].unique() +Disc.sort(), Prof_turmas.sort() + +Turmas_df['Turma'] = pd.to_datetime(Turmas_df['Turma'], format='%Y/%m') +Turmas_df['Turma'] = Turmas_df['Turma'].dt.date + Turmas_df = Turmas_df.to_dict('records') @@ -149,8 +160,21 @@ id='sidebar', fixed=False, hidden=True, + height=800, width={"base": navwidth}, position='right', + children=[ + html.Div( + [ + html.H2("Opções", style={"color": "black"}), + ], + style={'text-align': 'center'} + ), + + html.Br(), + + html.Div(id='sidebar-div', children=[]) + ], style={ "overflow": "hidden", "transition": "width 0.3s ease-in-out", @@ -216,7 +240,7 @@ def drawer_demo(opened, width): @callback( - Output('sidebar', 'children'), + Output('sidebar-div', 'children'), Output('Intervalo', 'n_intervals'), State('Intervalo', 'n_intervals'), Input('url', 'pathname'), @@ -243,4 +267,4 @@ def nav_content(n, url): if __name__ == "__main__": - app.run(debug=True, host="localhost") + app.run(debug=False, host="0.0.0.0") diff --git a/src/pages/pg1.py b/src/pages/pg1.py index d2116e4..64d5898 100644 --- a/src/pages/pg1.py +++ b/src/pages/pg1.py @@ -1,6 +1,4 @@ # Importando as bibliotecas -import time - import dash from dash import html, dcc, Input, Output, State, callback, clientside_callback, ctx import dash_ag_grid as dag @@ -90,11 +88,20 @@ def drop4init(options14, options15): # ------------------------------------------------------------------------------------- @callback( Output('grid', 'rowData'), + Input(component_id='Intervalo', component_property='n_intervals'), Input('Dados_notas', 'data'), + Input(component_id='Mdropdown11', component_property='value'), ) -def Grid_maker(data): +def Grid_maker(n, data, mdrop): + dff = pd.DataFrame(data) + + if mdrop: + dff = dff[dff['Professor'].isin(mdrop)] + + data = dff.to_dict('records') + return data @@ -152,4 +159,4 @@ def matplot_html(n, rows, drop1, drop2, drop3, drop4, drop5, drop6): ) - return fig + return fig \ No newline at end of file diff --git a/src/pages/pg2.py b/src/pages/pg2.py index d5c80e7..464b564 100644 --- a/src/pages/pg2.py +++ b/src/pages/pg2.py @@ -9,8 +9,6 @@ import pandas as pd import scipy.stats -import time - # Iniciando o aplicativo @@ -75,8 +73,8 @@ #-------------------------------------------------------------------------------------------- # Callback em cadeia @callback( - Output('dropdown22', 'data'), - Input('dropdown21', 'value'), + Output('dropdown24', 'data'), + Input('dropdown22', 'value'), prevent_initial_call=True ) @@ -87,8 +85,8 @@ def drop_chain(drop21value): @callback( - Output('dropdown22', 'value'), - Input('dropdown22', 'data'), + Output('dropdown23', 'value'), + Input('dropdown23', 'data'), prevent_initial_call=True ) @@ -106,11 +104,18 @@ def drop4init(available_options): #--------------------------------------------------------------------------------- @callback( Output('grid2', 'rowData'), + Input(component_id='Intervalo', component_property='n_intervals'), Input('Dados_notas', 'data'), + Input(component_id='Mdropdown21', component_property='value'), ) +def Grid_maker(n, data, mdrop): + dff = pd.DataFrame(data) + + if mdrop: + dff = dff[dff['Professor'].isin(mdrop)] + data = dff.to_dict('records') -def Grid_maker(data): return data @@ -122,11 +127,11 @@ def Grid_maker(data): Output(component_id='textpg2', component_property='value'), Input(component_id='Intervalo', component_property='n_intervals'), Input(component_id='grid2', component_property='virtualRowData'), - Input(component_id='dropdown20', component_property='value'), Input(component_id='dropdown21', component_property='value'), Input(component_id='dropdown22', component_property='value'), Input(component_id='dropdown23', component_property='value'), Input(component_id='dropdown24', component_property='value'), + Input(component_id='dropdown25', component_property='value'), prevent_initial_call=True ) diff --git a/src/pages/pg4.py b/src/pages/pg4.py index 4b65b6e..5fa1d8b 100644 --- a/src/pages/pg4.py +++ b/src/pages/pg4.py @@ -59,11 +59,26 @@ #-------------------------------------------------------------------------- @callback( Output('grid3', 'rowData'), + Input(component_id='Intervalo', component_property='n_intervals'), 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(n, data, mdrop1, mdrop2): + dff = pd.DataFrame(data) + + + if mdrop1: + dff = dff[dff['Disciplina'].isin(mdrop1)] + + if mdrop2: + dff = dff[dff['Professor'].isin(mdrop2)] + + + data = dff.to_dict('records') + return data @@ -90,7 +105,6 @@ def filterdata(n, rows, drop1): dff = pd.DataFrame(rows) - # Transformando os dados no eixo y em uma razão ao invés de número absoluto if drop1 == 'Média turma': var = drop1 @@ -176,5 +190,3 @@ def filterdata(n, rows, drop1): return fig - - diff --git a/src/pages/pg5.py b/src/pages/pg5.py index 8c21edb..6e592ad 100644 --- a/src/pages/pg5.py +++ b/src/pages/pg5.py @@ -80,11 +80,26 @@ #----------------------------------------------------------------------------------------------------- @callback( Output('grid4', 'rowData'), + Input(component_id='Intervalo', component_property='n_intervals'), Input('Dados_turmas', 'data'), + Input(component_id='Mdropdown51', component_property='value'), + Input(component_id='Mdropdown52', component_property='value'), ) -def Grid_maker(data): +def Grid_maker(n, data, mdrop1, mdrop2): + dff = pd.DataFrame(data) + + + if mdrop1: + dff = dff[dff['Disciplina'].isin(mdrop1)] + + if mdrop2: + dff = dff[dff['Professor'].isin(mdrop2)] + + + data = dff.to_dict('records') + return data