Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -47,6 +47,12 @@ def normalize_cost(val, max_tick, baseline=20):
|
|
| 47 |
|
| 48 |
def generate_radar_plot(selected_rows_data: List[dict]) -> go.Figure:
|
| 49 |
"""Generate a CAP radar plot from selected rows."""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 50 |
# Validation: max 3 rows, all same dataset
|
| 51 |
if not selected_rows_data or len(selected_rows_data) == 0:
|
| 52 |
fig = go.Figure()
|
|
@@ -59,15 +65,15 @@ def generate_radar_plot(selected_rows_data: List[dict]) -> go.Figure:
|
|
| 59 |
yanchor='middle'
|
| 60 |
)
|
| 61 |
fig.update_layout(
|
| 62 |
-
height=
|
| 63 |
-
width=1000,
|
| 64 |
xaxis=dict(visible=False),
|
| 65 |
yaxis=dict(visible=False),
|
| 66 |
paper_bgcolor='white',
|
| 67 |
plot_bgcolor='white',
|
| 68 |
-
margin=
|
| 69 |
)
|
| 70 |
return fig
|
|
|
|
| 71 |
if len(selected_rows_data) > 3:
|
| 72 |
fig = go.Figure()
|
| 73 |
fig.add_annotation(
|
|
@@ -79,15 +85,15 @@ def generate_radar_plot(selected_rows_data: List[dict]) -> go.Figure:
|
|
| 79 |
yanchor='middle'
|
| 80 |
)
|
| 81 |
fig.update_layout(
|
| 82 |
-
height=
|
| 83 |
-
width=1000,
|
| 84 |
xaxis=dict(visible=False),
|
| 85 |
yaxis=dict(visible=False),
|
| 86 |
paper_bgcolor='white',
|
| 87 |
plot_bgcolor='white',
|
| 88 |
-
margin=
|
| 89 |
)
|
| 90 |
return fig
|
|
|
|
| 91 |
datasets = [row.get('Dataset', '') for row in selected_rows_data]
|
| 92 |
unique_datasets = set(datasets)
|
| 93 |
if len(unique_datasets) > 1:
|
|
@@ -101,15 +107,15 @@ def generate_radar_plot(selected_rows_data: List[dict]) -> go.Figure:
|
|
| 101 |
yanchor='middle'
|
| 102 |
)
|
| 103 |
fig.update_layout(
|
| 104 |
-
height=
|
| 105 |
-
width=1000,
|
| 106 |
xaxis=dict(visible=False),
|
| 107 |
yaxis=dict(visible=False),
|
| 108 |
paper_bgcolor='white',
|
| 109 |
plot_bgcolor='white',
|
| 110 |
-
margin=
|
| 111 |
)
|
| 112 |
return fig
|
|
|
|
| 113 |
dataset_name = datasets[0] if datasets else "Unknown"
|
| 114 |
|
| 115 |
# Extract metrics from selected rows
|
|
@@ -197,7 +203,7 @@ def generate_radar_plot(selected_rows_data: List[dict]) -> go.Figure:
|
|
| 197 |
title=dict(
|
| 198 |
text=f"CAP Radar Plot: {dataset_name}",
|
| 199 |
x=0.5,
|
| 200 |
-
xanchor='
|
| 201 |
font=dict(size=20)
|
| 202 |
),
|
| 203 |
polar=dict(
|
|
@@ -208,21 +214,23 @@ def generate_radar_plot(selected_rows_data: List[dict]) -> go.Figure:
|
|
| 208 |
),
|
| 209 |
angularaxis=dict(
|
| 210 |
tickfont=dict(size=14),
|
| 211 |
-
rotation=
|
| 212 |
direction='clockwise'
|
| 213 |
),
|
| 214 |
),
|
| 215 |
legend=dict(
|
| 216 |
orientation='h',
|
| 217 |
yanchor='bottom',
|
| 218 |
-
y=-0.
|
| 219 |
xanchor='center',
|
| 220 |
x=0.5,
|
| 221 |
font=dict(size=13)
|
| 222 |
),
|
| 223 |
-
|
|
|
|
| 224 |
height=700,
|
| 225 |
-
width
|
|
|
|
| 226 |
paper_bgcolor='white',
|
| 227 |
plot_bgcolor='white'
|
| 228 |
)
|
|
@@ -869,7 +877,7 @@ def build_app() -> gr.Blocks:
|
|
| 869 |
with gr.Row():
|
| 870 |
with gr.Column(scale=1):
|
| 871 |
pass
|
| 872 |
-
with gr.Column(scale=
|
| 873 |
radar_plot = gr.Plot(label="", value=generate_radar_plot([]))
|
| 874 |
with gr.Column(scale=1):
|
| 875 |
pass
|
|
|
|
| 47 |
|
| 48 |
def generate_radar_plot(selected_rows_data: List[dict]) -> go.Figure:
|
| 49 |
"""Generate a CAP radar plot from selected rows."""
|
| 50 |
+
|
| 51 |
+
# --- COMMON LAYOUT SETTINGS ---
|
| 52 |
+
# We use balanced margins here so the chart is centered.
|
| 53 |
+
# l=80, r=80 gives space for labels. b=100 gives space for the legend.
|
| 54 |
+
common_margin = dict(t=80, b=100, l=80, r=80)
|
| 55 |
+
|
| 56 |
# Validation: max 3 rows, all same dataset
|
| 57 |
if not selected_rows_data or len(selected_rows_data) == 0:
|
| 58 |
fig = go.Figure()
|
|
|
|
| 65 |
yanchor='middle'
|
| 66 |
)
|
| 67 |
fig.update_layout(
|
| 68 |
+
height=600, # Reduced slightly to fit screens better
|
|
|
|
| 69 |
xaxis=dict(visible=False),
|
| 70 |
yaxis=dict(visible=False),
|
| 71 |
paper_bgcolor='white',
|
| 72 |
plot_bgcolor='white',
|
| 73 |
+
margin=common_margin # Use balanced margins
|
| 74 |
)
|
| 75 |
return fig
|
| 76 |
+
|
| 77 |
if len(selected_rows_data) > 3:
|
| 78 |
fig = go.Figure()
|
| 79 |
fig.add_annotation(
|
|
|
|
| 85 |
yanchor='middle'
|
| 86 |
)
|
| 87 |
fig.update_layout(
|
| 88 |
+
height=600,
|
|
|
|
| 89 |
xaxis=dict(visible=False),
|
| 90 |
yaxis=dict(visible=False),
|
| 91 |
paper_bgcolor='white',
|
| 92 |
plot_bgcolor='white',
|
| 93 |
+
margin=common_margin # Use balanced margins
|
| 94 |
)
|
| 95 |
return fig
|
| 96 |
+
|
| 97 |
datasets = [row.get('Dataset', '') for row in selected_rows_data]
|
| 98 |
unique_datasets = set(datasets)
|
| 99 |
if len(unique_datasets) > 1:
|
|
|
|
| 107 |
yanchor='middle'
|
| 108 |
)
|
| 109 |
fig.update_layout(
|
| 110 |
+
height=600,
|
|
|
|
| 111 |
xaxis=dict(visible=False),
|
| 112 |
yaxis=dict(visible=False),
|
| 113 |
paper_bgcolor='white',
|
| 114 |
plot_bgcolor='white',
|
| 115 |
+
margin=common_margin # Use balanced margins
|
| 116 |
)
|
| 117 |
return fig
|
| 118 |
+
|
| 119 |
dataset_name = datasets[0] if datasets else "Unknown"
|
| 120 |
|
| 121 |
# Extract metrics from selected rows
|
|
|
|
| 203 |
title=dict(
|
| 204 |
text=f"CAP Radar Plot: {dataset_name}",
|
| 205 |
x=0.5,
|
| 206 |
+
xanchor='center', # Center the title
|
| 207 |
font=dict(size=20)
|
| 208 |
),
|
| 209 |
polar=dict(
|
|
|
|
| 214 |
),
|
| 215 |
angularaxis=dict(
|
| 216 |
tickfont=dict(size=14),
|
| 217 |
+
rotation=90, # Rotated to put Throughput at top
|
| 218 |
direction='clockwise'
|
| 219 |
),
|
| 220 |
),
|
| 221 |
legend=dict(
|
| 222 |
orientation='h',
|
| 223 |
yanchor='bottom',
|
| 224 |
+
y=-0.15, # Lowered slightly to fit bottom margin
|
| 225 |
xanchor='center',
|
| 226 |
x=0.5,
|
| 227 |
font=dict(size=13)
|
| 228 |
),
|
| 229 |
+
# UPDATED MARGINS HERE
|
| 230 |
+
margin=common_margin,
|
| 231 |
height=700,
|
| 232 |
+
# Removed fixed 'width' to allow Gradio to resize it responsively
|
| 233 |
+
autosize=True,
|
| 234 |
paper_bgcolor='white',
|
| 235 |
plot_bgcolor='white'
|
| 236 |
)
|
|
|
|
| 877 |
with gr.Row():
|
| 878 |
with gr.Column(scale=1):
|
| 879 |
pass
|
| 880 |
+
with gr.Column(scale=3):
|
| 881 |
radar_plot = gr.Plot(label="", value=generate_radar_plot([]))
|
| 882 |
with gr.Column(scale=1):
|
| 883 |
pass
|