From ab1d541e2c2feec82228dce62dcb809ca384acf3 Mon Sep 17 00:00:00 2001 From: jack leene Date: Sat, 6 Sep 2025 07:07:08 +0200 Subject: [PATCH] added table --- src/components/.data_table.py.swp | Bin 0 -> 12288 bytes src/components/data_table.py | 19 ++++--------------- 2 files changed, 4 insertions(+), 15 deletions(-) create mode 100644 src/components/.data_table.py.swp diff --git a/src/components/.data_table.py.swp b/src/components/.data_table.py.swp new file mode 100644 index 0000000000000000000000000000000000000000..3fed9a291fbacdbb5df997f2e0853e214a273788 GIT binary patch literal 12288 zcmeI2&yN!~6vw?i@}m^Ea5Te#M9O-z+aB0RQxV8gwy>LO8(KjWMc%Qq8JNr%+Xjc_ogk0pU0crQOV7>v^>49s{G9PjoChuygxZ#FwyU$yt{_l`T~3kv6)iv=y@ zq$~|7BxR+RqVE8+d9pKKAqVs=o(J@w6x!03Z>MT(;o&l@tciYWul-G{{rzr@2EG`A>SC1~4cTe$c5Z)w z|NX7z-ihwrS(@#!Efc!|gKpk#?!hw^M8h}{TBc=A*SS&*&aEf=aNfN_90BMRQdgj( zL0fP@z2@mR7RqgjKOqC1jVPlroMG1%-Uz0!Fu!w2#$n2`w>5j#i*fE4JQGs6z-a`9 yPg$RP(PnQbbotW|JwChYH>|P;iE-!&x8HBp94ckpBVpbHg71 literal 0 HcmV?d00001 diff --git a/src/components/data_table.py b/src/components/data_table.py index 2dd91a1..271c013 100644 --- a/src/components/data_table.py +++ b/src/components/data_table.py @@ -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)