added table

This commit is contained in:
2025-09-06 07:07:08 +02:00
parent cc8de33780
commit ab1d541e2c
2 changed files with 4 additions and 15 deletions

Binary file not shown.

View File

@ -18,14 +18,13 @@ def render(app: Dash, data: pd.DataFrame) -> html.Div:
)
def update_data_table(
years: list[str], months: list[str], categories: list[str]
) -> list[dict]:
) -> html.Div:
filtered_data = data.query(
"year in @years and month in @months and category in @categories"
)
if filtered_data.shape[0] == 0:
return []
return html.Div("No data selected.", id=ids.DATA_TABLE)
def create_pivot_table() -> pd.DataFrame:
pt = filtered_data.pivot_table(
values=DataSchema.AMOUNT,
@ -36,16 +35,6 @@ def render(app: Dash, data: pd.DataFrame) -> html.Div:
)
return pt.reset_index().sort_values(DataSchema.AMOUNT, ascending=False)
return create_pivot_table().to_dict("records")
return html.Div(dcc.Data_table(data=create_pivot_table(data), id=ids.DATA_TABLE)
return html.Div(
DataTable(
id=ids.DATA_TABLE,
columns=[
{"name": col, "id": col}
for col in [DataSchema.CATEGORY, DataSchema.AMOUNT]
],
data=[],
sort_action="native",
)
)
return html.Div(id=ids.DATA_TABLE)