entropy25 commited on
Commit
b80e40a
·
verified ·
1 Parent(s): 0f8c670

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +29 -0
app.py CHANGED
@@ -80,6 +80,35 @@ def create_total_production_chart(df, time_period='daily'):
80
  fig.update_traces(line=dict(color='#1f77b4'))
81
  return fig
82
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
83
  def create_shift_trend_chart(df, time_period='daily'):
84
  """Create shift production trend chart over time"""
85
  if time_period == 'daily':
 
80
  fig.update_traces(line=dict(color='#1f77b4'))
81
  return fig
82
 
83
+ def create_materials_trend_chart(df, time_period='daily', selected_materials=None):
84
+ """Create individual materials trend chart"""
85
+ if selected_materials:
86
+ df = df[df['material_type'].isin(selected_materials)]
87
+
88
+ if time_period == 'daily':
89
+ grouped = df.groupby(['date', 'material_type'])['weight_kg'].sum().reset_index()
90
+ fig = px.line(grouped, x='date', y='weight_kg', color='material_type',
91
+ title='🏷️ Materials Production Trends',
92
+ labels={'weight_kg': 'Weight (kg)', 'date': 'Date', 'material_type': 'Material'})
93
+ elif time_period == 'weekly':
94
+ df['week'] = df['date'].dt.isocalendar().week
95
+ df['year'] = df['date'].dt.year
96
+ grouped = df.groupby(['year', 'week', 'material_type'])['weight_kg'].sum().reset_index()
97
+ grouped['week_label'] = grouped['year'].astype(str) + '-W' + grouped['week'].astype(str)
98
+ fig = px.bar(grouped, x='week_label', y='weight_kg', color='material_type',
99
+ title='🏷️ Materials Production Trends (Weekly)',
100
+ labels={'weight_kg': 'Weight (kg)', 'week_label': 'Week', 'material_type': 'Material'})
101
+ else: # monthly
102
+ df['month'] = df['date'].dt.to_period('M')
103
+ grouped = df.groupby(['month', 'material_type'])['weight_kg'].sum().reset_index()
104
+ grouped['month'] = grouped['month'].astype(str)
105
+ fig = px.bar(grouped, x='month', y='weight_kg', color='material_type',
106
+ title='🏷️ Materials Production Trends (Monthly)',
107
+ labels={'weight_kg': 'Weight (kg)', 'month': 'Month', 'material_type': 'Material'})
108
+
109
+ fig.update_layout(height=400)
110
+ return fig
111
+
112
  def create_shift_trend_chart(df, time_period='daily'):
113
  """Create shift production trend chart over time"""
114
  if time_period == 'daily':