milwright commited on
Commit
852427e
·
1 Parent(s): 811a5c6

fix temporal charts: use autorange instead of hardcoded ranges for sparse data

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +7 -13
src/streamlit_app.py CHANGED
@@ -603,17 +603,11 @@ def create_temporal_visualizations(df: pd.DataFrame) -> Dict[str, go.Figure]:
603
  fig_timeline.update_layout(
604
  height=600,
605
  showlegend=True,
606
- title=f'Activity Timeline ({date_min.strftime("%Y-%m-%d")} to {date_max.strftime("%Y-%m-%d")})'
607
- )
608
- fig_timeline.update_xaxes(
609
- title_text="Date",
610
- row=2, col=1,
611
- range=[date_min_padded, date_max_padded]
612
- )
613
- fig_timeline.update_xaxes(
614
- range=[date_min_padded, date_max_padded],
615
- row=1, col=1
616
  )
 
617
  fig_timeline.update_yaxes(title_text="Count", row=1, col=1)
618
  fig_timeline.update_yaxes(title_text="Value", row=2, col=1)
619
 
@@ -650,7 +644,7 @@ def create_temporal_visualizations(df: pd.DataFrame) -> Dict[str, go.Figure]:
650
  fig_monthly.update_layout(
651
  title=f'Monthly Posting Trends ({date_min.strftime("%Y-%m")} to {date_max.strftime("%Y-%m")})',
652
  xaxis_title='Month',
653
- xaxis=dict(range=[date_min_padded, date_max_padded]),
654
  yaxis=dict(title='Post Count', side='left'),
655
  yaxis2=dict(title='Average Score', side='right', overlaying='y'),
656
  height=400,
@@ -689,7 +683,7 @@ def create_temporal_visualizations(df: pd.DataFrame) -> Dict[str, go.Figure]:
689
  fig_weekly.update_layout(
690
  title=f'Weekly Posting Trends ({date_min.strftime("%Y-%m-%d")} to {date_max.strftime("%Y-%m-%d")})',
691
  xaxis_title='Week',
692
- xaxis=dict(range=[date_min_padded, date_max_padded]),
693
  yaxis=dict(title='Post Count', side='left'),
694
  yaxis2=dict(title='Average Score', side='right', overlaying='y'),
695
  height=400,
@@ -710,7 +704,7 @@ def create_temporal_visualizations(df: pd.DataFrame) -> Dict[str, go.Figure]:
710
  labels={'count': 'Number of Posts', 'created_utc': 'Week'})
711
  fig_flair.update_layout(
712
  height=400,
713
- xaxis=dict(range=[date_min_padded, date_max_padded])
714
  )
715
  figures['flair'] = fig_flair
716
 
 
603
  fig_timeline.update_layout(
604
  height=600,
605
  showlegend=True,
606
+ title=f'Activity Timeline ({date_min.strftime("%Y-%m-%d")} to {date_max.strftime("%Y-%m-%d")})',
607
+ xaxis=dict(type='date', autorange=True),
608
+ xaxis2=dict(type='date', autorange=True)
 
 
 
 
 
 
 
609
  )
610
+ fig_timeline.update_xaxes(title_text="Date", row=2, col=1)
611
  fig_timeline.update_yaxes(title_text="Count", row=1, col=1)
612
  fig_timeline.update_yaxes(title_text="Value", row=2, col=1)
613
 
 
644
  fig_monthly.update_layout(
645
  title=f'Monthly Posting Trends ({date_min.strftime("%Y-%m")} to {date_max.strftime("%Y-%m")})',
646
  xaxis_title='Month',
647
+ xaxis=dict(type='date', autorange=True),
648
  yaxis=dict(title='Post Count', side='left'),
649
  yaxis2=dict(title='Average Score', side='right', overlaying='y'),
650
  height=400,
 
683
  fig_weekly.update_layout(
684
  title=f'Weekly Posting Trends ({date_min.strftime("%Y-%m-%d")} to {date_max.strftime("%Y-%m-%d")})',
685
  xaxis_title='Week',
686
+ xaxis=dict(type='date', autorange=True),
687
  yaxis=dict(title='Post Count', side='left'),
688
  yaxis2=dict(title='Average Score', side='right', overlaying='y'),
689
  height=400,
 
704
  labels={'count': 'Number of Posts', 'created_utc': 'Week'})
705
  fig_flair.update_layout(
706
  height=400,
707
+ xaxis=dict(type='date', autorange=True)
708
  )
709
  figures['flair'] = fig_flair
710