openbb-charting 2.0.2__tar.gz → 2.0.3__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 (49) hide show
  1. {openbb_charting-2.0.2 → openbb_charting-2.0.3}/PKG-INFO +2 -2
  2. openbb_charting-2.0.3/openbb_charting/__init__.py +525 -0
  3. openbb_charting-2.0.3/openbb_charting/charting_router.py +1294 -0
  4. openbb_charting-2.0.3/openbb_charting/core/__init__.py +1 -0
  5. {openbb_charting-2.0.2 → openbb_charting-2.0.3}/openbb_charting/core/backend.py +1 -0
  6. openbb_charting-2.0.3/openbb_charting/core/config/__init__.py +1 -0
  7. {openbb_charting-2.0.2 → openbb_charting-2.0.3}/openbb_charting/core/config/openbb_styles.py +53 -17
  8. {openbb_charting-2.0.2 → openbb_charting-2.0.3}/openbb_charting/core/dummy_backend.py +7 -5
  9. {openbb_charting-2.0.2 → openbb_charting-2.0.3}/openbb_charting/core/openbb_figure.py +17 -19
  10. {openbb_charting-2.0.2 → openbb_charting-2.0.3}/openbb_charting/core/plotly.html +7 -7
  11. openbb_charting-2.0.3/openbb_charting/core/plotly_ta/__init__.py +1 -0
  12. {openbb_charting-2.0.2 → openbb_charting-2.0.3}/openbb_charting/core/plotly_ta/base.py +4 -2
  13. {openbb_charting-2.0.2 → openbb_charting-2.0.3}/openbb_charting/core/plotly_ta/data_classes.py +1 -1
  14. openbb_charting-2.0.3/openbb_charting/core/plotly_ta/plugins/__init__.py +1 -0
  15. {openbb_charting-2.0.2 → openbb_charting-2.0.3}/openbb_charting/core/plotly_ta/plugins/custom_indicators_plugin.py +14 -11
  16. {openbb_charting-2.0.2 → openbb_charting-2.0.3}/openbb_charting/core/plotly_ta/plugins/momentum_plugin.py +48 -45
  17. {openbb_charting-2.0.2 → openbb_charting-2.0.3}/openbb_charting/core/plotly_ta/plugins/overlap_plugin.py +6 -3
  18. {openbb_charting-2.0.2 → openbb_charting-2.0.3}/openbb_charting/core/plotly_ta/plugins/trend_indicators_plugin.py +4 -1
  19. {openbb_charting-2.0.2 → openbb_charting-2.0.3}/openbb_charting/core/plotly_ta/plugins/volatility_plugin.py +8 -8
  20. {openbb_charting-2.0.2 → openbb_charting-2.0.3}/openbb_charting/core/plotly_ta/plugins/volume_plugin.py +6 -3
  21. {openbb_charting-2.0.2 → openbb_charting-2.0.3}/openbb_charting/core/plotly_ta/ta_class.py +102 -38
  22. {openbb_charting-2.0.2 → openbb_charting-2.0.3}/openbb_charting/core/plotly_ta/ta_helpers.py +3 -2
  23. openbb_charting-2.0.3/openbb_charting/core/table.html +326 -0
  24. {openbb_charting-2.0.2 → openbb_charting-2.0.3}/openbb_charting/core/to_chart.py +1 -2
  25. openbb_charting-2.0.3/openbb_charting/query_params.py +834 -0
  26. openbb_charting-2.0.3/openbb_charting/styles/__init__.py +1 -0
  27. openbb_charting-2.0.3/openbb_charting/styles/colors.py +39 -0
  28. {openbb_charting-2.0.2 → openbb_charting-2.0.3}/openbb_charting/styles/default/dark.pltstyle.json +33 -22
  29. openbb_charting-2.0.3/openbb_charting/styles/default/light.pltstyle.json +142 -0
  30. openbb_charting-2.0.3/openbb_charting/utils/generic_charts.py +606 -0
  31. openbb_charting-2.0.3/openbb_charting/utils/helpers.py +94 -0
  32. openbb_charting-2.0.3/openbb_charting/utils/relative_rotation.py +582 -0
  33. {openbb_charting-2.0.2 → openbb_charting-2.0.3}/pyproject.toml +2 -2
  34. openbb_charting-2.0.2/openbb_charting/__init__.py +0 -214
  35. openbb_charting-2.0.2/openbb_charting/charting_router.py +0 -538
  36. openbb_charting-2.0.2/openbb_charting/core/__init__.py +0 -0
  37. openbb_charting-2.0.2/openbb_charting/core/config/__init__.py +0 -0
  38. openbb_charting-2.0.2/openbb_charting/core/plotly_ta/__init__.py +0 -0
  39. openbb_charting-2.0.2/openbb_charting/core/table.html +0 -2159
  40. openbb_charting-2.0.2/openbb_charting/query_params.py +0 -105
  41. openbb_charting-2.0.2/openbb_charting/styles/default/light.pltstyle.json +0 -871
  42. openbb_charting-2.0.2/openbb_charting/utils/helpers.py +0 -21
  43. {openbb_charting-2.0.2 → openbb_charting-2.0.3}/README.md +0 -0
  44. {openbb_charting-2.0.2 → openbb_charting-2.0.3}/openbb_charting/builder.py +0 -0
  45. {openbb_charting-2.0.2 → openbb_charting-2.0.3}/openbb_charting/core/assets/Terminal_icon.png +0 -0
  46. {openbb_charting-2.0.2 → openbb_charting-2.0.3}/openbb_charting/core/assets/plotly-2.24.2.min.js +0 -0
  47. {openbb_charting-2.0.2 → openbb_charting-2.0.3}/openbb_charting/core/chart_style.py +0 -0
  48. {openbb_charting-2.0.2 → openbb_charting-2.0.3}/openbb_charting/styles/default/tables.pltstyle.json +0 -0
  49. {openbb_charting-2.0.2 → openbb_charting-2.0.3}/openbb_charting/utils/__init__.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: openbb-charting
