openbb-charting 2.1.2__tar.gz → 2.2.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. {openbb_charting-2.1.2 → openbb_charting-2.2.0}/PKG-INFO +39 -9
  2. {openbb_charting-2.1.2 → openbb_charting-2.2.0}/README.md +34 -5
  3. openbb_charting-2.2.0/openbb_charting/__init__.py +25 -0
  4. openbb_charting-2.1.2/openbb_charting/__init__.py → openbb_charting-2.2.0/openbb_charting/charting.py +131 -98
  5. {openbb_charting-2.1.2/openbb_charting/utils → openbb_charting-2.2.0/openbb_charting/charts}/generic_charts.py +39 -29
  6. {openbb_charting-2.1.2/openbb_charting/utils → openbb_charting-2.2.0/openbb_charting/charts}/helpers.py +27 -19
  7. openbb_charting-2.2.0/openbb_charting/charts/price_historical.py +319 -0
  8. openbb_charting-2.2.0/openbb_charting/charts/price_performance.py +108 -0
  9. {openbb_charting-2.1.2/openbb_charting/utils → openbb_charting-2.2.0/openbb_charting/charts}/relative_rotation.py +18 -10
  10. {openbb_charting-2.1.2 → openbb_charting-2.2.0}/openbb_charting/core/backend.py +71 -54
  11. {openbb_charting-2.1.2 → openbb_charting-2.2.0}/openbb_charting/core/config/openbb_styles.py +5 -4
  12. {openbb_charting-2.1.2 → openbb_charting-2.2.0}/openbb_charting/core/openbb_figure.py +80 -51
  13. {openbb_charting-2.1.2 → openbb_charting-2.2.0}/openbb_charting/core/plotly_ta/base.py +19 -7
  14. {openbb_charting-2.1.2 → openbb_charting-2.2.0}/openbb_charting/core/plotly_ta/data_classes.py +23 -17
  15. {openbb_charting-2.1.2 → openbb_charting-2.2.0}/openbb_charting/core/plotly_ta/ta_class.py +7 -5
  16. {openbb_charting-2.1.2 → openbb_charting-2.2.0}/openbb_charting/core/plotly_ta/ta_helpers.py +8 -5
  17. {openbb_charting-2.1.2 → openbb_charting-2.2.0}/openbb_charting/core/to_chart.py +12 -10
  18. {openbb_charting-2.1.2 → openbb_charting-2.2.0}/openbb_charting/query_params.py +3 -2
  19. {openbb_charting-2.1.2 → openbb_charting-2.2.0}/pyproject.toml +4 -3
  20. openbb_charting-2.1.2/openbb_charting/builder.py +0 -53
  21. openbb_charting-2.1.2/openbb_charting/charting_router.py +0 -1446
  22. {openbb_charting-2.1.2/openbb_charting/utils → openbb_charting-2.2.0/openbb_charting/charts}/__init__.py +0 -0
  23. {openbb_charting-2.1.2 → openbb_charting-2.2.0}/openbb_charting/core/__init__.py +0 -0
  24. {openbb_charting-2.1.2 → openbb_charting-2.2.0}/openbb_charting/core/assets/Terminal_icon.png +0 -0
  25. {openbb_charting-2.1.2 → openbb_charting-2.2.0}/openbb_charting/core/assets/plotly-2.32.0.min.js +0 -0
  26. {openbb_charting-2.1.2 → openbb_charting-2.2.0}/openbb_charting/core/chart_style.py +0 -0
  27. {openbb_charting-2.1.2 → openbb_charting-2.2.0}/openbb_charting/core/config/__init__.py +0 -0
  28. {openbb_charting-2.1.2 → openbb_charting-2.2.0}/openbb_charting/core/dummy_backend.py +0 -0
  29. {openbb_charting-2.1.2 → openbb_charting-2.2.0}/openbb_charting/core/plotly.html +0 -0
  30. {openbb_charting-2.1.2 → openbb_charting-2.2.0}/openbb_charting/core/plotly_ta/__init__.py +0 -0
  31. {openbb_charting-2.1.2 → openbb_charting-2.2.0}/openbb_charting/core/plotly_ta/plugins/__init__.py +0 -0
  32. {openbb_charting-2.1.2 → openbb_charting-2.2.0}/openbb_charting/core/plotly_ta/plugins/custom_indicators_plugin.py +0 -0
  33. {openbb_charting-2.1.2 → openbb_charting-2.2.0}/openbb_charting/core/plotly_ta/plugins/momentum_plugin.py +0 -0
  34. {openbb_charting-2.1.2 → openbb_charting-2.2.0}/openbb_charting/core/plotly_ta/plugins/overlap_plugin.py +0 -0
  35. {openbb_charting-2.1.2 → openbb_charting-2.2.0}/openbb_charting/core/plotly_ta/plugins/trend_indicators_plugin.py +0 -0
  36. {openbb_charting-2.1.2 → openbb_charting-2.2.0}/openbb_charting/core/plotly_ta/plugins/volatility_plugin.py +0 -0
  37. {openbb_charting-2.1.2 → openbb_charting-2.2.0}/openbb_charting/core/plotly_ta/plugins/volume_plugin.py +0 -0
  38. {openbb_charting-2.1.2 → openbb_charting-2.2.0}/openbb_charting/core/table.html +0 -0
  39. {openbb_charting-2.1.2 → openbb_charting-2.2.0}/openbb_charting/styles/__init__.py +0 -0
  40. {openbb_charting-2.1.2 → openbb_charting-2.2.0}/openbb_charting/styles/colors.py +0 -0
  41. {openbb_charting-2.1.2 → openbb_charting-2.2.0}/openbb_charting/styles/default/dark.pltstyle.json +0 -0
  42. {openbb_charting-2.1.2 → openbb_charting-2.2.0}/openbb_charting/styles/default/light.pltstyle.json +0 -0
  43. {openbb_charting-2.1.2 → openbb_charting-2.2.0}/openbb_charting/styles/default/tables.pltstyle.json +0 -0
