diff --git a/vidigi/animation.py b/vidigi/animation.py index 837f4aa..8d5d477 100644 --- a/vidigi/animation.py +++ b/vidigi/animation.py @@ -301,6 +301,7 @@ def animate_activity_log( scenario=None, every_x_time_units=10, wrap_queues_at=20, + wrap_resources_at=20, step_snapshot_max=50, limit_duration=10*60*24, plotly_height=900, @@ -341,6 +342,8 @@ def animate_activity_log( Time interval between animation frames in minutes (default is 10). wrap_queues_at : int, optional Maximum number of entities to display in a queue before wrapping to a new row (default is 20). + wrap_resources_at : int, optional + Number of resources to show before wrapping to a new row (default is 20). step_snapshot_max : int, optional Maximum number of patients to show in each snapshot per event (default is 50). limit_duration : int, optional @@ -423,6 +426,7 @@ def animate_activity_log( full_patient_df=full_patient_df, event_position_df=event_position_df, wrap_queues_at=wrap_queues_at, + wrap_resources_at=wrap_resources_at, step_snapshot_max=step_snapshot_max, gap_between_entities=gap_between_entities, gap_between_resources=gap_between_resources, diff --git a/vidigi/prep.py b/vidigi/prep.py index c1013e8..d144e4e 100644 --- a/vidigi/prep.py +++ b/vidigi/prep.py @@ -175,6 +175,7 @@ def generate_animation_df( full_patient_df, event_position_df, wrap_queues_at=20, + wrap_resources_at=20, step_snapshot_max=50, gap_between_entities=10, gap_between_resources=10, @@ -196,6 +197,8 @@ def generate_animation_df( DataFrame with columns 'event', 'x', and 'y', specifying initial positions for each event type. wrap_queues_at : int, optional Number of entities in a queue before wrapping to a new row (default is 20). + wrap_resources_at : int, optional + Number of resources to show before wrapping to a new row (default is 20). step_snapshot_max : int, optional Maximum number of patients to show in each snapshot (default is 50). gap_between_entities : int, optional @@ -244,6 +247,14 @@ def generate_animation_df( resource_use = resource_use.rename(columns={"y": "y_final"}) resource_use['x_final'] = resource_use['x'] - resource_use['resource_id'] * gap_between_resources + # If we want resources to wrap at a certain queue length, do this here + # They'll wrap at the defined point and then the queue will start expanding upwards + # from the starting row + if wrap_resources_at is not None: + resource_use['row'] = np.floor((resource_use['resource_id'] - 1) / (wrap_resources_at)) + resource_use['x_final'] = resource_use['x_final'] + (wrap_resources_at * resource_use['row'] * gap_between_resources) + gap_between_resources + resource_use['y_final'] = resource_use['y_final'] + (resource_use['row'] * gap_between_rows) + # Determine the position for any queuing steps queues = full_patient_df_plus_pos[full_patient_df_plus_pos['event_type']=='queue'].copy() # queues['y_final'] = queues['y']