Skip to content

Commit

Permalink
hotfix/ /stocks/fa/pt show all price targets on hover (#5305)
Browse files Browse the repository at this point in the history
* `/stocks/fa/pt` show all price targets on hover

* Update helper_funcs.py
  • Loading branch information
tehcoderer authored Aug 10, 2023
1 parent 581fd94 commit 6cf0939
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
5 changes: 5 additions & 0 deletions openbb_terminal/helper_funcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@ def print_rich_table(
print_to_console: bool = False,
limit: Optional[int] = 1000,
source: Optional[str] = None,
columns_keep_types: Optional[List[str]] = None,
):
"""Prepare a table from df in rich.
Expand Down Expand Up @@ -313,6 +314,8 @@ def print_rich_table(
console.
source: Optional[str]
Source of the table. If provided, it will be displayed in the header of the table.
columns_keep_types: Optional[List[str]]
Columns to keep their types, i.e. not convert to numeric
"""
if export:
return
Expand All @@ -329,6 +332,8 @@ def print_rich_table(
# convert non-str that are not timestamp or int into str
# eg) praw.models.reddit.subreddit.Subreddit
for col in df.columns:
if columns_keep_types is not None and col in columns_keep_types:
continue
try:
if not any(
isinstance(df[col].iloc[x], pd.Timestamp)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,17 @@ def adjust_splits(row, splits: pd.DataFrame):
name="Price Target",
mode="markers",
customdata=df_analyst_plot.apply(
lambda row: f"{row['Company']} ({row['Rating']})", axis=1
).values,
hovertemplate="%{customdata}<br><br>Price Target: %{y:.2f}",
lambda row: "<br>".join(
[
f"<b>${x['Price Target']}</b> - <b>{x['Company']} ({x['Rating']})</b>"
for _, x in df_analyst_plot[df_analyst_plot.index == row.name]
.sort_values(by="Price Target", ascending=False)
.iterrows()
]
),
axis=1,
),
hovertemplate="<br>%{customdata}",
marker=dict(
color=colors,
line=dict(width=1, color="DarkSlateGrey"),
Expand All @@ -183,6 +191,8 @@ def adjust_splits(row, splits: pd.DataFrame):
line=dict(color=theme.get_colors()[1]),
)

fig.update_layout(hovermode="x unified")

export_data(
export,
os.path.dirname(os.path.abspath(__file__)),
Expand Down

0 comments on commit 6cf0939

Please sign in to comment.