@@ -1,19 +1,20 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: openbb-charting
3
- Version: 2.1.2
3
+ Version: 2.2.0
4
4
  Summary: Charting extension for OpenBB
5
5
  License: AGPL-3.0-only
6
6
  Author: OpenBB Team
7
7
  Author-email: hello@openbb.co
8
- Requires-Python: >=3.8,<3.12
8
+ Requires-Python: >=3.9,<3.13
9
9
  Classifier: License :: OSI Approved :: GNU Affero General Public License v3
10
10
  Classifier: Programming Language :: Python :: 3
11
- Classifier: Programming Language :: Python :: 3.8
12
11
  Classifier: Programming Language :: Python :: 3.9
13
12
  Classifier: Programming Language :: Python :: 3.10
14
13
  Classifier: Programming Language :: Python :: 3.11
14
+ Classifier: Programming Language :: Python :: 3.12
15
15
  Requires-Dist: nbformat (>=5.9.2,<6.0.0)
16
- Requires-Dist: openbb-core (>=1.2.4,<2.0.0)
16
+ Requires-Dist: numpy (>=1,<2)
17
+ Requires-Dist: openbb-core (>=1.3.0,<2.0.0)
17
18
  Requires-Dist: pandas-ta (>=0.3.14b,<0.4.0)
18
19
  Requires-Dist: plotly (>=5.17.0,<6.0.0)
19
20
  Requires-Dist: pywry (>=0.6.1,<0.7.0)
@@ -32,7 +33,7 @@ The library includes:
32
33
  - prebuilt charts for a set of commands that are built-in OpenBB extensions
33
34
 
34
35
  >[!NOTE]
