gauravlochab commited on
Commit
e165379
·
1 Parent(s): 64ec345

feat: enhance responsiveness and styling of APR vs Agent Hash graph

Browse files
Files changed (2) hide show
  1. app.py +2 -2
  2. apr_vs_agent_hash.py +11 -24
app.py CHANGED
@@ -3046,11 +3046,11 @@ def dashboard():
3046
  gr.HTML("""
3047
  <style>
3048
  /* Make plots responsive */
3049
- #responsive_apr_plot, #responsive_roi_plot, #responsive_volume_plot {
3050
  width: 100% !important;
3051
  max-width: 100% !important;
3052
  }
3053
- #responsive_apr_plot > div, #responsive_roi_plot > div, #responsive_volume_plot > div {
3054
  width: 100% !important;
3055
  height: auto !important;
3056
  min-height: 500px !important;
 
3046
  gr.HTML("""
3047
  <style>
3048
  /* Make plots responsive */
3049
+ #responsive_apr_plot, #responsive_roi_plot, #responsive_volume_plot, #responsive_apr_hash_plot {
3050
  width: 100% !important;
3051
  max-width: 100% !important;
3052
  }
3053
+ #responsive_apr_plot > div, #responsive_roi_plot > div, #responsive_volume_plot > div, #responsive_apr_hash_plot > div {
3054
  width: 100% !important;
3055
  height: auto !important;
3056
  min-height: 500px !important;
apr_vs_agent_hash.py CHANGED
@@ -243,7 +243,7 @@ def create_apr_vs_agent_hash_graph(df):
243
  change_color = "green" if is_improvement else "red"
244
  change_text = "improvement" if is_improvement else "decrease"
245
 
246
- # Add annotation showing improvement with better styling
247
  fig.add_annotation(
248
  x=(len(sorted_hashes) - 1) / 2, # Center of the x-axis
249
  y=90, # Top of the chart
@@ -252,11 +252,11 @@ def create_apr_vs_agent_hash_graph(df):
252
  font=dict(
253
  family="Arial, sans-serif",
254
  size=16,
255
- color=change_color,
256
  weight="bold"
257
  ),
258
  bgcolor="rgba(255, 255, 255, 0.9)",
259
- bordercolor=change_color,
260
  borderwidth=2,
261
  borderpad=6,
262
  opacity=0.9
@@ -297,9 +297,9 @@ def create_apr_vs_agent_hash_graph(df):
297
  ),
298
  yaxis_title=None, # Remove the y-axis title as we'll use annotations instead
299
  template="plotly_white",
300
- height=700, # Increased height for better visualization
301
- width=900, # Set a fixed width for better proportions
302
- autosize=True, # Still enable auto-sizing for responsiveness
303
  boxmode='group', # Group boxes together
304
  margin=dict(r=50, l=120, t=100, b=100), # Reduced right margin since guide was removed
305
  hovermode="closest",
@@ -313,22 +313,10 @@ def create_apr_vs_agent_hash_graph(df):
313
  showlegend=False
314
  )
315
 
316
- # Add annotations for y-axis regions
317
  fig.add_annotation(
318
  x=-0.08, # Position further from the y-axis to avoid overlapping with tick labels
319
- y=-25, # Middle of the negative region
320
- xref="paper",
321
- yref="y",
322
- text="Percent drawdown [%]",
323
- showarrow=False,
324
- font=dict(size=16, family="Arial, sans-serif", color="black", weight="bold"), # Adjusted font size
325
- textangle=-90, # Rotate text to be vertical
326
- align="center"
327
- )
328
-
329
- fig.add_annotation(
330
- x=-0.08, # Position further from the y-axis to avoid overlapping with tick labels
331
- y=50, # Middle of the positive region
332
  xref="paper",
333
  yref="y",
334
  text="Agent APR [%]",
@@ -340,14 +328,13 @@ def create_apr_vs_agent_hash_graph(df):
340
 
341
  # Box plot guide removed as per user request
342
 
343
- # Update y-axis with fixed range of -50 to +100 for psychological effect
344
  fig.update_yaxes(
345
  showgrid=True,
346
  gridwidth=1,
347
  gridcolor='rgba(0,0,0,0.1)',
348
- # Use fixed range instead of autoscaling
349
- autorange=False, # Disable autoscaling
350
- range=[-50, 100], # Set fixed range from -50 to +100
351
  tickformat=".2f", # Format tick labels with 2 decimal places
352
  tickfont=dict(size=14, family="Arial, sans-serif", color="black", weight="bold"), # Adjusted font size
353
  title=None # Remove the built-in axis title since we're using annotations
 
243
  change_color = "green" if is_improvement else "red"
244
  change_text = "improvement" if is_improvement else "decrease"
245
 
246
+ # Add annotation showing improvement with better styling (black color)
247
  fig.add_annotation(
248
  x=(len(sorted_hashes) - 1) / 2, # Center of the x-axis
249
  y=90, # Top of the chart
 
252
  font=dict(
253
  family="Arial, sans-serif",
254
  size=16,
255
+ color="black", # Changed to black
256
  weight="bold"
257
  ),
258
  bgcolor="rgba(255, 255, 255, 0.9)",
259
+ bordercolor="black", # Changed to black
260
  borderwidth=2,
261
  borderpad=6,
262
  opacity=0.9
 
297
  ),
298
  yaxis_title=None, # Remove the y-axis title as we'll use annotations instead
299
  template="plotly_white",
300
+ height=900, # Increased height for better visualization and more vertical space
301
+ # width parameter removed to allow full responsiveness
302
+ autosize=True, # Enable auto-sizing for responsiveness
303
  boxmode='group', # Group boxes together
304
  margin=dict(r=50, l=120, t=100, b=100), # Reduced right margin since guide was removed
305
  hovermode="closest",
 
313
  showlegend=False
314
  )
315
 
316
+ # Add single annotation for y-axis
317
  fig.add_annotation(
318
  x=-0.08, # Position further from the y-axis to avoid overlapping with tick labels
319
+ y=0, # Center of the y-axis
 
 
 
 
 
 
 
 
 
 
 
 
320
  xref="paper",
321
  yref="y",
322
  text="Agent APR [%]",
 
328
 
329
  # Box plot guide removed as per user request
330
 
331
+ # Update y-axis with autoscaling
332
  fig.update_yaxes(
333
  showgrid=True,
334
  gridwidth=1,
335
  gridcolor='rgba(0,0,0,0.1)',
336
+ # Use autoscaling
337
+ autorange=True, # Enable autoscaling
 
338
  tickformat=".2f", # Format tick labels with 2 decimal places
339
  tickfont=dict(size=14, family="Arial, sans-serif", color="black", weight="bold"), # Adjusted font size
340
  title=None # Remove the built-in axis title since we're using annotations