Spaces:
Sleeping
Sleeping
gauravlochab
commited on
Commit
·
9ca7c3a
1
Parent(s):
bc42514
feat: enhance graph layout with increased dimensions and improved x-axis formatting
Browse files
app.py
CHANGED
|
@@ -810,13 +810,14 @@ def create_combined_time_series_graph(df):
|
|
| 810 |
logger.info(f"Added infinite window moving average APR trace with {len(x_values_ma)} points")
|
| 811 |
|
| 812 |
# Update layout - use simple boolean values everywhere
|
|
|
|
| 813 |
fig.update_layout(
|
| 814 |
title="Average APR Values Across All Agents",
|
| 815 |
xaxis_title="Time",
|
| 816 |
yaxis_title="Value",
|
| 817 |
template="plotly_white",
|
| 818 |
-
height=
|
| 819 |
-
width=
|
| 820 |
legend=dict(
|
| 821 |
orientation="h",
|
| 822 |
yanchor="bottom",
|
|
@@ -853,12 +854,36 @@ def create_combined_time_series_graph(df):
|
|
| 853 |
dtick=dtick
|
| 854 |
)
|
| 855 |
|
| 856 |
-
# Update x-axis
|
| 857 |
-
|
| 858 |
-
|
| 859 |
-
|
| 860 |
-
|
| 861 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 862 |
|
| 863 |
# SIMPLIFIED APPROACH: Do a direct plot without markers for comparison
|
| 864 |
# This creates a simple, reliable fallback plot if the advanced one fails
|
|
@@ -998,21 +1023,42 @@ def create_combined_time_series_graph(df):
|
|
| 998 |
)
|
| 999 |
)
|
| 1000 |
|
| 1001 |
-
# Simplified layout with adjusted y-axis range
|
| 1002 |
simple_fig.update_layout(
|
| 1003 |
title="Average APR Values Across All Agents",
|
| 1004 |
xaxis_title="Time",
|
| 1005 |
yaxis_title="Value",
|
| 1006 |
-
|
| 1007 |
-
|
| 1008 |
-
|
| 1009 |
-
|
| 1010 |
-
|
| 1011 |
-
|
| 1012 |
-
height=
|
| 1013 |
-
width=
|
|
|
|
| 1014 |
)
|
| 1015 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1016 |
# Add a note about hidden agents if there are more than MAX_VISIBLE_AGENTS
|
| 1017 |
if len(unique_agents) > MAX_VISIBLE_AGENTS:
|
| 1018 |
simple_fig.add_annotation(
|
|
|
|
| 810 |
logger.info(f"Added infinite window moving average APR trace with {len(x_values_ma)} points")
|
| 811 |
|
| 812 |
# Update layout - use simple boolean values everywhere
|
| 813 |
+
# Increase the width and height for better visualization
|
| 814 |
fig.update_layout(
|
| 815 |
title="Average APR Values Across All Agents",
|
| 816 |
xaxis_title="Time",
|
| 817 |
yaxis_title="Value",
|
| 818 |
template="plotly_white",
|
| 819 |
+
height=700, # Increased height
|
| 820 |
+
width=1400, # Increased width
|
| 821 |
legend=dict(
|
| 822 |
orientation="h",
|
| 823 |
yanchor="bottom",
|
|
|
|
| 854 |
dtick=dtick
|
| 855 |
)
|
| 856 |
|
| 857 |
+
# Update x-axis with better formatting and focus on data points
|
| 858 |
+
# Get the actual data time range
|
| 859 |
+
if not apr_data.empty:
|
| 860 |
+
# Find the actual time range where we have data
|
| 861 |
+
data_min_time = apr_data['timestamp'].min()
|
| 862 |
+
data_max_time = apr_data['timestamp'].max()
|
| 863 |
+
|
| 864 |
+
# Add some padding (10% on each side)
|
| 865 |
+
time_range = data_max_time - data_min_time
|
| 866 |
+
padding = time_range * 0.1
|
| 867 |
+
display_min_time = data_min_time - padding
|
| 868 |
+
display_max_time = data_max_time + padding
|
| 869 |
+
|
| 870 |
+
# Update x-axis range to focus on the actual data
|
| 871 |
+
fig.update_xaxes(
|
| 872 |
+
showgrid=True,
|
| 873 |
+
gridwidth=1,
|
| 874 |
+
gridcolor='rgba(0,0,0,0.1)',
|
| 875 |
+
range=[display_min_time, display_max_time],
|
| 876 |
+
tickformat="%b %d, %H:%M", # More detailed time format
|
| 877 |
+
tickangle=-30, # Angle the labels for better readability
|
| 878 |
+
tickfont=dict(size=12) # Larger font for tick labels
|
| 879 |
+
)
|
| 880 |
+
else:
|
| 881 |
+
# Default x-axis settings if no data
|
| 882 |
+
fig.update_xaxes(
|
| 883 |
+
showgrid=True,
|
| 884 |
+
gridwidth=1,
|
| 885 |
+
gridcolor='rgba(0,0,0,0.1)'
|
| 886 |
+
)
|
| 887 |
|
| 888 |
# SIMPLIFIED APPROACH: Do a direct plot without markers for comparison
|
| 889 |
# This creates a simple, reliable fallback plot if the advanced one fails
|
|
|
|
| 1023 |
)
|
| 1024 |
)
|
| 1025 |
|
| 1026 |
+
# Simplified layout with adjusted y-axis range and increased size
|
| 1027 |
simple_fig.update_layout(
|
| 1028 |
title="Average APR Values Across All Agents",
|
| 1029 |
xaxis_title="Time",
|
| 1030 |
yaxis_title="Value",
|
| 1031 |
+
yaxis=dict(
|
| 1032 |
+
range=[-40, -10], # Fixed range to match the main graph
|
| 1033 |
+
tickmode='linear',
|
| 1034 |
+
tick0=0,
|
| 1035 |
+
dtick=5
|
| 1036 |
+
),
|
| 1037 |
+
height=700, # Increased height
|
| 1038 |
+
width=1400, # Increased width
|
| 1039 |
+
template="plotly_white" # Use a cleaner template
|
| 1040 |
)
|
| 1041 |
|
| 1042 |
+
# Apply the same x-axis improvements to the fallback graph
|
| 1043 |
+
if not apr_data.empty:
|
| 1044 |
+
# Find the actual time range where we have data
|
| 1045 |
+
data_min_time = apr_data['timestamp'].min()
|
| 1046 |
+
data_max_time = apr_data['timestamp'].max()
|
| 1047 |
+
|
| 1048 |
+
# Add some padding (10% on each side)
|
| 1049 |
+
time_range = data_max_time - data_min_time
|
| 1050 |
+
padding = time_range * 0.1
|
| 1051 |
+
display_min_time = data_min_time - padding
|
| 1052 |
+
display_max_time = data_max_time + padding
|
| 1053 |
+
|
| 1054 |
+
# Update x-axis range to focus on the actual data
|
| 1055 |
+
simple_fig.update_xaxes(
|
| 1056 |
+
range=[display_min_time, display_max_time],
|
| 1057 |
+
tickformat="%b %d, %H:%M",
|
| 1058 |
+
tickangle=-30,
|
| 1059 |
+
tickfont=dict(size=12)
|
| 1060 |
+
)
|
| 1061 |
+
|
| 1062 |
# Add a note about hidden agents if there are more than MAX_VISIBLE_AGENTS
|
| 1063 |
if len(unique_agents) > MAX_VISIBLE_AGENTS:
|
| 1064 |
simple_fig.add_annotation(
|