Spaces:
Runtime error
Runtime error
gauravlochab
commited on
Commit
·
bc81417
1
Parent(s):
bd7c571
refactor: Update the graph for Nr of Agents Registered
Browse files
app.py
CHANGED
@@ -1,6 +1,7 @@
|
|
1 |
import requests
|
2 |
import pandas as pd
|
3 |
import gradio as gr
|
|
|
4 |
import plotly.express as px
|
5 |
from datetime import datetime, timedelta
|
6 |
import json
|
@@ -295,26 +296,39 @@ def create_visualizations():
|
|
295 |
)
|
296 |
fig_bridges_chain.update_xaxes(tickformat="%Y-%m-%d")
|
297 |
|
298 |
-
#
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
310 |
xaxis=dict(
|
311 |
tickmode='array',
|
312 |
-
tickvals=
|
313 |
-
ticktext=
|
314 |
-
tickangle
|
315 |
),
|
316 |
-
bargap=0.8,
|
317 |
height=700,
|
|
|
318 |
)
|
319 |
# Calculate weekly average daily active agents
|
320 |
df_agents_with_transactions['day_of_week'] = df_agents_with_transactions['date'].dt.dayofweek
|
@@ -341,7 +355,7 @@ def create_visualizations():
|
|
341 |
height=700,
|
342 |
)
|
343 |
|
344 |
-
return fig_swaps_chain, fig_bridges_chain,
|
345 |
|
346 |
# Gradio interface
|
347 |
def dashboard():
|
@@ -351,7 +365,7 @@ def dashboard():
|
|
351 |
fig_tx_chain = create_transcation_visualizations()
|
352 |
gr.Plot(fig_tx_chain)
|
353 |
|
354 |
-
fig_swaps_chain, fig_bridges_chain,
|
355 |
#Fetch and display visualizations
|
356 |
with gr.Tab("Swaps"):
|
357 |
gr.Plot(fig_swaps_chain)
|
@@ -360,9 +374,9 @@ def dashboard():
|
|
360 |
#fig_swaps_chain, fig_bridges_chain, fig_agents_daily, fig_agents_with_transactions_daily,fig_tvl = create_visualizations()
|
361 |
gr.Plot(fig_bridges_chain)
|
362 |
|
363 |
-
with gr.Tab("
|
364 |
#fig_swaps_chain, fig_bridges_chain, fig_agents_daily, fig_agents_with_transactions_daily,fig_tvl = create_visualizations()
|
365 |
-
gr.Plot(
|
366 |
|
367 |
with gr.Tab("DAA"):
|
368 |
#fig_swaps_chain, fig_bridges_chain, fig_agents_daily, fig_agents_with_transactions_daily,fig_tvl = create_visualizations()
|
|
|
1 |
import requests
|
2 |
import pandas as pd
|
3 |
import gradio as gr
|
4 |
+
import plotly.graph_objects as go
|
5 |
import plotly.express as px
|
6 |
from datetime import datetime, timedelta
|
7 |
import json
|
|
|
296 |
)
|
297 |
fig_bridges_chain.update_xaxes(tickformat="%Y-%m-%d")
|
298 |
|
299 |
+
# Nr of agents registered daily and weekly
|
300 |
+
df_agents_with_transactions['date'] = pd.to_datetime(df_agents_with_transactions['date'])
|
301 |
+
daily_agents_df = df_agents_with_transactions.groupby(df_agents_with_transactions['date']).size().reset_index(name='agent_count')
|
302 |
+
weekly_agents_df = df_agents_with_transactions.groupby(df_agents_with_transactions['date'].dt.to_period("W").apply(lambda r: r.start_time)).size().reset_index(name='agent_count')
|
303 |
+
|
304 |
+
fig_agents_registered = go.Figure(data=[
|
305 |
+
go.Bar(
|
306 |
+
name='Daily nr of Registered Agents',
|
307 |
+
x=daily_agents_df['date'],
|
308 |
+
y=daily_agents_df['agent_count'],
|
309 |
+
marker_color='blue'
|
310 |
+
),
|
311 |
+
go.Bar(
|
312 |
+
name='Total Weekly Nr of Registered Agents',
|
313 |
+
x=weekly_agents_df['date'],
|
314 |
+
y=weekly_agents_df['agent_count'],
|
315 |
+
marker_color='purple'
|
316 |
+
)
|
317 |
+
])
|
318 |
+
fig_agents_registered.update_layout(
|
319 |
+
xaxis_title='Date',
|
320 |
+
yaxis_title='Number of Agents',
|
321 |
+
title="Nr of Agents Registered",
|
322 |
+
barmode='group',
|
323 |
+
tickmode='linear', tick0=0, dtick=1,
|
324 |
xaxis=dict(
|
325 |
tickmode='array',
|
326 |
+
tickvals=weekly_agents_df['date'],
|
327 |
+
ticktext=[f'Mon {d.strftime("%b %d")}' for d in weekly_agents_df['date']],
|
328 |
+
tickangle=-45
|
329 |
),
|
|
|
330 |
height=700,
|
331 |
+
bargap=0.8
|
332 |
)
|
333 |
# Calculate weekly average daily active agents
|
334 |
df_agents_with_transactions['day_of_week'] = df_agents_with_transactions['date'].dt.dayofweek
|
|
|
355 |
height=700,
|
356 |
)
|
357 |
|
358 |
+
return fig_swaps_chain, fig_bridges_chain, fig_agents_registered, fig_agents_with_transactions_daily,fig_tvl
|
359 |
|
360 |
# Gradio interface
|
361 |
def dashboard():
|
|
|
365 |
fig_tx_chain = create_transcation_visualizations()
|
366 |
gr.Plot(fig_tx_chain)
|
367 |
|
368 |
+
fig_swaps_chain, fig_bridges_chain, fig_agents_registered, fig_agents_with_transactions_daily,fig_tvl = create_visualizations()
|
369 |
#Fetch and display visualizations
|
370 |
with gr.Tab("Swaps"):
|
371 |
gr.Plot(fig_swaps_chain)
|
|
|
374 |
#fig_swaps_chain, fig_bridges_chain, fig_agents_daily, fig_agents_with_transactions_daily,fig_tvl = create_visualizations()
|
375 |
gr.Plot(fig_bridges_chain)
|
376 |
|
377 |
+
with gr.Tab("Nr of Agents Registered"):
|
378 |
#fig_swaps_chain, fig_bridges_chain, fig_agents_daily, fig_agents_with_transactions_daily,fig_tvl = create_visualizations()
|
379 |
+
gr.Plot(fig_agents_registered)
|
380 |
|
381 |
with gr.Tab("DAA"):
|
382 |
#fig_swaps_chain, fig_bridges_chain, fig_agents_daily, fig_agents_with_transactions_daily,fig_tvl = create_visualizations()
|