Marthee commited on
Commit
a9183e6
·
verified ·
1 Parent(s): a74030c

Update Doors_Schedule.py

Browse files
Files changed (1) hide show
  1. Doors_Schedule.py +28 -1
Doors_Schedule.py CHANGED
@@ -282,7 +282,7 @@ def get_st_op_pattern(clmn_name):
282
  return name
283
  return None
284
 
285
- def get_similar_colors(selected_columns_new):
286
  def generate_rgb():
287
  return (random.randint(0, 255), random.randint(0, 255), random.randint(0, 255)) # RGB tuple
288
 
@@ -305,6 +305,33 @@ def get_similar_colors(selected_columns_new):
305
  col_dict[key]['heights'].append(row['height'])
306
  col_dict[key]['color'] = key_colors[key] # Assign the unique RGB color
307
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
308
  # Convert defaultdict to a normal dictionary
309
  col_dict = dict(col_dict)
310
  return col_dict
 
282
  return name
283
  return None
284
 
285
+ '''def get_similar_colors(selected_columns_new):
286
  def generate_rgb():
287
  return (random.randint(0, 255), random.randint(0, 255), random.randint(0, 255)) # RGB tuple
288
 
 
305
  col_dict[key]['heights'].append(row['height'])
306
  col_dict[key]['color'] = key_colors[key] # Assign the unique RGB color
307
 
308
+ # Convert defaultdict to a normal dictionary
309
+ col_dict = dict(col_dict)
310
+ return col_dict'''
311
+
312
+ def get_similar_colors(selected_columns_new):
313
+ def generate_rgb():
314
+ return (random.randint(0, 255), random.randint(0, 255), random.randint(0, 255)) # RGB tuple
315
+
316
+ unique_keys = selected_columns_new['door_type'].unique()
317
+ key_colors = {key: generate_rgb() for key in unique_keys} # Assign a unique RGB color to each key
318
+
319
+ # Create dictionary storing values, colors, and widths
320
+ if 'structural_opening' in selected_columns_new.columns:
321
+ col_dict = defaultdict(lambda: {'values': [], 'color': None, 'widths': []})
322
+ else:
323
+ col_dict = defaultdict(lambda: {'values': [], 'color': None, 'widths': [], 'heights': []})
324
+
325
+ for _, row in selected_columns_new.iterrows():
326
+ key = row['door_type']
327
+ col_dict[key]['values'].append(row['door_id'])
328
+ if 'structural_opening' in selected_columns_new.columns:
329
+ col_dict[key]['widths'].append(row['structural_opening']) # Add structural opening
330
+ else:
331
+ col_dict[key]['widths'].append(row['width']) # Assuming 'widht' is a typo for 'width'
332
+ col_dict[key]['heights'].append(row['height'])
333
+ col_dict[key]['color'] = key_colors[key] # Assign the unique RGB color
334
+
335
  # Convert defaultdict to a normal dictionary
336
  col_dict = dict(col_dict)
337
  return col_dict