diff --git a/plotting/chart.py b/plotting/chart.py index 5cb72d8..5d67db7 100644 --- a/plotting/chart.py +++ b/plotting/chart.py @@ -1,4 +1,4 @@ -from pandas import date_range, Series +from pandas import date_range, Series, to_datetime from plotly.basedatatypes import BaseTraceType from typing import List @@ -15,5 +15,16 @@ class Chart: start_date = self.x.min() end_date = self.x.max() all_dates = date_range(start = start_date, end = end_date) + missing_dates = all_dates.difference(self.x) - return [dict(values = missing_dates)] \ No newline at end of file + range_breaks = [dict(values = missing_dates)] + + if self.is_intraday(): + # Assuming US Eastern time zone. + range_breaks.append(dict(bounds = [16, 9.5], pattern = 'hour')) + + return range_breaks + + def is_intraday(self) -> bool: + # Check if the x-axis series has a time component other than midnight. + return any(to_datetime(self.x).dt.time != to_datetime(self.x).dt.normalize().dt.time) \ No newline at end of file