Spaces:
Running
Running
gauravlochab
commited on
Commit
·
dc178ee
1
Parent(s):
50f5a4c
feat: set fixed x-axis range start date
Browse files
app.py
CHANGED
@@ -518,6 +518,9 @@ def create_combined_time_series_graph(df):
|
|
518 |
df['apr'] = df['apr'].astype(float) # Ensure APR is float
|
519 |
df['metric_type'] = df['metric_type'].astype(str) # Ensure metric_type is string
|
520 |
|
|
|
|
|
|
|
521 |
# CRITICAL: Log the exact dataframe we're using for plotting to help debug
|
522 |
logger.info(f"Graph data - shape: {df.shape}, columns: {df.columns}")
|
523 |
logger.info(f"Graph data - unique agents: {df['agent_name'].unique().tolist()}")
|
@@ -903,13 +906,14 @@ def create_combined_time_series_graph(df):
|
|
903 |
title=None # Remove the built-in axis title since we're using annotations
|
904 |
)
|
905 |
|
906 |
-
# Update x-axis with better formatting and
|
907 |
fig.update_xaxes(
|
908 |
showgrid=True,
|
909 |
gridwidth=1,
|
910 |
gridcolor='rgba(0,0,0,0.1)',
|
911 |
-
#
|
912 |
-
autorange=
|
|
|
913 |
tickformat="%b %d", # Simplified date format without time
|
914 |
tickangle=-30, # Angle the labels for better readability
|
915 |
tickfont=dict(size=14, family="Arial, sans-serif", color="black", weight="bold"), # Adjusted font size
|
@@ -1129,9 +1133,10 @@ def create_combined_time_series_graph(df):
|
|
1129 |
)
|
1130 |
)
|
1131 |
|
1132 |
-
# Apply
|
1133 |
simple_fig.update_xaxes(
|
1134 |
-
autorange=
|
|
|
1135 |
tickformat="%b %d", # Simplified date format without time
|
1136 |
tickangle=-30,
|
1137 |
tickfont=dict(size=14, family="Arial, sans-serif", color="black", weight="bold"), # Adjusted font size
|
|
|
518 |
df['apr'] = df['apr'].astype(float) # Ensure APR is float
|
519 |
df['metric_type'] = df['metric_type'].astype(str) # Ensure metric_type is string
|
520 |
|
521 |
+
# Set x-axis start date to April 17, 2025 as requested by user
|
522 |
+
x_start_date = datetime(2025, 4, 17, 0, 0, 0)
|
523 |
+
|
524 |
# CRITICAL: Log the exact dataframe we're using for plotting to help debug
|
525 |
logger.info(f"Graph data - shape: {df.shape}, columns: {df.columns}")
|
526 |
logger.info(f"Graph data - unique agents: {df['agent_name'].unique().tolist()}")
|
|
|
906 |
title=None # Remove the built-in axis title since we're using annotations
|
907 |
)
|
908 |
|
909 |
+
# Update x-axis with better formatting and fixed range
|
910 |
fig.update_xaxes(
|
911 |
showgrid=True,
|
912 |
gridwidth=1,
|
913 |
gridcolor='rgba(0,0,0,0.1)',
|
914 |
+
# Set fixed range with April 17 as start date
|
915 |
+
autorange=False, # Disable autoscaling
|
916 |
+
range=[x_start_date, max_time], # Set fixed range from April 17 to max date
|
917 |
tickformat="%b %d", # Simplified date format without time
|
918 |
tickangle=-30, # Angle the labels for better readability
|
919 |
tickfont=dict(size=14, family="Arial, sans-serif", color="black", weight="bold"), # Adjusted font size
|
|
|
1133 |
)
|
1134 |
)
|
1135 |
|
1136 |
+
# Apply fixed range to the x-axis for the fallback graph
|
1137 |
simple_fig.update_xaxes(
|
1138 |
+
autorange=False, # Disable autoscaling
|
1139 |
+
range=[x_start_date, max_time], # Set fixed range from April 17
|
1140 |
tickformat="%b %d", # Simplified date format without time
|
1141 |
tickangle=-30,
|
1142 |
tickfont=dict(size=14, family="Arial, sans-serif", color="black", weight="bold"), # Adjusted font size
|