diff --git a/chart.py b/chart.py index aebd954..9684342 100644 --- a/chart.py +++ b/chart.py @@ -1,7 +1,18 @@ +from pandas import date_range, Series from plotly.basedatatypes import BaseTraceType from typing import List class Chart: + x: Series = None + def traces(self) -> List[BaseTraceType]: - pass \ No newline at end of file + pass + + def range_breaks(self) -> List[dict]: + # Assuming x is either a date or timestamp. + 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 diff --git a/plot.py b/plot.py index 02ea3c5..5604933 100644 --- a/plot.py +++ b/plot.py @@ -13,8 +13,19 @@ def figure_with_subplots(subplots: List[List[Chart]]) -> Figure: for j, chart in enumerate(row, start = 1): for trace in chart.traces(): figure.add_trace(trace, row = i, col = j) - figure.update_xaxes(showgrid = False, showticklabels = True, rangeslider = dict(visible = False), row = i, col = j) - figure.update_yaxes(showgrid = False, side = 'right', row = i, col = j) + + figure.update_xaxes( + showgrid = False, + showticklabels = True, + rangebreaks = chart.range_breaks(), + rangeslider = dict(visible = False), + row = i, col = j + ) + figure.update_yaxes( + showgrid = False, + side = 'right', + row = i, col = j + ) # TODO: Make this configurable. figure.update_layout(