Koshti10 commited on
Commit
131f2c3
·
verified ·
1 Parent(s): e31306e

Upload trend_utils.py

Browse files
Files changed (1) hide show
  1. src/trend_utils.py +9 -2
src/trend_utils.py CHANGED
@@ -201,6 +201,7 @@ def get_plot(df: pd.DataFrame, start_date: str = '2023-06-01', end_date: str = '
201
  open_dip = plot_kwargs['open_dip']
202
  comm_dip = plot_kwargs['comm_dip']
203
  height = plot_kwargs['height']
 
204
 
205
  mobile_view = True if plot_kwargs['mobile_view'] else False
206
 
@@ -384,10 +385,15 @@ def get_plot(df: pd.DataFrame, start_date: str = '2023-06-01', end_date: str = '
384
  bordercolor='rgba(0,0,0,0.05)')
385
  )
386
 
 
 
 
 
 
387
  return fig
388
 
389
 
390
- def get_final_trend_plot(benchmark: str = "Text", mobile_view: bool = False) -> go.Figure:
391
  """Fetch and generate the final trend plot for all models.
392
 
393
  Args:
@@ -416,7 +422,8 @@ def get_final_trend_plot(benchmark: str = "Text", mobile_view: bool = False) ->
416
  else:
417
  height = 1000
418
 
419
- plot_kwargs = {'height': height, 'open_dip': 0, 'comm_dip': 0,
 
420
  'mobile_view': mobile_view}
421
 
422
  benchmark_ticks = {}
 
201
  open_dip = plot_kwargs['open_dip']
202
  comm_dip = plot_kwargs['comm_dip']
203
  height = plot_kwargs['height']
204
+ custom_width = plot_kwargs['custom_width']
205
 
206
  mobile_view = True if plot_kwargs['mobile_view'] else False
207
 
 
385
  bordercolor='rgba(0,0,0,0.05)')
386
  )
387
 
388
+ if custom_width:
389
+ # Use a custom width for loading the graph for the first time
390
+ # Gets squished on initial loading as container width defaults to None while rendering for the first time
391
+ fig.update_layout(width=custom_width)
392
+
393
  return fig
394
 
395
 
396
+ def get_final_trend_plot(benchmark: str = "Text", mobile_view: bool = False, custom_width=None) -> go.Figure:
397
  """Fetch and generate the final trend plot for all models.
398
 
399
  Args:
 
422
  else:
423
  height = 1000
424
 
425
+
426
+ plot_kwargs = {'height': height, 'custom_width': custom_width, 'open_dip': 0, 'comm_dip': 0,
427
  'mobile_view': mobile_view}
428
 
429
  benchmark_ticks = {}