Spaces:
Sleeping
Sleeping
gauravlochab
commited on
Commit
·
b028096
1
Parent(s):
dc178ee
feat: update hover text and trace names for average APR consistency
Browse files
app.py
CHANGED
|
@@ -757,7 +757,7 @@ def create_combined_time_series_graph(df):
|
|
| 757 |
for idx, row in avg_apr_data_with_ma.iterrows():
|
| 758 |
timestamp = row['timestamp']
|
| 759 |
hover_data_apr.append(
|
| 760 |
-
f"Time: {timestamp}<br>
|
| 761 |
)
|
| 762 |
|
| 763 |
fig.add_trace(
|
|
@@ -766,7 +766,7 @@ def create_combined_time_series_graph(df):
|
|
| 766 |
y=y_values_ma,
|
| 767 |
mode='lines', # Only lines for moving average
|
| 768 |
line=dict(color='red', width=2), # Thinner line
|
| 769 |
-
name='
|
| 770 |
hovertext=hover_data_apr,
|
| 771 |
hoverinfo='text',
|
| 772 |
visible=True # Visible by default
|
|
@@ -784,11 +784,11 @@ def create_combined_time_series_graph(df):
|
|
| 784 |
timestamp = row['timestamp']
|
| 785 |
if pd.notna(row['adjusted_moving_avg']):
|
| 786 |
hover_data_adj.append(
|
| 787 |
-
f"Time: {timestamp}<br>
|
| 788 |
)
|
| 789 |
else:
|
| 790 |
hover_data_adj.append(
|
| 791 |
-
f"Time: {timestamp}<br>
|
| 792 |
)
|
| 793 |
|
| 794 |
fig.add_trace(
|
|
@@ -797,7 +797,7 @@ def create_combined_time_series_graph(df):
|
|
| 797 |
y=y_values_adj_ma,
|
| 798 |
mode='lines', # Only lines for moving average
|
| 799 |
line=dict(color='green', width=4), # Thicker solid line for adjusted APR
|
| 800 |
-
name='
|
| 801 |
hovertext=hover_data_adj,
|
| 802 |
hoverinfo='text',
|
| 803 |
visible=True # Visible by default
|
|
@@ -1042,7 +1042,7 @@ def create_combined_time_series_graph(df):
|
|
| 1042 |
x=avg_apr_data_with_ma['timestamp'],
|
| 1043 |
y=avg_apr_data_with_ma['moving_avg'],
|
| 1044 |
mode='lines',
|
| 1045 |
-
name='
|
| 1046 |
line=dict(width=2, color='red') # Thinner line
|
| 1047 |
)
|
| 1048 |
)
|
|
@@ -1620,10 +1620,10 @@ def dashboard():
|
|
| 1620 |
with gr.Column():
|
| 1621 |
with gr.Row(elem_id="toggle_container"):
|
| 1622 |
with gr.Column(scale=1, min_width=150):
|
| 1623 |
-
apr_toggle = gr.Checkbox(label="APR
|
| 1624 |
|
| 1625 |
with gr.Column(scale=1, min_width=150):
|
| 1626 |
-
adjusted_apr_toggle = gr.Checkbox(label="Adjusted APR
|
| 1627 |
|
| 1628 |
# Add custom CSS for making the plot responsive
|
| 1629 |
gr.HTML("""
|
|
@@ -1694,9 +1694,9 @@ def dashboard():
|
|
| 1694 |
# Update visibility of traces based on toggle values
|
| 1695 |
for i, trace in enumerate(combined_fig.data):
|
| 1696 |
# Check if this is a moving average trace
|
| 1697 |
-
if trace.name == '
|
| 1698 |
trace.visible = show_apr_ma
|
| 1699 |
-
elif trace.name == '
|
| 1700 |
trace.visible = show_adjusted_apr_ma
|
| 1701 |
|
| 1702 |
return combined_fig
|
|
|
|
| 757 |
for idx, row in avg_apr_data_with_ma.iterrows():
|
| 758 |
timestamp = row['timestamp']
|
| 759 |
hover_data_apr.append(
|
| 760 |
+
f"Time: {timestamp}<br>Avg APR (3d window): {row['moving_avg']:.2f}"
|
| 761 |
)
|
| 762 |
|
| 763 |
fig.add_trace(
|
|
|
|
| 766 |
y=y_values_ma,
|
| 767 |
mode='lines', # Only lines for moving average
|
| 768 |
line=dict(color='red', width=2), # Thinner line
|
| 769 |
+
name='Average APR (3d window)',
|
| 770 |
hovertext=hover_data_apr,
|
| 771 |
hoverinfo='text',
|
| 772 |
visible=True # Visible by default
|
|
|
|
| 784 |
timestamp = row['timestamp']
|
| 785 |
if pd.notna(row['adjusted_moving_avg']):
|
| 786 |
hover_data_adj.append(
|
| 787 |
+
f"Time: {timestamp}<br>Avg ETH Adjusted APR (3d window): {row['adjusted_moving_avg']:.2f}"
|
| 788 |
)
|
| 789 |
else:
|
| 790 |
hover_data_adj.append(
|
| 791 |
+
f"Time: {timestamp}<br>Avg ETH Adjusted APR (3d window): N/A"
|
| 792 |
)
|
| 793 |
|
| 794 |
fig.add_trace(
|
|
|
|
| 797 |
y=y_values_adj_ma,
|
| 798 |
mode='lines', # Only lines for moving average
|
| 799 |
line=dict(color='green', width=4), # Thicker solid line for adjusted APR
|
| 800 |
+
name='Average ETH Adjusted APR (3d window)',
|
| 801 |
hovertext=hover_data_adj,
|
| 802 |
hoverinfo='text',
|
| 803 |
visible=True # Visible by default
|
|
|
|
| 1042 |
x=avg_apr_data_with_ma['timestamp'],
|
| 1043 |
y=avg_apr_data_with_ma['moving_avg'],
|
| 1044 |
mode='lines',
|
| 1045 |
+
name='Average APR (6h window)',
|
| 1046 |
line=dict(width=2, color='red') # Thinner line
|
| 1047 |
)
|
| 1048 |
)
|
|
|
|
| 1620 |
with gr.Column():
|
| 1621 |
with gr.Row(elem_id="toggle_container"):
|
| 1622 |
with gr.Column(scale=1, min_width=150):
|
| 1623 |
+
apr_toggle = gr.Checkbox(label="APR Average", value=True, elem_id="apr_toggle")
|
| 1624 |
|
| 1625 |
with gr.Column(scale=1, min_width=150):
|
| 1626 |
+
adjusted_apr_toggle = gr.Checkbox(label="ETH Adjusted APR Average", value=True, elem_id="adjusted_apr_toggle")
|
| 1627 |
|
| 1628 |
# Add custom CSS for making the plot responsive
|
| 1629 |
gr.HTML("""
|
|
|
|
| 1694 |
# Update visibility of traces based on toggle values
|
| 1695 |
for i, trace in enumerate(combined_fig.data):
|
| 1696 |
# Check if this is a moving average trace
|
| 1697 |
+
if trace.name == 'Average APR (3d window)':
|
| 1698 |
trace.visible = show_apr_ma
|
| 1699 |
+
elif trace.name == 'Average ETH Adjusted APR (3d window)':
|
| 1700 |
trace.visible = show_adjusted_apr_ma
|
| 1701 |
|
| 1702 |
return combined_fig
|