diff --git a/src/components/.data_table.py.swp b/src/components/.data_table.py.swp new file mode 100644 index 0000000..3fed9a2 Binary files /dev/null and b/src/components/.data_table.py.swp differ 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)