Skip to content

Commit

Permalink
Update plotly_helper.py (#5098)
Browse files Browse the repository at this point in the history
  • Loading branch information
tehcoderer authored Jun 1, 2023
1 parent 1539793 commit 67e0461
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions openbb_terminal/core/plots/plotly_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -1126,11 +1126,13 @@ def show(

def _xaxis_tickformatstops(self) -> None:
"""Set the datetickformatstops for the xaxis if the x data is datetime."""
if (dateindex := self.get_dateindex()) is None:
if (dateindex := self.get_dateindex()) is None or list(
self.select_xaxes(lambda x: hasattr(x, "tickformat") and x.tickformat)
):
return

tickformatstops = [
dict(dtickrange=[None, 86_400_000], value="%I%p\n%b,%d"),
dict(dtickrange=[None, 86_400_000], value="%I:%M%p\n%b,%d"),
dict(dtickrange=[86_400_000, 604_800_000], value="%Y-%m-%d"),
]
xhoverformat = "%I:%M%p %Y-%m-%d"
Expand All @@ -1149,7 +1151,9 @@ def _xaxis_tickformatstops(self) -> None:
dict(dtickrange=["M1", None], value="%Y-%m-%d"),
],
type="date",
selector=dict(anchor=entry["yaxis"]),
row=entry["row"],
col=entry["col"],
tick0=0.5,
)
self.update_traces(
xhoverformat=xhoverformat, selector=dict(name=entry["name"])
Expand Down Expand Up @@ -1223,6 +1227,8 @@ def get_dateindex(self) -> Optional[List[datetime]]:
self._date_xaxs[trace.xaxis] = {
"yaxis": trace.yaxis,
"name": name,
"row": row,
"col": col,
"secondary_y": secondary_y,
}
self._subplot_xdates.setdefault(row, {}).setdefault(
Expand Down

0 comments on commit 67e0461

Please sign in to comment.