mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-10-30 14:02:06 +00:00
hotfix/ /stocks/fa/pt show all price targets on hover (#5305)
* `/stocks/fa/pt` show all price targets on hover * Update helper_funcs.py
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -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
|
||||
@@ -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)
|
||||
|
||||
@@ -172,9 +172,17 @@ def display_price_target_from_analysts(
|
||||
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"),
|
||||
@@ -183,6 +191,8 @@ def display_price_target_from_analysts(
|
||||
line=dict(color=theme.get_colors()[1]),
|
||||
)
|
||||
|
||||
fig.update_layout(hovermode="x unified")
|
||||
|
||||
export_data(
|
||||
export,
|
||||
os.path.dirname(os.path.abspath(__file__)),
|
||||
|
||||
Reference in New Issue
Block a user