* introducing fig on the chart model * charting manager to expect fig and content. also, adding a 1st example of its usage for stocks/load route * leveraging fig.show on command output * introducing the render_chart function * using render_chart() on the command output * drop to_plotly_json function * a way of removing fields from the api only * remove references to to_plotly_json * fix charting_router to use new convention on returning fig and content * adjustments on the builder script * ruff and black * typo * stocks_news chart implementation * repr on chart model * adding table style config * removing to_plotly_json from the charting manager * typo and a little change on the way to_table behaves so we can leverage inheritance * introducing OpenBBFigureTable as a workarround to have tables on the sdk * renaming to to_chart * multiples implementation * black
OpenBB Charting extension
This extension provides a charting library for OpenBB SDK.
The library includes:
- charting infrastructure based on Plotly and
- a set of charting components
- prebuilt charts for a set of commands that are available in built-in OpenBB SDK extensions
Installation
To install the extension, run the following command in this folder:
pip install .
PyWry dependency on Linux
The PyWry dependency handles display of interactive charts and tables in a separate window. It is installed automatically with the OpenBB Charting extension.
When using linux distributions, the PyWry dependency requires certain dependencies to be installed first.
Debian-based / Ubuntu / Mint:
sudo apt install libwebkit2gtk-4.0-dev
Arch Linux / Manjaro:
sudo pacman -S webkit2gtk
Fedora:
sudo dnf install gtk3-devel webkit2gtk3-devel
Usage
To use the extension is as simple as running any of the OpenBB SDK endpoints with the chart argument equals to True.
Here's an example how it would look like in a python interface:
from openbb import obb
stock_data = obb.stocks.load(symbol="TSLA", start_date="2023-01-01", provider="fmp", chart=True)
Which would result in an CommandOutput object containing a chart attribute, which contains plotly json data.
In order to actually display the chart, you need to call the show() method.
stock_data.show()
Note: The
show()method is only going to work either in a Jupyter Notebook or in a standalone python script where a PyWry based backend is properly initialized.