# check out https://dash.plotly.com/ for documentation
# And check out https://py.cafe/maartenbreddels for more examples
from dash import Dash, Input, Output, callback, dcc, html
import dash_ag_grid as dag
import plotly.express as px
import pandas as pd
df = pd.read_csv("Class_Size_Report_mini.csv")
df['CLASS SIZE'] = pd.to_numeric(df['CLASS SIZE'], errors='coerce')
df_filtered = df.groupby(['BOROUGH','GRADE LEVEL'])[['CLASS SIZE']].mean().reset_index()
df_filtered['BOROUGH'] = df_filtered['BOROUGH'].replace({
'X': 'Bronx',
'R': 'Staten Island',
'K': 'Brooklyn',
'M': 'Manhattan',
'Q': 'Queens'
})
fig = px.sunburst(df_filtered, path=['BOROUGH','GRADE LEVEL'], color='CLASS SIZE',
title="Average Class Size by Borough and Grade Level")
fig.layout.update(margin=dict(l=20, r=20, t=30, b=30))
grid = dag.AgGrid(
rowData=df.to_dict("records"),
columnDefs=[{"field": i, 'filter': True, 'sortable': True} for i in df.columns],
dashGridOptions={"pagination": True},
)
app = Dash(__name__)
app.layout = html.Div(
children=[
dcc.Markdown(children="Title of Graph"),
dcc.Graph(figure=fig),
grid
]
)
# if __name__ == "__main__":
# app.run(debug=True)