Compare commits

...

3 Commits

Author SHA1 Message Date
017f9fbf2e added r script not releasable code yet 2025-08-24 21:28:33 +02:00
d77c51cc81 testing`: 2025-03-24 21:07:01 +01:00
5d03cb08e6 first commit 2025-03-24 20:42:03 +01:00
14 changed files with 102 additions and 15 deletions

5
.gitignore vendored
View File

@ -1,5 +1,8 @@
.env
**/*.pyc
.coverage
htmlcov
**/.DS_Store
**/*.log
**/*.log
.codegpt

View File

@ -1,13 +1,6 @@
MIT License
Copyright (c) 2022 ArjanCodes and Mark Todisco
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

0
Makefile Normal file
View File

View File

@ -1,3 +1,4 @@
#
# Dash App Tutorial
## Running the app

View File

@ -651,4 +651,4 @@ Batch,Speed,BatchQty,Para1Tgt,Para1,Para2Tgt,Para2,Para3,Para4,Para5,Para6,Para7
650,98,121,0.421,0.432,312,312,314,51747,1549,0.43525,312.75,26510,872,0.433,315.75,964,0.443,317.5,1113,56.25,32.49266862,49.7005988,2.857142857,0.5,0.22,0.824601367,21
651,98,25,0.421,0.424,313,315,306,42278,1433,0.424,307.25,19901,854,0.426,307.5,709,0.431,304,1046,61.68333333,37.33955659,68.13186813,2.923976608,0.27,0.69,0.700471698,22
652,88,17,0.429,0.44425,311,318,314,50548,1496,0.4435,311.75,24853,864,0.4465,315.25,772,0.4475,313,1330,47.5,26.15384615,54.54545455,3.281334051,0.46,0.91,0.74715262,20
653,90,95,0.421,0.42675,311,311,296,42970,1354,0.4245,294.25,19676,770,0.427,301,691,0.4275,287.5,1040,52.5,31.88073394,56.81818182,2.099580084,0.49,0.8,0.555288462,19
653,90,95,0.421,0.42675,311,311,296,42970,1354,0.4245,294.25,19676,770,0.427,301,691,0.4275,287.5,1040,52.5,31.88073394,56.81818182,2.099580084,0.49,0.8,0.555288462,19

1 Batch Speed BatchQty Para1Tgt Para1 Para2Tgt Para2 Para3 Para4 Para5 Para6 Para7 Para8 Para9 Para10 Para11 Para12 Para13 Para14 Para15 Para16 Para17 Para18 Para19 Para20 Para21 Para22 Para23
651 650 98 121 0.421 0.432 312 312 314 51747 1549 0.43525 312.75 26510 872 0.433 315.75 964 0.443 317.5 1113 56.25 32.49266862 49.7005988 2.857142857 0.5 0.22 0.824601367 21
652 651 98 25 0.421 0.424 313 315 306 42278 1433 0.424 307.25 19901 854 0.426 307.5 709 0.431 304 1046 61.68333333 37.33955659 68.13186813 2.923976608 0.27 0.69 0.700471698 22
653 652 88 17 0.429 0.44425 311 318 314 50548 1496 0.4435 311.75 24853 864 0.4465 315.25 772 0.4475 313 1330 47.5 26.15384615 54.54545455 3.281334051 0.46 0.91 0.74715262 20
654 653 90 95 0.421 0.42675 311 311 296 42970 1354 0.4245 294.25 19676 770 0.427 301 691 0.4275 287.5 1040 52.5 31.88073394 56.81818182 2.099580084 0.49 0.8 0.555288462 19

View File

@ -3,15 +3,19 @@ from dash import Dash
from dash_bootstrap_components.themes import BOOTSTRAP
from src.components.layout import create_layout
from src.data.loader_gz import load_transaction_data
from src.data.loader_gz import load_spc_data
from json import load
import os
from dotenv import load_dotenv
load_dotenv()
config_file = "./config.json"
with open(config_file) as config_f:
config=load(config_f)
def main() -> None:
print(os.getenv("MY_ENV_VAR"))
# load the data and create the data manager
data = load_transaction_data(config["DATA_PATH"])

17
poetry.lock generated
View File

@ -744,6 +744,21 @@ files = [
[package.dependencies]
six = ">=1.5"
[[package]]
name = "python-dotenv"
version = "1.0.0"
description = "Read key-value pairs from a .env file and set them as environment variables"
category = "main"
optional = false
python-versions = ">=3.8"
files = [
{file = "python-dotenv-1.0.0.tar.gz", hash = "sha256:a8df96034aae6d2d50a4ebe8216326c61c3eb64836776504fcca410e5937a3ba"},
{file = "python_dotenv-1.0.0-py3-none-any.whl", hash = "sha256:f5971a9226b701070a4bf2c38c89e5a3f0d64de8debda981d1db98583009122a"},
]
[package.extras]
cli = ["click (>=5.0)"]
[[package]]
name = "pytz"
version = "2023.3.post1"
@ -915,4 +930,4 @@ testing = ["big-O", "jaraco.functools", "jaraco.itertools", "more-itertools", "p
[metadata]
lock-version = "2.0"
python-versions = "^3.11"
content-hash = "aec3b7eae4106cf6a3129ef080da73c29c6c87cdce2ad8daa07863e6530a583b"
content-hash = "7f3e66382a8e3dfd6c4b32282eb27fa714b79e8aa2ddbf66a6adfdae0e127732"

View File

@ -13,6 +13,7 @@ pydantic = "^2.5.3"
dash-bootstrap-components = "^1.5.0"
pandas = "^2.1.4"
dash-daq = "^0.5.0"
python-dotenv = "^1.0.0"
[build-system]

View File

@ -0,0 +1,48 @@
import pandas as pd
import plotly.express as px
from dash import Dash, dcc, html
from dash.dependencies import Input, Output
from ..data.loader import DataSchema
from . import ids
def render(app: Dash, data: pd.DataFrame) -> html.Div:
@app.callback(
Output(ids.BAR_CHART, "children"),
[
Input(ids.YEAR_DROPDOWN, "value"),
Input(ids.MONTH_DROPDOWN, "value"),
Input(ids.CATEGORY_DROPDOWN, "value"),
],
)
def update_bar_chart(
years: list[str], months: list[str], categories: list[str]
) -> html.Div:
filtered_data = data.query(
"year in @years and month in @months and category in @categories"
)
if filtered_data.shape[0] == 0:
return html.Div("No data selected.", id=ids.BAR_CHART)
def create_pivot_table() -> pd.DataFrame:
pt = filtered_data.pivot_table(
values=DataSchema.AMOUNT,
index=[DataSchema.CATEGORY],
aggfunc="sum",
fill_value=0,
dropna=False,
)
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.Graph(figure=fig), id=ids.BAR_CHART)
return html.Div(id=ids.BAR_CHART)

View File

@ -1,5 +1,6 @@
BAR_CHART = "bar-chart"
PIE_CHART = "pie-chart"
DATA_TABLE = "data-table"
SELECT_ALL_CATEGORIES_BUTTON = "select-all-categories-button"
CATEGORY_DROPDOWN = "category-dropdown"

View File

@ -1,6 +1,5 @@
import pandas as pd
class DataSchema:
AMOUNT = "amount"
CATEGORY = "category"
@ -8,8 +7,17 @@ class DataSchema:
MONTH = "month"
YEAR = "year"
class SPC_Schema:
FC = "FC"
Category1 = "Category1"
Category2 = "Category2"
Category3 = "Category3"
Batch = "Batch"
Lot = "Lot"
DateTime = "DateTime"
Value = "Value"
def load_transaction_data(path: str) -> pd.DataFrame:
def load_spc_data(path: str) -> pd.DataFrame:
# load the data from the CSV file
data = pd.read_csv(
path,

3
src/data/statistic_ver.R Normal file
View File

@ -0,0 +1,3 @@
library("ggplot2")
read.csv("data\\")

1
test
View File

@ -1 +0,0 @@
i

11
tools/stat_check.R Normal file
View File

@ -0,0 +1,11 @@
library(tidyverse)
library(lubridate
)
print("Hello")
setwd("~/code/2024-dash_v1/data")
data <- read.csv("transactions.csv.gz")
print(data)
print("Goodbye")