3
- Version: 2.0.2
3
+ Version: 2.0.3
4
4
  Summary: Charting extension for OpenBB
5
5
  Author: OpenBB Team
6
6
  Author-email: hello@openbb.co
@@ -11,7 +11,7 @@ Classifier: Programming Language :: Python :: 3.9
11
11
  Classifier: Programming Language :: Python :: 3.10
12
12
  Classifier: Programming Language :: Python :: 3.11
13
13
  Requires-Dist: nbformat (>=5.9.2,<6.0.0)
14
- Requires-Dist: openbb-core (>=1.1.5,<2.0.0)
14
+ Requires-Dist: openbb-core (>=1.1.6,<2.0.0)
15
15
  Requires-Dist: pandas-ta (>=0.3.14b,<0.4.0)
16
16
  Requires-Dist: plotly (>=5.17.0,<6.0.0)
17
17
  Requires-Dist: pywry (>=0.6.1,<0.7.0)
@@ -0,0 +1,525 @@
1
+ """OpenBB OBBject extension for charting."""
2
+
3
+ # pylint: disable=too-many-arguments,unused-argument
4
+
5
+ import warnings
6
+ from typing import (
7
+ Any,
8
+ Callable,
9
+ Dict,
10
+ List,
11
+ Literal,
12
+ Optional,
13
+ Tuple,
14
+ Union,
15
+ )
16
+ from warnings import warn
17
+
18
+ import numpy as np
19
+ import pandas as pd
20
+ from openbb_core.app.model.charts.chart import Chart
21
+ from openbb_core.app.model.extension import Extension
22
+ from openbb_core.app.model.obbject import OBBject
23
+ from openbb_core.app.utils import basemodel_to_df, convert_to_basemodel
24
+ from openbb_core.provider.abstract.data import Data
25
+ from plotly.graph_objs import Figure
26
+
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
36
+ )
37
+
38
+ ext = Extension(name="charting")
39
+
40
+
41
+ @ext.obbject_accessor
42
+ class Charting:
43
+ """
44
+ Charting extension.
45
+
46
+ Methods
47
+ -------
48
+ show
49
+ Display chart and save it to the OBBject.
50
+ to_chart
51
+ Redraw the chart and save it to the OBBject, with an optional entry point for Data.
52
+ functions
53
+ Return a list of Platform commands with charting functions.
54
+ get_params
55
+ Return the charting parameters for the function the OBBject was created from.
56
+ indicators
57
+ Return the list of the available technical indicators to use with the `to_chart` method and OHLC+V data.
58
+ table
59
+ Display an interactive table.
60
+ create_line_chart
61
+ Create a line chart from external data.
62
+ create_bar_chart
63
+ Create a bar chart, on a single x-axis with one or more values for the y-axis, from external data.
64
+ """
65
+
66
+ def __init__(self, obbject):
67
+ """Initialize Charting extension."""
68
+ # pylint: disable=import-outside-toplevel
69
+ from openbb_core.app.model.charts.charting_settings import ChartingSettings
70
+
71
+ self._obbject: OBBject = obbject
72
+ self._charting_settings = ChartingSettings(
73
+ user_settings=self._obbject._user_settings, # type: ignore
74
+ system_settings=self._obbject._system_settings, # type: ignore
75
+ )
76
+ self._backend: Backend = self._handle_backend()
77
+
78
+ @classmethod
79
+ def indicators(cls):
80
+ """
81
+ Return an instance of the IndicatorsParams class, containing all available indicators and their parameters.
82
+ Without assigning to a variable, it will print the the information to the console.
83
+ """
84
+ return IndicatorsParams()
85
+
86
+ @classmethod
87
+ def functions(cls):
88
+ """Return a list of the available functions."""
89
+ return get_charting_functions()
90
+
91
+ def _handle_backend(self) -> Backend:
92
+ """Create and start the backend."""
93
+
94
+ create_backend(self._charting_settings)
95
+ backend = get_backend()
96
+ backend.start(debug=self._charting_settings.debug_mode)
97
+ return backend
98
+
99
+ @staticmethod
100
+ def _get_chart_function(route: str) -> Callable:
101
+ """Given a route, it returns the chart function. The module must contain the given route."""
102
+
103
+ if route is None:
104
+ raise ValueError("OBBject was initialized with no function route.")
105
+ adjusted_route = route.replace("/", "_")[1:]
106
+ return getattr(charting_router, adjusted_route)
107
+
108
+ def get_params(self) -> ChartParams:
109
+ """
110
+ Return the ChartQueryParams class for the function the OBBject was created from.
111
+ Without assigning to a variable, it will print the docstring to the console.
112
+ """
113
+ if self._obbject._route is None: # pylint: disable=protected-access
114
+ raise ValueError("OBBject was initialized with no function route.")
115
+ charting_function = (
116
+ self._obbject._route # pylint: disable=protected-access
117
+ ).replace("/", "_")[1:]
118
+ if hasattr(ChartParams, charting_function):
119
+ return getattr(ChartParams, charting_function)()
120
+ raise ValueError(
121
+ f"Error: No chart parameters are defined for the route: {charting_function}"
122
+ )
123
+
124
+ def _prepare_data_as_df(
125
+ self, data: Optional[Union[pd.DataFrame, pd.Series]]
126
+ ) -> Tuple[pd.DataFrame, bool]:
127
+ """Convert supplied data to a DataFrame."""
128
+ has_data = (
129
+ isinstance(data, (Data, pd.DataFrame, pd.Series)) and not data.empty
130
+ ) or (bool(data))
131
+ index = (
132
+ data.index.name
133
+ if has_data and isinstance(data, (pd.DataFrame, pd.Series))
134
+ else None
135
+ )
136
+ data_as_df: pd.DataFrame = (
137
+ basemodel_to_df(convert_to_basemodel(data), index=index)
138
+ if has_data
139
+ else self._obbject.to_dataframe(index=index)
140
+ )
141
+ if "date" in data_as_df.columns:
142
+ data_as_df = data_as_df.set_index("date")
143
+ if "provider" in data_as_df.columns:
144
+ data_as_df.drop(columns="provider", inplace=True)
145
+ return data_as_df, has_data
146
+
147
+ # pylint: disable=too-many-locals
148
+ def create_line_chart(
149
+ self,
150
+ data: Union[
151
+ list,
152
+ dict,
153
+ pd.DataFrame,
154
+ List[pd.DataFrame],
155
+ pd.Series,
156
+ List[pd.Series],
157
+ np.ndarray,
158
+ Data,
159
+ ],
160
+ index: Optional[str] = None,
161
+ target: Optional[str] = None,
162
+ title: Optional[str] = None,
163
+ x: Optional[str] = None,
164
+ xtitle: Optional[str] = None,
165
+ y: Optional[Union[str, List[str]]] = None,
166
+ ytitle: Optional[str] = None,
167
+ y2: Optional[Union[str, List[str]]] = None,
168
+ y2title: Optional[str] = None,
169
+ layout_kwargs: Optional[dict] = None,
170
+ scatter_kwargs: Optional[dict] = None,
171
+ normalize: bool = False,
172
+ returns: bool = False,
173
+ same_axis: bool = False,
174
+ render: bool = True,
175
+ **kwargs,
176
+ ) -> Union[OpenBBFigure, Figure, None]:
177
+ """Create a line chart from external data and render a chart or return the OpenBBFigure.
178
+
179
+ Parameters
180
+ ----------
181
+ data : Union[Data, pd.DataFrame, pd.Series]
182
+ Data to be plotted (OHLCV data).
183
+ index : Optional[str], optional
184
+ Index column, by default None
185
+ target : Optional[str], optional
186
+ Target column to be plotted, by default None
187
+ title : Optional[str], optional
188
+ Chart title, by default None
189
+ x : Optional[str], optional
190
+ X-axis column, by default None
191
+ xtitle : Optional[str], optional
192
+ X-axis title, by default None
193
+ y : Optional[Union[str, List[str]]], optional
194
+ Y-axis column(s), by default None
195
+ If None are supplied, the layout is optimized for the contents of data.
196
+ Where many units/scales are present,
197
+ it will attempt to divide based on the range of values.
198
+ ytitle : Optional[str], optional
199
+ Y-axis title, by default None
200
+ y2 : Optional[Union[str, List[str]]], optional
201
+ Y2-axis column(s), by default None
202
+ y2title : Optional[str], optional
203
+ Y2-axis title, by default None
204
+ layout_kwargs : Optional[dict], optional
205
+ Additional Plotly Layout parameters for `fig.update_layout`, by default None
206
+ scatter_kwargs : Optional[dict], optional
207
+ Additional Plotly parameters applied on creation of each scatter plot, by default None
208
+ normalize : bool, optional
209
+ Normalize the data with Z-Score Standardization, by default False
210
+ returns : bool, optional
211
+ Convert the data to cumulative returns, by default False
212
+ same_axis: bool, optional
213
+ If True, forces all data onto the same Y-axis, by default False
214
+ render: bool, optional
215
+ If True, the chart will be rendered, by default True
216
+ **kwargs: Dict[str, Any]
217
+ Extra parameters to be passed to `figure.show()`
218
+ """
219
+ fig = line_chart(
220
+ data=data,
221
+ index=index,
222
+ target=target,
223
+ title=title,
224
+ x=x,
225
+ xtitle=xtitle,
226
+ y=y,
227
+ ytitle=ytitle,
228
+ y2=y2,
229
+ y2title=y2title,
230
+ layout_kwargs=layout_kwargs,
231
+ scatter_kwargs=scatter_kwargs,
232
+ normalize=normalize,
233
+ returns=returns,
234
+ same_axis=same_axis,
235
+ **kwargs,
236
+ )
237
+ if render:
238
+ return fig.show(**kwargs)
239
+
240
+ return fig
241
+
242
+ def create_bar_chart(
243
+ self,
244
+ data: Union[
245
+ list,
246
+ dict,
247
+ pd.DataFrame,
248
+ List[pd.DataFrame],
249
+ pd.Series,
250
+ List[pd.Series],
251
+ np.ndarray,
252
+ Data,
253
+ ],
254
+ x: str,
255
+ y: Union[str, List[str]],
256
+ barmode: Literal["group", "stack", "relative", "overlay"] = "group",
257
+ xtype: Literal[
258
+ "category", "multicategory", "date", "log", "linear"
259
+ ] = "category",
260
+ title: Optional[str] = None,
261
+ xtitle: Optional[str] = None,
262
+ ytitle: Optional[str] = None,
263
+ orientation: Literal["h", "v"] = "v",
264
+ colors: Optional[List[str]] = None,
265
+ layout_kwargs: Optional[Dict[str, Any]] = None,
266
+ bar_kwargs: Optional[Dict[str, Any]] = None,
267
+ render: bool = True,
268
+ **kwargs,
269
+ ) -> Union[OpenBBFigure, Figure, None]:
270
+ """Create a bar chart on a single x-axis with one or more values for the y-axis.
271
+
272
+ Parameters
273
+ ----------
274
+ data : Union[list, dict, pd.DataFrame, List[pd.DataFrame], pd.Series, List[pd.Series], np.ndarray, Data]
275
+ Data to plot.
276
+ x : str
277
+ The x-axis column name.
278
+ y : Union[str, List[str]]
279
+ The y-axis column name(s).
280
+ barmode : Literal["group", "stack", "relative", "overlay"], optional
281
+ The bar mode, by default "group".
282
+ xtype : Literal["category", "multicategory", "date", "log", "linear"], optional
283
+ The x-axis type, by default "category".
284
+ title : str, optional
285
+ The title of the chart, by default None.
286
+ xtitle : str, optional
287
+ The x-axis title, by default None.
288
+ ytitle : str, optional
289
+ The y-axis title, by default None.
290
+ colors: List[str], optional
291
+ Manually set the colors to cycle through for each column in 'y', by default None.
292
+ bar_kwargs : Dict[str, Any], optional
293
+ Additional keyword arguments to apply with figure.add_bar(), by default None.
294
+ layout_kwargs : Dict[str, Any], optional
295
+ Additional keyword arguments to apply with figure.update_layout(), by default None.
296
+ Returns
297
+ -------
298
+ OpenBBFigure
299
+ The OpenBBFigure object.
300
+ """
301
+
302
+ fig = bar_chart(
303
+ data=data,
304
+ x=x,
305
+ y=y,
306
+ barmode=barmode,
307
+ xtype=xtype,
308
+ title=title,
309
+ xtitle=xtitle,
310
+ ytitle=ytitle,
311
+ orientation=orientation,
312
+ colors=colors,
313
+ bar_kwargs=bar_kwargs,
314
+ layout_kwargs=layout_kwargs,
315
+ )
316
+
317
+ if render:
318
+ return fig.show(**kwargs)
319
+
320
+ return fig
321
+
322
+ # pylint: disable=inconsistent-return-statements
323
+ def show(self, render: bool = True, **kwargs):
324
+ """Display chart and save it to the OBBject."""
325
+
326
+ try:
327
+ charting_function = self._get_chart_function(
328
+ self._obbject._route # pylint: disable=protected-access
329
+ )
330
+ kwargs["obbject_item"] = self._obbject.results
331
+ kwargs["charting_settings"] = self._charting_settings
332
+ if (
333
+ hasattr(self._obbject, "_standard_params")
334
+ and self._obbject._standard_params # pylint: disable=protected-access
335
+ ):
336
+ kwargs["standard_params"] = (
337
+ self._obbject._standard_params.__dict__ # pylint: disable=protected-access
338
+ )
339
+ kwargs["provider"] = (
340
+ self._obbject.provider
341
+ ) # pylint: disable=protected-access
342
+ kwargs["extra"] = self._obbject.extra # pylint: disable=protected-access
343
+
344
+ if "kwargs" in kwargs:
345
+ _kwargs = kwargs.pop("kwargs")
346
+ kwargs.update(_kwargs.get("chart_params", {}))
347
+ fig, content = charting_function(**kwargs)
348
+ self._obbject.chart = Chart(
349
+ fig=fig, content=content, format=charting_router.CHART_FORMAT
350
+ )
351
+ if render:
352
+ fig.show(**kwargs)
353
+ except Exception:
354
+ try:
355
+ fig = self.create_line_chart(data=self._obbject.results, render=False, **kwargs) # type: ignore
356
+ content = fig.show(external=True, **kwargs).to_plotly_json() # type: ignore
357
+ self._obbject.chart = Chart(
358
+ fig=fig, content=content, format=charting_router.CHART_FORMAT
359
+ )
360
+ if render:
361
+ return fig.show(**kwargs) # type: ignore
362
+ except Exception as e:
363
+ raise RuntimeError(
364
+ "Failed to automatically create a generic chart with the data provided."
365
+ ) from e
366
+
367
+ # pylint: disable=too-many-locals,inconsistent-return-statements
368
+ def to_chart(
369
+ self,
370
+ data: Optional[
371
+ Union[
372
+ list,
373
+ dict,
374
+ pd.DataFrame,
375
+ List[pd.DataFrame],
376
+ pd.Series,
377
+ List[pd.Series],
378
+ np.ndarray,
379
+ Data,
380
+ ]
381
+ ] = None,
382
+ target: Optional[str] = None,
383
+ index: Optional[str] = None,
384
+ indicators: Optional[Dict[str, Dict[str, Any]]] = None,
385
+ symbol: str = "",
386
+ candles: bool = True,
387
+ volume: bool = True,
388
+ volume_ticks_x: int = 7,
389
+ render: bool = True,
390
+ **kwargs,
391
+ ):
392
+ """
393
+ Create an OpenBBFigure with user customizations (if any) and save it to the OBBject.
394
+ This function is used to populate, or re-populate, the OBBject with a chart using the data within
395
+ the OBBject or external data supplied via the `data` parameter.
396
+
397
+ This function modifies the original OBBject by overwriting the existing chart.
398
+
399
+ Parameters
400
+ ----------
401
+ data : Union[Data, pd.DataFrame, pd.Series]
402
+ Data to be plotted.
403
+ indicators : Dict[str, Dict[str, Any]], optional
404
+ Indicators to be plotted, by default None
405
+ symbol : str, optional
406
+ Symbol to be plotted. This is used for labels and titles, by default ""
407
+ candles : bool, optional
408
+ If True, candles will be plotted, by default True
409
+ volume : bool, optional
410
+ If True, volume will be plotted, by default True
411
+ volume_ticks_x : int, optional
412
+ Volume ticks, by default 7
413
+ render : bool, optional
414
+ If True, the chart will be rendered, by default True
415
+ kwargs: Dict[str, Any]
416
+ Extra parameters to be passed to the chart constructor.
417
+
418
+ Examples
419
+ --------
420
+ Plotting a time series with TA indicators
421
+
422
+ >>> from openbb import obb
423
+ >>> res = obb.equity.price.historical("AAPL")
424
+ >>> indicators = dict(
425
+ >>> sma=dict(length=[20,30,50]),
426
+ >>> adx=dict(length=14),
427
+ >>> rsi=dict(length=14),
428
+ >>> macd=dict(fast=12, slow=26, signal=9),
429
+ >>> bbands=dict(length=20, std=2),
430
+ >>> stoch=dict(length=14),
431
+ >>> ema=dict(length=[20,30,50]),
432
+ >>> )
433
+ >>> res.charting.to_chart(**{"indicators": indicators})
434
+
435
+ Get all the available indicators
436
+
437
+ >>> res = obb.equity.price.historical("AAPL")
438
+ >>> indicators = res.charting.indicators()
439
+ >>> indicators?
440
+ """
441
+ data_as_df, has_data = self._prepare_data_as_df(data) # type: ignore
442
+ if target is not None:
443
+ data_as_df = data_as_df[[target]]
444
+ kwargs["candles"] = candles
445
+ kwargs["volume"] = volume
446
+ kwargs["volume_ticks_x"] = volume_ticks_x
447
+ kwargs["indicators"] = indicators if indicators else {}
448
+ kwargs["symbol"] = symbol
449
+ kwargs["target"] = target
450
+ kwargs["index"] = index
451
+ kwargs["obbject_item"] = self._obbject.results
452
+ 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
+ if "kwargs" in kwargs:
463
+ _kwargs = kwargs.pop("kwargs")
464
+ kwargs.update(_kwargs.get("chart_params", {}))
465
+ try:
466
+ if has_data:
467
+ self.show(data=data_as_df, render=render, **kwargs)
468
+ else:
469
+ self.show(**kwargs, render=render)
470
+ except Exception:
471
+ try:
472
+ fig = self.create_line_chart(data=data_as_df, render=False, **kwargs)
473
+ content = fig.show(external=True, **kwargs).to_plotly_json() # type: ignore
474
+ self._obbject.chart = Chart(
475
+ fig=fig, content=content, format=charting_router.CHART_FORMAT
476
+ )
477
+ if render:
478
+ return fig.show(**kwargs) # type: ignore
479
+ except Exception as e:
480
+ raise RuntimeError(
481
+ "Failed to automatically create a generic chart with the data provided."
482
+ ) from e
483
+
484
+ def table(
485
+ self,
486
+ data: Optional[Union[pd.DataFrame, pd.Series]] = None,
487
+ title: str = "",
488
+ ):
489
+ """
490
+ Display an interactive table.
491
+
492
+ Parameters
493
+ ----------
494
+ data : Optional[Union[pd.DataFrame, pd.Series]], optional
495
+ Data to be plotted, by default None.
496
+ If no data is provided the OBBject results will be used.
497
+ title : str, optional
498
+ Title of the table, by default "".
499
+ """
500
+ data_as_df, _ = self._prepare_data_as_df(data)
501
+ if isinstance(data_as_df.index, pd.RangeIndex):
502
+ data_as_df.reset_index(inplace=True, drop=True)
503
+ else:
504
+ data_as_df.reset_index(inplace=True)
505
+ if self._backend.isatty:
506
+ try:
507
+ self._backend.send_table(
508
+ df_table=data_as_df,
509
+ title=title
510
+ or self._obbject._route, # pylint: disable=protected-access
511
+ theme=self._charting_settings.table_style,
512
+ )
513
+ except Exception as e:
514
+ warn(f"Failed to show figure with backend. {e}")
515
+
516
+ else:
517
+ from plotly import ( # pylint:disable=import-outside-toplevel
518
+ optional_imports,
519
+ )
520
+
521
+ ipython_display = optional_imports.get_module("IPython.display")
522
+ if ipython_display:
523
+ ipython_display.display(ipython_display.HTML(data_as_df.to_html()))
524
+ else:
525
+ warn("IPython.display is not available.")