Compare commits
4 Commits
594e7c3cce
...
ab1d541e2c
Author | SHA1 | Date | |
---|---|---|---|
ab1d541e2c | |||
cc8de33780 | |||
1c41f666dc | |||
d76db631fd |
1
main.py
1
main.py
@ -17,6 +17,7 @@ with open(config_file) as config_f:
|
|||||||
|
|
||||||
def main() -> None:
|
def main() -> None:
|
||||||
print(os.getenv("MY_ENV_VAR"))
|
print(os.getenv("MY_ENV_VAR"))
|
||||||
|
print(config["Startup"])
|
||||||
# load the data and create the data manager
|
# load the data and create the data manager
|
||||||
data = load_spc_data(config["DATA_PATH"])
|
data = load_spc_data(config["DATA_PATH"])
|
||||||
|
|
||||||
|
@ -7,4 +7,5 @@ requires-python = ">=3.11"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"dash>=3.2.0",
|
"dash>=3.2.0",
|
||||||
"dash-bootstrap-components>=2.0.4",
|
"dash-bootstrap-components>=2.0.4",
|
||||||
|
"dotenv>=0.9.9",
|
||||||
]
|
]
|
||||||
|
BIN
src/components/.data_table.py.swp
Normal file
BIN
src/components/.data_table.py.swp
Normal file
Binary file not shown.
@ -16,7 +16,7 @@ def render(app: Dash, data: pd.DataFrame) -> html.Div:
|
|||||||
Input(ids.CATEGORY_DROPDOWN, "value"),
|
Input(ids.CATEGORY_DROPDOWN, "value"),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
def update_bar_chart(
|
def update_data_table(
|
||||||
years: list[str], months: list[str], categories: list[str]
|
years: list[str], months: list[str], categories: list[str]
|
||||||
) -> html.Div:
|
) -> html.Div:
|
||||||
filtered_data = data.query(
|
filtered_data = data.query(
|
||||||
@ -24,8 +24,7 @@ def render(app: Dash, data: pd.DataFrame) -> html.Div:
|
|||||||
)
|
)
|
||||||
|
|
||||||
if filtered_data.shape[0] == 0:
|
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:
|
def create_pivot_table() -> pd.DataFrame:
|
||||||
pt = filtered_data.pivot_table(
|
pt = filtered_data.pivot_table(
|
||||||
values=DataSchema.AMOUNT,
|
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)
|
return pt.reset_index().sort_values(DataSchema.AMOUNT, ascending=False)
|
||||||
|
|
||||||
fig = px.bar(
|
return html.Div(dcc.Data_table(data=create_pivot_table(data), id=ids.DATA_TABLE)
|
||||||
create_pivot_table(),
|
|
||||||
x=DataSchema.CATEGORY,
|
|
||||||
y=DataSchema.AMOUNT,
|
|
||||||
color=DataSchema.CATEGORY,
|
|
||||||
)
|
|
||||||
|
|
||||||
return html.Div(dcc.Graph(figure=fig), id=ids.BAR_CHART)
|
return html.Div(id=ids.DATA_TABLE)
|
||||||
|
|
||||||
return html.Div(id=ids.BAR_CHART)
|
|
||||||
|
@ -4,7 +4,7 @@ from src.components import (
|
|||||||
bar_chart,
|
bar_chart,
|
||||||
category_dropdown,
|
category_dropdown,
|
||||||
month_dropdown,
|
month_dropdown,
|
||||||
pie_chart,
|
data_table,
|
||||||
year_dropdown,
|
year_dropdown,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -24,6 +24,6 @@ def create_layout(app: Dash, data: pd.DataFrame) -> html.Div:
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
bar_chart.render(app, data),
|
bar_chart.render(app, data),
|
||||||
pie_chart.render(app, data),
|
data_table.render(app, data),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
22
uv.lock
generated
22
uv.lock
generated
@ -9,12 +9,14 @@ source = { virtual = "." }
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
{ name = "dash" },
|
{ name = "dash" },
|
||||||
{ name = "dash-bootstrap-components" },
|
{ name = "dash-bootstrap-components" },
|
||||||
|
{ name = "dotenv" },
|
||||||
]
|
]
|
||||||
|
|
||||||
[package.metadata]
|
[package.metadata]
|
||||||
requires-dist = [
|
requires-dist = [
|
||||||
{ name = "dash", specifier = ">=3.2.0" },
|
{ name = "dash", specifier = ">=3.2.0" },
|
||||||
{ name = "dash-bootstrap-components", specifier = ">=2.0.4" },
|
{ name = "dash-bootstrap-components", specifier = ">=2.0.4" },
|
||||||
|
{ name = "dotenv", specifier = ">=0.9.9" },
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[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 },
|
{ 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]]
|
[[package]]
|
||||||
name = "flask"
|
name = "flask"
|
||||||
version = "3.1.2"
|
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 },
|
{ 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]]
|
[[package]]
|
||||||
name = "requests"
|
name = "requests"
|
||||||
version = "2.32.5"
|
version = "2.32.5"
|
||||||
|
Reference in New Issue
Block a user