35
- > The charting library is an [`OBBject` extension](https://docs.openbb.co/platform/development/developer-guidelines/obbject_extensions) which means you'll have the functionality it exposes on every command result.
36
+ > The charting library is an `OBBject` extension which means you'll have the functionality it exposes on every command result.
36
37
 
37
38
  ## Installation
38
39
 
@@ -143,15 +144,44 @@ Example usage:
143
144
 
144
145
  ## Add a visualization to an existing Platform command
145
146
 
146
- One should first ensure that the already implemented endpoint is available in the [charting router](/openbb_platform/obbject_extensions/charting/openbb_charting/charting_router.py).
147
+ To add a visualization to an existing command, you'll need to add a `poetry` plugin to your `pyproject.toml` file. The syntax should be the following:
147
148
 
148
- To do so, you can run:
149
- `python openbb_platform/obbject_extensions/charting/openbb_charting/builder.py` - which will read all the available endpoints and add them to the charting router.
149
+ ```toml
150
+ [tool.poetry.plugins."openbb_charting_extension"]
151
+ my_extension = "openbb_my_extension.my_extension_views:MyExtensionViews"
152
+ ```
153
+
154
+ Where the `openbb_charting_extension` is **mandatory**, otherwise the charting extension won't be able to find the visualization.
155
+
156
+ And the suggested structure for the `my_extension_views` module is the following:
157
+
158
+ ```python
159
+ """Views for MyExtension."""
160
+
161
+ from typing import Any, Dict, Tuple
162
+
163
+ from openbb_charting.charts.price_historical import price_historical
164
+ from openbb_charting.core.openbb_figure import OpenBBFigure
165
+
166
+
167
+ class MyExtensionViews:
168
+ """MyExtension Views."""
169
+
170
+ @staticmethod
171
+ def my_extension_price_historical(
172
+ **kwargs,
173
+ ) -> Tuple[OpenBBFigure, Dict[str, Any]]:
174
+ """MyExtension Price Historical Chart."""
175
+ return price_historical(**kwargs)
176
+ ```
177
+
178
+ > Note that `my_extension_views` lives under the `openbb_my_extension` package.
150
179
 
151
- Afterwards, you'll need to add the visualization to the [charting router]. The convention to match the endpoint with the respective charting function is the following:
180
+ Afterwards, you'll need to add the visualization to your new `MyExtensionViews` class. The convention to match the endpoint with the respective charting function is the following:
152
181
 
153
182
  - `/equity/price/historical` -> `equity_price_historical`
154
183
  - `/technical/ema` -> `technical_ema`
184
+ - `/my_extension/price_historical` -> `my_extension_price_historical`
155
185
 
156
186
  When you spot the charting function on the charting router file, you can add the visualization to it.
157
187
 
@@ -9,7 +9,7 @@ The library includes:
9
9
  - prebuilt charts for a set of commands that are built-in OpenBB extensions
10
10
 
11
11
  >[!NOTE]
12
- > The charting library is an [`OBBject` extension](https://docs.openbb.co/platform/development/developer-guidelines/obbject_extensions) which means you'll have the functionality it exposes on every command result.
12
+ > The charting library is an `OBBject` extension which means you'll have the functionality it exposes on every command result.
13
13
 
14
14
  ## Installation
15
15
 
@@ -120,15 +120,44 @@ Example usage:
120
120
 
121
121
  ## Add a visualization to an existing Platform command
122
122
 
123
- One should first ensure that the already implemented endpoint is available in the [charting router](/openbb_platform/obbject_extensions/charting/openbb_charting/charting_router.py).
123
+ To add a visualization to an existing command, you'll need to add a `poetry` plugin to your `pyproject.toml` file. The syntax should be the following:
124
124
 
125
- To do so, you can run:
126
- `python openbb_platform/obbject_extensions/charting/openbb_charting/builder.py` - which will read all the available endpoints and add them to the charting router.
125
+ ```toml
126
+ [tool.poetry.plugins."openbb_charting_extension"]
127
+ my_extension = "openbb_my_extension.my_extension_views:MyExtensionViews"
128
+ ```
129
+
130
+ Where the `openbb_charting_extension` is **mandatory**, otherwise the charting extension won't be able to find the visualization.
131
+
132
+ And the suggested structure for the `my_extension_views` module is the following:
133
+
134
+ ```python
135
+ """Views for MyExtension."""
136
+
137
+ from typing import Any, Dict, Tuple
138
+
139
+ from openbb_charting.charts.price_historical import price_historical
140
+ from openbb_charting.core.openbb_figure import OpenBBFigure
141
+
142
+
143
+ class MyExtensionViews:
144
+ """MyExtension Views."""
145
+
146
+ @staticmethod
147
+ def my_extension_price_historical(
148
+ **kwargs,
149
+ ) -> Tuple[OpenBBFigure, Dict[str, Any]]:
150
+ """MyExtension Price Historical Chart."""
151
+ return price_historical(**kwargs)
152
+ ```
153
+
154
+ > Note that `my_extension_views` lives under the `openbb_my_extension` package.
127
155
 
128
- Afterwards, you'll need to add the visualization to the [charting router]. The convention to match the endpoint with the respective charting function is the following:
156
+ Afterwards, you'll need to add the visualization to your new `MyExtensionViews` class. The convention to match the endpoint with the respective charting function is the following:
129
157
 
130
158
  - `/equity/price/historical` -> `equity_price_historical`
131
159
  - `/technical/ema` -> `technical_ema`
160
+ - `/my_extension/price_historical` -> `my_extension_price_historical`
132
161
 
133
162
  When you spot the charting function on the charting router file, you can add the visualization to it.
134
163
 
@@ -0,0 +1,25 @@
1
+ """OpenBB OBBject extension for charting."""
2
+
3
+ import warnings
4
+
5
+ from openbb_core.app.model.extension import Extension
6
+
7
+ warnings.filterwarnings(
8
+ "ignore",
9
+ category=UserWarning,
10
+ module="openbb_core.app.model.extension",
11
+ )
12
+
13
+
14
+ def get_charting_module():
15
+ """Get the Charting module."""
16
+ # pylint: disable=import-outside-toplevel
17
+ import importlib
18
+
19
+ _Charting = importlib.import_module("openbb_charting.charting").Charting
20
+ return _Charting
21
+
22
+
23
+ ext = Extension(name="charting", description="Create custom charts from OBBject data.")
24
+
25
+ Charting = ext.obbject_accessor(get_charting_module())
@@ -1,44 +1,41 @@
1
- """OpenBB OBBject extension for charting."""
1
+ """Charting Class implementation."""
2
2
 
3
3
  # pylint: disable=too-many-arguments,unused-argument
4
4
 
5
- import warnings
6
5
  from typing import (
6
+ TYPE_CHECKING,
7
7
  Any,
8
8
  Callable,
9
+ ClassVar,
9
10
  Dict,
10
11
  List,
11
12
  Literal,
12
13
  Optional,
13
14
  Tuple,
15
+ Type,
14
16
  Union,
15
17
  )
16
18
  from warnings import warn
17
19
 
18
- import numpy as np
19
- import pandas as pd
20
+ from importlib_metadata import entry_points
20
21
  from openbb_core.app.model.charts.chart import Chart
21
- from openbb_core.app.model.extension import Extension
22
22
  from openbb_core.app.model.obbject import OBBject
23
- from openbb_core.app.utils import basemodel_to_df, convert_to_basemodel
24
23
  from openbb_core.provider.abstract.data import Data
25
- from plotly.graph_objs import Figure
26
24
 
27
- from openbb_charting import charting_router
28
- from openbb_charting.core.backend import Backend, create_backend, get_backend
29
- from openbb_charting.core.openbb_figure import OpenBBFigure
30
- from openbb_charting.query_params import ChartParams, IndicatorsParams
31
- from openbb_charting.utils.generic_charts import bar_chart, line_chart
32
- from openbb_charting.utils.helpers import get_charting_functions
33
-
34
- warnings.filterwarnings(
35
- "ignore", category=UserWarning, module="openbb_core.app.model.extension", lineno=47
25
+ from openbb_charting.charts.helpers import (
26
+ get_charting_functions,
27
+ get_charting_functions_list,
36
28
  )
37
29
 
38
- ext = Extension(name="charting", description="Create custom charts from OBBject data.")
30
+ if TYPE_CHECKING:
31
+ from numpy import ndarray # noqa
32
+ from pandas import DataFrame, Series # noqa
33
+ from plotly.graph_objs import Figure # noqa
34
+ from openbb_charting.core.openbb_figure import OpenBBFigure # noqa
35
+ from openbb_charting.query_params import ChartParams # noqa
36
+ from openbb_charting.core.backend import Backend # noqa
39
37
 
40
38
 
41
- @ext.obbject_accessor
42
39
  class Charting:
43
40
  """Charting extension.
44
41
 
@@ -64,17 +61,29 @@ class Charting:
64
61
  Toggle the chart style, of an existing chart, between light and dark mode.
65
62
  """
66
63
 
64
+ _extension_views: ClassVar[List[Type]] = [
65
+ entry_point.load()
66
+ for entry_point in entry_points(group="openbb_charting_extension")
67
+ ]
68
+ _format = "plotly" # the charts computed by this extension will be in plotly format
69
+
67
70
  def __init__(self, obbject):
68
71
  """Initialize Charting extension."""
69
72
  # pylint: disable=import-outside-toplevel
70
- from openbb_core.app.model.charts.charting_settings import ChartingSettings
73
+ import importlib # noqa
74
+
75
+ charting_settings_module = importlib.import_module(
76
+ "openbb_core.app.model.charts.charting_settings", "ChartingSettings"
77
+ )
78
+ ChartingSettings = charting_settings_module.ChartingSettings
71
79
 
72
80
  self._obbject: OBBject = obbject
73
81
  self._charting_settings = ChartingSettings(
74
82
  user_settings=self._obbject._user_settings, # type: ignore
75
83
  system_settings=self._obbject._system_settings, # type: ignore
76
84
  )
77
- self._backend: Backend = self._handle_backend()
85
+ self._backend = self._handle_backend()
86
+ self._functions: Dict[str, Callable] = self._get_functions()
78
87
 
79
88
  @classmethod
80
89
  def indicators(cls):
@@ -82,33 +91,58 @@ class Charting:
82
91
 
83
92
  Without assigning to a variable, it will print the the information to the console.
84
93
  """
94
+ # pylint: disable=import-outside-toplevel
95
+ from openbb_charting.query_params import IndicatorsParams
96
+
85
97
  return IndicatorsParams()
86
98
 
87
99
  @classmethod
88
- def functions(cls):
100
+ def functions(cls) -> List[str]:
89
101
  """Return a list of the available functions."""
90
- return get_charting_functions()
102
+ functions: List[str] = []
103
+ for view in cls._extension_views:
104
+ functions.extend(get_charting_functions_list(view))
105
+
106
+ return functions
107
+
108
+ def _get_functions(self) -> Dict[str, Callable]:
109
+ """Return a dict with the available functions."""
110
+ functions: Dict[str, Callable] = {}
111
+ for view in self._extension_views:
112
+ functions.update(get_charting_functions(view))
91
113
 
92
- def _handle_backend(self) -> Backend:
114
+ return functions
115
+
116
+ def _handle_backend(self) -> "Backend":
93
117
  """Create and start the backend."""
118
+ # pylint: disable=import-outside-toplevel
119
+ from openbb_charting.core.backend import create_backend, get_backend
120
+
94
121
  create_backend(self._charting_settings)
95
122
  backend = get_backend()
96
123
  backend.start(debug=self._charting_settings.debug_mode)
97
124
  return backend
98
125
 
99
- @staticmethod
100
- def _get_chart_function(route: str) -> Callable:
126
+ def _get_chart_function(self, route: str) -> Callable:
101
127
  """Given a route, it returns the chart function. The module must contain the given route."""
102
128
  if route is None:
103
129
  raise ValueError("OBBject was initialized with no function route.")
104
130
  adjusted_route = route.replace("/", "_")[1:]
105
- return getattr(charting_router, adjusted_route)
131
+ if adjusted_route not in self._functions:
132
+ raise ValueError(
133
+ f"Could not find the route `{adjusted_route}` in the charting functions."
134
+ )
135
+ return self._functions[adjusted_route]
106
136
 
107
- def get_params(self) -> ChartParams:
137
+ def get_params(self) -> Union["ChartParams", None]:
108
138
  """Return the ChartQueryParams class for the function the OBBject was created from.
109
139
 
110
140
  Without assigning to a variable, it will print the docstring to the console.
141
+ If the class is not defined, the help for the function will be returned.
111
142
  """
143
+ # pylint: disable=import-outside-toplevel
144
+ from openbb_charting.query_params import ChartParams
145
+
112
146
  if self._obbject._route is None: # pylint: disable=protected-access
113
147
  raise ValueError("OBBject was initialized with no function route.")
114
148
  charting_function = (
@@ -116,23 +150,32 @@ class Charting:
116
150
  ).replace("/", "_")[1:]
117
151
  if hasattr(ChartParams, charting_function):
118
152
  return getattr(ChartParams, charting_function)()
119
- raise ValueError(
120
- f"Error: No chart parameters are defined for the route: {charting_function}"
153
+
154
+ return help( # type: ignore
155
+ self._get_chart_function( # pylint: disable=protected-access
156
+ self._obbject.extra[ # pylint: disable=protected-access
157
+ "metadata"
158
+ ].route
159
+ )
121
160
  )
122
161
 
123
162
  def _prepare_data_as_df(
124
- self, data: Optional[Union[pd.DataFrame, pd.Series]]
125
- ) -> Tuple[pd.DataFrame, bool]:
163
+ self, data: Optional[Union["DataFrame", "Series"]]
164
+ ) -> Tuple["DataFrame", bool]:
126
165
  """Convert supplied data to a DataFrame."""
166
+ # pylint: disable=import-outside-toplevel
167
+ from openbb_core.app.utils import basemodel_to_df, convert_to_basemodel
168
+ from pandas import DataFrame, Series
169
+
127
170
  has_data = (
128
- isinstance(data, (Data, pd.DataFrame, pd.Series)) and not data.empty # type: ignore
171
+ isinstance(data, (Data, DataFrame, Series)) and not data.empty # type: ignore
129
172
  ) or (bool(data))
130
173
  index = (
131
174
  data.index.name
132
- if has_data and isinstance(data, (pd.DataFrame, pd.Series))
175
+ if has_data and isinstance(data, (DataFrame, Series))
133
176
  else None
134
177
  )
135
- data_as_df: pd.DataFrame = (
178
+ data_as_df: DataFrame = (
136
179
  basemodel_to_df(convert_to_basemodel(data), index=index)
137
180
  if has_data
138
181
  else self._obbject.to_dataframe(index=index)
@@ -149,11 +192,11 @@ class Charting:
149
192
  data: Union[
150
193
  list,
151
194
  dict,
152
- pd.DataFrame,
153
- List[pd.DataFrame],
154
- pd.Series,
155
- List[pd.Series],
156
- np.ndarray,
195
+ "DataFrame",
196
+ List["DataFrame"],
197
+ "Series",
198
+ List["Series"],
199
+ "ndarray",
157
200
  Data,
158
201
  ],
159
202
  index: Optional[str] = None,
@@ -172,12 +215,12 @@ class Charting:
172
215
  same_axis: bool = False,
173
216
  render: bool = True,
174
217
  **kwargs,
175
- ) -> Union[OpenBBFigure, Figure, None]:
218
+ ) -> Union["OpenBBFigure", "Figure", None]:
176
219
  """Create a line chart from external data and render a chart or return the OpenBBFigure.
177
220
 
178
221
  Parameters
179
222
  ----------
180
- data : Union[Data, pd.DataFrame, pd.Series]
223
+ data : Union[Data, DataFrame, Series]
181
224
  Data to be plotted (OHLCV data).
182
225
  index : Optional[str], optional
183
226
  Index column, by default None
@@ -215,6 +258,9 @@ class Charting:
215
258
  **kwargs: Dict[str, Any]
216
259
  Extra parameters to be passed to `figure.show()`
217
260
  """
261
+ # pylint: disable=import-outside-toplevel
262
+ from openbb_charting.charts.generic_charts import line_chart
263
+
218
264
  fig = line_chart(
219
265
  data=data,
220
266
  index=index,
@@ -244,11 +290,11 @@ class Charting:
244
290
  data: Union[
245
291
  list,
246
292
  dict,
247
- pd.DataFrame,
248
- List[pd.DataFrame],
249
- pd.Series,
250
- List[pd.Series],
251
- np.ndarray,
293
+ "DataFrame",
294
+ List["DataFrame"],
295
+ "Series",
296
+ List["Series"],
297
+ "ndarray",
252
298
  Data,
253
299
  ],
254
300
  x: str,
@@ -266,12 +312,12 @@ class Charting:
266
312
  bar_kwargs: Optional[Dict[str, Any]] = None,
267
313
  render: bool = True,
268
314
  **kwargs,
269
- ) -> Union[OpenBBFigure, Figure, None]:
315
+ ) -> Union["OpenBBFigure", "Figure", None]:
270
316
  """Create a bar chart on a single x-axis with one or more values for the y-axis.
271
317
 
272
318
  Parameters
273
319
  ----------
274
- data : Union[list, dict, pd.DataFrame, List[pd.DataFrame], pd.Series, List[pd.Series], np.ndarray, Data]
320
+ data : Union[list, dict, DataFrame, List[DataFrame], Series, List[Series], ndarray, Data]
275
321
  Data to plot.
276
322
  x : str
277
323
  The x-axis column name.
@@ -298,6 +344,9 @@ class Charting:
298
344
  OpenBBFigure
299
345
  The OpenBBFigure object.
300
346
  """
347
+ # pylint: disable=import-outside-toplevel
348
+ from openbb_charting.charts.generic_charts import bar_chart
349
+
301
350
  fig = bar_chart(
302
351
  data=data,
303
352
  x=x,
@@ -326,28 +375,19 @@ class Charting:
326
375
  self._obbject._route # pylint: disable=protected-access
327
376
  )
328
377
  kwargs["obbject_item"] = self._obbject.results
329
- kwargs["charting_settings"] = self._charting_settings
330
- if (
331
- hasattr(self._obbject, "_standard_params")
332
- and self._obbject._standard_params # pylint: disable=protected-access
333
- ):
334
- kwargs["standard_params"] = (
335
- self._obbject._standard_params.__dict__ # pylint: disable=protected-access
336
- )
337
- kwargs["provider"] = (
338
- self._obbject.provider
339
- ) # pylint: disable=protected-access
340
- kwargs["extra"] = self._obbject.extra # pylint: disable=protected-access
341
-
342
- if "kwargs" in kwargs:
343
- _kwargs = kwargs.pop("kwargs")
344
- kwargs.update(_kwargs.get("chart_params", {}))
378
+ kwargs["charting_settings"] = self._charting_settings #
379
+ kwargs["standard_params"] = (
380
+ self._obbject._standard_params # pylint: disable=protected-access
381
+ )
382
+ kwargs["extra_params"] = (
383
+ self._obbject._extra_params # pylint: disable=protected-access
384
+ )
385
+ kwargs["provider"] = self._obbject.provider
386
+ kwargs["extra"] = self._obbject.extra
345
387
  fig, content = charting_function(**kwargs)
346
388
  fig = self._set_chart_style(fig)
347
389
  content = fig.show(external=True, **kwargs).to_plotly_json()
348
- self._obbject.chart = Chart(
349
- fig=fig, content=content, format=charting_router.CHART_FORMAT
350
- )
390
+ self._obbject.chart = Chart(fig=fig, content=content, format=self._format)
351
391
  if render:
352
392
  fig.show(**kwargs)
353
393
  except Exception: # pylint: disable=W0718
@@ -356,7 +396,7 @@ class Charting:
356
396
  fig = self._set_chart_style(fig)
357
397
  content = fig.show(external=True, **kwargs).to_plotly_json() # type: ignore
358
398
  self._obbject.chart = Chart(
359
- fig=fig, content=content, format=charting_router.CHART_FORMAT
399
+ fig=fig, content=content, format=self._format
360
400
  )
361
401
  if render:
362
402
  return fig.show(**kwargs) # type: ignore
@@ -372,11 +412,11 @@ class Charting:
372
412
  Union[
373
413
  list,
374
414
  dict,
375
- pd.DataFrame,
376
- List[pd.DataFrame],
377
- pd.Series,
378
- List[pd.Series],
379
- np.ndarray,
415
+ "DataFrame",
416
+ List["DataFrame"],
417
+ "Series",
418
+ List["Series"],
419
+ "ndarray",
380
420
  Data,
381
421
  ]
382
422
  ] = None,
@@ -398,7 +438,7 @@ class Charting:
398
438
 
399
439
  Parameters
400
440
  ----------
401
- data : Union[Data, pd.DataFrame, pd.Series]
441
+ data : Union[Data, DataFrame, Series]
402
442
  Data to be plotted.
403
443
  indicators : Dict[str, Dict[str, Any]], optional
404
444
  Indicators to be plotted, by default None
@@ -450,22 +490,14 @@ class Charting:
450
490
  kwargs["index"] = index
451
491
  kwargs["obbject_item"] = self._obbject.results
452
492
  kwargs["charting_settings"] = self._charting_settings
453
- if (
454
- hasattr(self._obbject, "_standard_params")
455
- and self._obbject._standard_params # pylint: disable=protected-access
456
- ):
457
- kwargs["standard_params"] = (
458
- self._obbject._standard_params.__dict__ # pylint: disable=protected-access
459
- )
460
- kwargs["provider"] = self._obbject.provider # pylint: disable=protected-access
461
- kwargs["extra"] = self._obbject.extra # pylint: disable=protected-access
462
- metadata = kwargs["extra"].get("metadata")
493
+ kwargs["standard_params"] = (
494
+ self._obbject._standard_params # pylint: disable=protected-access
495
+ )
463
496
  kwargs["extra_params"] = (
464
- metadata.arguments.get("extra_params") if metadata else None
497
+ self._obbject._extra_params # pylint: disable=protected-access
465
498
  )
466
- if "kwargs" in kwargs:
467
- _kwargs = kwargs.pop("kwargs")
468
- kwargs.update(_kwargs.get("chart_params", {}))
499
+ kwargs["provider"] = self._obbject.provider # pylint: disable=protected-access
500
+ kwargs["extra"] = self._obbject.extra # pylint: disable=protected-access
469
501
  try:
470
502
  if has_data:
471
503
  self.show(data=data_as_df, render=render, **kwargs)
@@ -477,7 +509,7 @@ class Charting:
477
509
  fig = self._set_chart_style(fig)
478
510
  content = fig.show(external=True, **kwargs).to_plotly_json() # type: ignore
479
511
  self._obbject.chart = Chart(
480
- fig=fig, content=content, format=charting_router.CHART_FORMAT
512
+ fig=fig, content=content, format=self._format
481
513
  )
482
514
  if render:
483
515
  return fig.show(**kwargs) # type: ignore
@@ -486,9 +518,9 @@ class Charting:
486
518
  "Failed to automatically create a generic chart with the data provided."
487
519
  ) from e
488
520
 
489
- def _set_chart_style(self, figure: Figure):
521
+ def _set_chart_style(self, figure: "Figure"):
490
522
  """Set the user preference for light or dark mode."""
491
- style = self._charting_settings.chart_style # pylint: disable=protected-access
523
+ style = self._charting_settings.chart_style
492
524
  font_color = "black" if style == "light" else "white"
493
525
  paper_bgcolor = "white" if style == "light" else "black"
494
526
  figure = figure.update_layout(
@@ -498,7 +530,7 @@ class Charting:
498
530
  )
499
531
  return figure
500
532
 
501
- def toggle_chart_style(self): # pylint: disable=protected-access
533
+ def toggle_chart_style(self):
502
534
  """Toggle the chart style between light and dark mode."""
503
535
  if not hasattr(self._obbject.chart, "fig"):
504
536
  raise ValueError(
@@ -516,21 +548,24 @@ class Charting:
516
548
 
517
549
  def table(
518
550
  self,
519
- data: Optional[Union[pd.DataFrame, pd.Series]] = None,
551
+ data: Optional[Union["DataFrame", "Series"]] = None,
520
552
  title: str = "",
521
553
  ):
522
554
  """Display an interactive table.
523
555
 
524
556
  Parameters
525
557
  ----------
526
- data : Optional[Union[pd.DataFrame, pd.Series]], optional
558
+ data : Optional[Union[DataFrame, Series]], optional
527
559
  Data to be plotted, by default None.
528
560
  If no data is provided the OBBject results will be used.
529
561
  title : str, optional
530
562
  Title of the table, by default "".
531
563
  """
564
+ # pylint: disable=import-outside-toplevel
565
+ from pandas import RangeIndex
566
+
532
567
  data_as_df, _ = self._prepare_data_as_df(data)
533
- if isinstance(data_as_df.index, pd.RangeIndex):
568
+ if isinstance(data_as_df.index, RangeIndex):
534
569
  data_as_df.reset_index(inplace=True, drop=True)
535
570
  else:
536
571
  data_as_df.reset_index(inplace=True)
@@ -546,9 +581,7 @@ class Charting:
546
581
  warn(f"Failed to show figure with backend. {e}")
547
582
 
548
583
  else:
549
- from plotly import ( # pylint:disable=import-outside-toplevel
550
- optional_imports,
551
- )
584
+ from plotly import optional_imports
552
585
 
553
586
  ipython_display = optional_imports.get_module("IPython.display")
554
587
  if ipython_display: