Compare commits

...

4 Commits

Author SHA1 Message Date
ab1d541e2c added table 2025-09-06 07:07:08 +02:00
cc8de33780 added table 2025-09-06 07:06:47 +02:00
1c41f666dc added table functionality 2025-09-05 05:46:52 +02:00
d76db631fd added table functionality 2025-09-05 05:46:44 +02:00
6 changed files with 30 additions and 14 deletions

View File

@ -17,6 +17,7 @@ with open(config_file) as config_f:
def main() -> None:
print(os.getenv("MY_ENV_VAR"))
print(config["Startup"])
# load the data and create the data manager
data = load_spc_data(config["DATA_PATH"])

View File

@ -7,4 +7,5 @@ requires-python = ">=3.11"
dependencies = [
"dash>=3.2.0",
"dash-bootstrap-components>=2.0.4",
"dotenv>=0.9.9",
]

Binary file not shown.

View File

@ -16,7 +16,7 @@ def render(app: Dash, data: pd.DataFrame) -> html.Div:
Input(ids.CATEGORY_DROPDOWN, "value"),
],
)
def update_bar_chart(
def update_data_table(
years: list[str], months: list[str], categories: list[str]
) -> html.Div:
filtered_data = data.query(
@ -24,8 +24,7 @@ def render(app: Dash, data: pd.DataFrame) -> html.Div:
)
if filtered_data.shape[0] == 0:
return html.Div("No data selected.", id=ids.BAR_CHART)
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,13 +35,6 @@ def render(app: Dash, data: pd.DataFrame) -> html.Div:
)
return pt.reset_index().sort_values(DataSchema.AMOUNT, ascending=False)
fig = px.bar(
create_pivot_table(),
x=DataSchema.CATEGORY,
y=DataSchema.AMOUNT,
color=DataSchema.CATEGORY,
)
return html.Div(dcc.Data_table(data=create_pivot_table(data), id=ids.DATA_TABLE)
return html.Div(dcc.Graph(figure=fig), id=ids.BAR_CHART)
return html.Div(id=ids.BAR_CHART)
return html.Div(id=ids.DATA_TABLE)

View File

@ -4,7 +4,7 @@ from src.components import (
bar_chart,
category_dropdown,
month_dropdown,
pie_chart,
data_table,
year_dropdown,
)
@ -24,6 +24,6 @@ def create_layout(app: Dash, data: pd.DataFrame) -> html.Div:
],
),
bar_chart.render(app, data),
pie_chart.render(app, data),
data_table.render(app, data),
],
)

22
uv.lock generated
View File

@ -9,12 +9,14 @@ source = { virtual = "." }
dependencies = [
{ name = "dash" },
{ name = "dash-bootstrap-components" },
{ name = "dotenv" },
]
[package.metadata]
requires-dist = [
{ name = "dash", specifier = ">=3.2.0" },
{ name = "dash-bootstrap-components", specifier = ">=2.0.4" },
{ name = "dotenv", specifier = ">=0.9.9" },
]
[[package]]
@ -141,6 +143,17 @@ wheels = [
{ url = "https://files.pythonhosted.org/packages/d6/38/1efeec8b4d741c09ccd169baf8a00c07a0176b58e418d4cd0c30dffedd22/dash_bootstrap_components-2.0.4-py3-none-any.whl", hash = "sha256:767cf0084586c1b2b614ccf50f79fe4525fdbbf8e3a161ed60016e584a14f5d1", size = 204044 },
]
[[package]]
name = "dotenv"
version = "0.9.9"
source = { registry = "https://pypi.org/simple" }
dependencies = [
{ name = "python-dotenv" },
]
wheels = [
{ url = "https://files.pythonhosted.org/packages/b2/b7/545d2c10c1fc15e48653c91efde329a790f2eecfbbf2bd16003b5db2bab0/dotenv-0.9.9-py2.py3-none-any.whl", hash = "sha256:29cf74a087b31dafdb5a446b6d7e11cbce8ed2741540e2339c69fbef92c94ce9", size = 1892 },
]
[[package]]
name = "flask"
version = "3.1.2"
@ -288,6 +301,15 @@ wheels = [
{ url = "https://files.pythonhosted.org/packages/95/a9/12e2dc726ba1ba775a2c6922d5d5b4488ad60bdab0888c337c194c8e6de8/plotly-6.3.0-py3-none-any.whl", hash = "sha256:7ad806edce9d3cdd882eaebaf97c0c9e252043ed1ed3d382c3e3520ec07806d4", size = 9791257 },
]
[[package]]
name = "python-dotenv"
version = "1.1.1"
source = { registry = "https://pypi.org/simple" }
sdist = { url = "https://files.pythonhosted.org/packages/f6/b0/4bc07ccd3572a2f9df7e6782f52b0c6c90dcbb803ac4a167702d7d0dfe1e/python_dotenv-1.1.1.tar.gz", hash = "sha256:a8a6399716257f45be6a007360200409fce5cda2661e3dec71d23dc15f6189ab", size = 41978 }
wheels = [
{ url = "https://files.pythonhosted.org/packages/5f/ed/539768cf28c661b5b068d66d96a2f155c4971a5d55684a514c1a0e0dec2f/python_dotenv-1.1.1-py3-none-any.whl", hash = "sha256:31f23644fe2602f88ff55e1f5c79ba497e01224ee7737937930c448e4d0e24dc", size = 20556 },
]
[[package]]
name = "requests"
version = "2.32.5"