entropy25 commited on
Commit
30194ef
Β·
verified Β·
1 Parent(s): a2069ed

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -40
app.py CHANGED
@@ -172,33 +172,6 @@ def create_shift_trend_chart(df, time_period='daily'):
172
  fig.update_layout(height=400)
173
 
174
  return fig
175
- """Create individual materials trend chart"""
176
- if selected_materials:
177
- df = df[df['material_type'].isin(selected_materials)]
178
-
179
- if time_period == 'daily':
180
- grouped = df.groupby(['date', 'material_type'])['weight_kg'].sum().reset_index()
181
- fig = px.line(grouped, x='date', y='weight_kg', color='material_type',
182
- title='🏷️ Materials Production Trends',
183
- labels={'weight_kg': 'Weight (kg)', 'date': 'Date', 'material_type': 'Material'})
184
- elif time_period == 'weekly':
185
- df['week'] = df['date'].dt.isocalendar().week
186
- df['year'] = df['date'].dt.year
187
- grouped = df.groupby(['year', 'week', 'material_type'])['weight_kg'].sum().reset_index()
188
- grouped['week_label'] = grouped['year'].astype(str) + '-W' + grouped['week'].astype(str)
189
- fig = px.bar(grouped, x='week_label', y='weight_kg', color='material_type',
190
- title='🏷️ Materials Production Trends (Weekly)',
191
- labels={'weight_kg': 'Weight (kg)', 'week_label': 'Week', 'material_type': 'Material'})
192
- else: # monthly
193
- df['month'] = df['date'].dt.to_period('M')
194
- grouped = df.groupby(['month', 'material_type'])['weight_kg'].sum().reset_index()
195
- grouped['month'] = grouped['month'].astype(str)
196
- fig = px.bar(grouped, x='month', y='weight_kg', color='material_type',
197
- title='🏷️ Materials Production Trends (Monthly)',
198
- labels={'weight_kg': 'Weight (kg)', 'month': 'Month', 'material_type': 'Material'})
199
-
200
- fig.update_layout(height=400)
201
- return fig
202
 
203
  def detect_outliers(df):
204
  outliers = {}
@@ -285,25 +258,18 @@ def main():
285
 
286
  col_total1, col_total2 = st.columns([3, 1])
287
 
 
 
 
288
  with col_total1:
289
  total_chart = create_total_production_chart(df, total_time_view)
290
  st.plotly_chart(total_chart, use_container_width=True)
291
 
292
- with col_total2:
293
- total_time_view = st.selectbox("Total Time Period", ["daily", "weekly", "monthly"], key="total_time")
294
-
295
  # Materials Production Chart Section
296
  st.subheader("🏷️ Materials Production Trends")
297
 
298
  col_mat1, col_mat2 = st.columns([3, 1])
299
 
300
- with col_mat1:
301
- if selected_materials:
302
- materials_chart = create_materials_trend_chart(df, materials_time_view, selected_materials)
303
- st.plotly_chart(materials_chart, use_container_width=True)
304
- else:
305
- st.info("Please select materials to display trends")
306
-
307
  with col_mat2:
308
  materials_time_view = st.selectbox("Materials Time Period", ["daily", "weekly", "monthly"], key="materials_time")
309
 
@@ -315,6 +281,13 @@ def main():
315
  help="Choose which materials to display"
316
  )
317
 
 
 
 
 
 
 
 
318
  # Shift Analysis
319
  if 'shift' in df.columns:
320
  st.subheader("πŸŒ“ Shift Analysis")
@@ -322,14 +295,14 @@ def main():
322
  # Shift time trend controls moved to right
323
  col_shift_trend1, col_shift_trend2 = st.columns([3, 1])
324
 
 
 
 
325
  with col_shift_trend1:
326
  st.markdown("**πŸ“ˆ Shift Production Trends**")
327
  shift_trend_chart = create_shift_trend_chart(df, shift_time_view)
328
  st.plotly_chart(shift_trend_chart, use_container_width=True)
329
 
330
- with col_shift_trend2:
331
- shift_time_view = st.selectbox("Shift Time Period", ["daily", "weekly", "monthly"], key="shift_time")
332
-
333
  # Shift comparison charts
334
  st.markdown("**πŸ“Š Shift Comparison Analysis**")
335
  shift_col1, shift_col2 = st.columns(2)
 
172
  fig.update_layout(height=400)
173
 
174
  return fig
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
175
 
176
  def detect_outliers(df):
177
  outliers = {}
 
258
 
259
  col_total1, col_total2 = st.columns([3, 1])
260
 
261
+ with col_total2:
262
+ total_time_view = st.selectbox("Total Time Period", ["daily", "weekly", "monthly"], key="total_time")
263
+
264
  with col_total1:
265
  total_chart = create_total_production_chart(df, total_time_view)
266
  st.plotly_chart(total_chart, use_container_width=True)
267
 
 
 
 
268
  # Materials Production Chart Section
269
  st.subheader("🏷️ Materials Production Trends")
270
 
271
  col_mat1, col_mat2 = st.columns([3, 1])
272
 
 
 
 
 
 
 
 
273
  with col_mat2:
274
  materials_time_view = st.selectbox("Materials Time Period", ["daily", "weekly", "monthly"], key="materials_time")
275
 
 
281
  help="Choose which materials to display"
282
  )
283
 
284
+ with col_mat1:
285
+ if selected_materials:
286
+ materials_chart = create_materials_trend_chart(df, materials_time_view, selected_materials)
287
+ st.plotly_chart(materials_chart, use_container_width=True)
288
+ else:
289
+ st.info("Please select materials to display trends")
290
+
291
  # Shift Analysis
292
  if 'shift' in df.columns:
293
  st.subheader("πŸŒ“ Shift Analysis")
 
295
  # Shift time trend controls moved to right
296
  col_shift_trend1, col_shift_trend2 = st.columns([3, 1])
297
 
298
+ with col_shift_trend2:
299
+ shift_time_view = st.selectbox("Shift Time Period", ["daily", "weekly", "monthly"], key="shift_time")
300
+
301
  with col_shift_trend1:
302
  st.markdown("**πŸ“ˆ Shift Production Trends**")
303
  shift_trend_chart = create_shift_trend_chart(df, shift_time_view)
304
  st.plotly_chart(shift_trend_chart, use_container_width=True)
305
 
 
 
 
306
  # Shift comparison charts
307
  st.markdown("**πŸ“Š Shift Comparison Analysis**")
308
  shift_col1, shift_col2 = st.columns(2)