gauravlochab commited on
Commit
6898351
·
1 Parent(s): bc81417

refactor: update graphs for total transactions

Browse files
Files changed (2) hide show
  1. app.py +1 -1
  2. app_trans_new.py +15 -2
app.py CHANGED
@@ -320,7 +320,7 @@ def create_visualizations():
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'],
 
320
  yaxis_title='Number of Agents',
321
  title="Nr of Agents Registered",
322
  barmode='group',
323
+ yaxis= dict(tickmode='linear', tick0=0, dtick=1),
324
  xaxis=dict(
325
  tickmode='array',
326
  tickvals=weekly_agents_df['date'],
app_trans_new.py CHANGED
@@ -247,11 +247,14 @@ def create_transcation_visualizations():
247
  # Group by date and chain, count transactions
248
  daily_counts = df_transactions_new.groupby([df_transactions_new['timestamp'].dt.date, 'chain']).size().unstack(fill_value=0)
249
 
 
 
250
  # Set up the plot
251
  fig_tx_chain = px.bar(
252
  daily_counts,
253
  barmode="stack",
254
  title="Chain Daily Activity: Transactions",
 
255
  color_discrete_map={
256
  "optimism": "blue",
257
  "ethereum": "darkgreen",
@@ -260,10 +263,20 @@ def create_transcation_visualizations():
260
  )
261
  fig_tx_chain.update_layout(
262
  xaxis_title="Date",
263
- yaxis_title="Daily Transaction Nr",
264
  legend_title="Transaction Chain",
265
- xaxis_tickformat="%Y-%m-%d",
 
266
  height=700,
 
 
 
 
 
 
 
 
 
267
  )
268
 
269
  return fig_tx_chain
 
247
  # Group by date and chain, count transactions
248
  daily_counts = df_transactions_new.groupby([df_transactions_new['timestamp'].dt.date, 'chain']).size().unstack(fill_value=0)
249
 
250
+ daily_counts = daily_counts[['optimism', 'base', 'ethereum']]
251
+
252
  # Set up the plot
253
  fig_tx_chain = px.bar(
254
  daily_counts,
255
  barmode="stack",
256
  title="Chain Daily Activity: Transactions",
257
+ labels={'index': 'Date', 'value': 'Daily Transaction Count'},
258
  color_discrete_map={
259
  "optimism": "blue",
260
  "ethereum": "darkgreen",
 
263
  )
264
  fig_tx_chain.update_layout(
265
  xaxis_title="Date",
266
+ yaxis_title="Daily Transaction Count",
267
  legend_title="Transaction Chain",
268
+ xaxis_tickformat="%m-%d",
269
+ xaxis=dict(tickmode='linear', dtick=86400000.0 * 7, tickangle=-45),
270
  height=700,
271
+ bargap=0.2,
272
+ bargroupgap=0.1
273
+ )
274
+
275
+ # Adjust x-axis to show only the date of the first day of each week (Monday)
276
+ fig_tx_chain.update_xaxes(
277
+ tickformat="%m-%d",
278
+ tickmode='array',
279
+ tickvals=[d for d in daily_counts.index if d.weekday() == 0]
280
  )
281
 
282
  return fig_tx_chain