gauravlochab commited on
Commit
c21d0a3
·
1 Parent(s): 5e25fe1

refactor: Update bar gaps and group gaps in create_visualizations()

Browse files
Files changed (1) hide show
  1. app.py +17 -21
app.py CHANGED
@@ -191,34 +191,32 @@ def create_visualizations():
191
  # Filter out dates with zero total value locked
192
  df_tvl_daily = df_tvl_daily[df_tvl_daily["total_value_locked_usd"] > 0]
193
  # Plot total value locked
194
- fig_tvl = px.bar(
195
- df_tvl_daily,
196
- x="date",
197
- y="total_value_locked_usd",
198
- color="chain_name",
 
 
 
 
 
 
 
 
199
  title="Total Volume Invested in Pools in Different Chains Daily",
200
- labels={"date": "Date", "total_value_locked_usd": "Total Volume Invested (USD)"},
 
201
  barmode='stack',
202
- color_discrete_map={
203
- "optimism": "blue",
204
- "base": "purple",
205
- "ethereum": "darkgreen"
206
- }
207
- )
208
- fig_tvl.update_layout(
209
- xaxis_title=None,
210
- yaxis=dict(tickmode='linear', tick0=0, dtick=1),
211
  xaxis=dict(
212
  tickmode='array',
213
  tickvals=df_tvl_daily['date'],
214
  ticktext=df_tvl_daily['date'].dt.strftime('%b %d'),
215
  tickangle=-45,
216
  ),
217
- bargap=0.6, # Increase gap between bar groups (0-1)
218
- bargroupgap=0.1, # Decrease gap between bars in a group (0-1)
219
  height=600,
220
- width=1000, # Specify width to prevent bars from being too wide
221
- margin=dict(l=50, r=50, t=50, b=50), # Add margins
222
  showlegend=True,
223
  legend=dict(
224
  yanchor="top",
@@ -228,8 +226,6 @@ def create_visualizations():
228
  ),
229
  template='plotly_white'
230
  )
231
- fig_tvl.update_xaxes(tickformat="%b %d")
232
-
233
 
234
  chain_name_map = {
235
  10: "Optimism",
 
191
  # Filter out dates with zero total value locked
192
  df_tvl_daily = df_tvl_daily[df_tvl_daily["total_value_locked_usd"] > 0]
193
  # Plot total value locked
194
+ # Plot total value locked
195
+ fig_tvl = go.Figure()
196
+
197
+ for chain_name, color in zip(["optimism", "base", "ethereum"], ["blue", "purple", "darkgreen"]):
198
+ chain_data = df_tvl_daily[df_tvl_daily['chain_name'] == chain_name]
199
+ fig_tvl.add_trace(go.Bar(
200
+ x=chain_data['date'],
201
+ y=chain_data['total_value_locked_usd'],
202
+ name=chain_name.capitalize(),
203
+ marker_color=color
204
+ ))
205
+
206
+ fig_tvl.update_layout(
207
  title="Total Volume Invested in Pools in Different Chains Daily",
208
+ xaxis_title="Date",
209
+ yaxis_title="Total Volume Invested (USD)",
210
  barmode='stack',
 
 
 
 
 
 
 
 
 
211
  xaxis=dict(
212
  tickmode='array',
213
  tickvals=df_tvl_daily['date'],
214
  ticktext=df_tvl_daily['date'].dt.strftime('%b %d'),
215
  tickangle=-45,
216
  ),
 
 
217
  height=600,
218
+ width=1000,
219
+ margin=dict(l=50, r=50, t=50, b=50),
220
  showlegend=True,
221
  legend=dict(
222
  yanchor="top",
 
226
  ),
227
  template='plotly_white'
228
  )
 
 
229
 
230
  chain_name_map = {
231
  10: "Optimism",