mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-10-27 12:40:35 +00:00
hotfix/backend - Initialize OpenBBFigure (#5912)
* create backend * openbb_figure * black * pylint * pylint again --------- Co-authored-by: Henrique Joaquim <h.joaquim@campus.fct.unl.pt>
This commit is contained in:
@@ -353,7 +353,7 @@ class Backend(PyWry):
|
||||
def get_kwargs(self, title: Optional[str] = "") -> dict:
|
||||
"""Get the kwargs for the backend."""
|
||||
return {
|
||||
"title": f"OpenBB - {title}",
|
||||
"title": "OpenBB Platform" + (f" - {title}" if title else ""),
|
||||
"icon": self.get_window_icon(),
|
||||
"download_path": str(self.charting_settings.user_exports_directory),
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ import numpy as np
|
||||
import pandas as pd
|
||||
import plotly.graph_objects as go
|
||||
import plotly.io as pio
|
||||
from openbb_charting.core.backend import PLOTLYJS_PATH, get_backend
|
||||
from openbb_charting.core.backend import PLOTLYJS_PATH, create_backend, get_backend
|
||||
from openbb_charting.core.chart_style import ChartStyle
|
||||
from openbb_charting.core.config.openbb_styles import (
|
||||
PLT_TBL_ROW_COLORS,
|
||||
@@ -99,6 +99,9 @@ class OpenBBFigure(go.Figure):
|
||||
self._export_image: Optional[Union[Path, str]] = ""
|
||||
self._subplot_xdates: Dict[int, Dict[int, List[Any]]] = {}
|
||||
|
||||
if kwargs.pop("create_backend", False):
|
||||
create_backend(self._charting_settings)
|
||||
get_backend().start(debug=self._charting_settings.debug_mode)
|
||||
self._theme = ChartStyle(
|
||||
self._charting_settings.chart_style,
|
||||
self._charting_settings.user_styles_directory,
|
||||
@@ -161,7 +164,7 @@ class OpenBBFigure(go.Figure):
|
||||
self._cmd_xshift = value
|
||||
|
||||
@classmethod
|
||||
def create_subplots( # noqa: PLR0913
|
||||
def create_subplots( # pylint: disable=too-many-arguments
|
||||
cls,
|
||||
rows: int = 1,
|
||||
cols: int = 1,
|
||||
@@ -267,7 +270,7 @@ class OpenBBFigure(go.Figure):
|
||||
except Exception as e:
|
||||
raise ValueError(f"Error adding trend line: {e}") from e
|
||||
|
||||
def add_histplot( # noqa: PLR0913, PLR0915
|
||||
def add_histplot( # pylint: disable=too-many-arguments
|
||||
self,
|
||||
dataset: Union[np.ndarray, pd.Series, TimeSeriesT],
|
||||
name: Optional[Union[str, List[str]]] = None,
|
||||
@@ -309,7 +312,7 @@ class OpenBBFigure(go.Figure):
|
||||
Column of the subplot, by default 1
|
||||
"""
|
||||
|
||||
from scipy import stats
|
||||
from scipy import stats # pylint: disable=import-outside-toplevel
|
||||
|
||||
callback = stats.norm if curve == "normal" else stats.gaussian_kde
|
||||
|
||||
@@ -1452,30 +1455,6 @@ class OpenBBFigure(go.Figure):
|
||||
|
||||
self._margin_adjusted = True
|
||||
|
||||
def _set_watermark(self) -> None:
|
||||
"""Set the watermark for OpenBB Terminal."""
|
||||
if (
|
||||
not self._backend.isatty
|
||||
or not self._charting_settings.plot_enable_pywry
|
||||
or isinstance(self._export_image, Path)
|
||||
and self._export_image.suffix in [".svg", ".pdf"]
|
||||
):
|
||||
self.add_annotation(
|
||||
yref="paper",
|
||||
xref="paper",
|
||||
x=1,
|
||||
y=0,
|
||||
showarrow=False,
|
||||
text="OpenBB Terminal",
|
||||
font_size=17,
|
||||
font_color="gray",
|
||||
opacity=0.5,
|
||||
xanchor="right",
|
||||
yanchor="bottom",
|
||||
yshift=-80,
|
||||
xshift=40,
|
||||
)
|
||||
|
||||
# pylint: disable=import-outside-toplevel
|
||||
def _add_cmd_source(self, command_location: Optional[str] = "") -> None:
|
||||
"""Set the watermark for OpenBB Terminal."""
|
||||
@@ -1525,7 +1504,6 @@ class OpenBBFigure(go.Figure):
|
||||
return
|
||||
|
||||
self._add_cmd_source()
|
||||
self._set_watermark()
|
||||
|
||||
self._feature_flags_applied = True
|
||||
|
||||
@@ -1594,7 +1572,7 @@ class OpenBBFigure(go.Figure):
|
||||
],
|
||||
)
|
||||
|
||||
def add_corr_plot( # noqa: PLR0913
|
||||
def add_corr_plot( # pylint: disable=too-many-arguments
|
||||
self,
|
||||
series: pd.DataFrame,
|
||||
max_lag: int = 20,
|
||||
|
||||
Reference in New Issue
Block a user