Charts¶
This page contains a reference to all chart objects that can be used within the library.
They inherit from AbstractChart.
- class Chart(width: int, height: int, x: int, y: int, title: str, screen: int, on_top: bool, maximize: bool, debug: bool, toolbox: bool, inner_width: float, inner_height: float, scale_candles_only: bool)¶
The main object used for the normal functionality of lightweight-charts-python, built on the pywebview library.
The
screenparameter defines which monitor the chart window will open on, given as an index (primary monitor = 0).Important
The
Chartobject should be defined within anif __name__ == '__main__'block.
- show(block: bool)¶
Shows the chart window, blocking until the chart has loaded. If
blockis enabled, the method will block code execution until the window is closed.
- hide()¶
Hides the chart window, which can be later shown by calling
chart.show().
- exit()¶
Exits and destroys the chart window.
- async show_async()¶
Show the chart asynchronously.
- screenshot(block: bool) bytes¶
Takes a screenshot of the chart, and returns a bytes object containing the image. For example:
if __name__ == '__main__': chart = Chart() df = pd.read_csv('ohlcv.csv') chart.set(df) chart.show() img = chart.screenshot() with open('screenshot.png', 'wb') as f: f.write(img)
Important
This method should be called after the chart window has loaded.
- class QtChart(widget: QWidget)¶
The
QtChartobject allows the use of charts within aQMainWindowobject, and has similar functionality to theChartobject for manipulating data, configuring and styling.Either the
PyQt5,PyQt6orPySide6libraries will work with this chart.Callbacks can be received through the Qt event loop.
- get_webview() QWebEngineView¶
Returns the
QWebEngineViewobject.
- class WxChart(parent: WxPanel)¶
The WxChart object allows the use of charts within a
wx.Frameobject, and has similar functionality to theChartobject for manipulating data, configuring and styling.Callbacks can be received through the Wx event loop.
- get_webview() wx.html2.WebView¶
Returns a
wx.html2.WebViewobject which can be used to for positioning and styling within wxPython.
- class StreamlitChart¶
The
StreamlitChartobject allows the use of charts within a Streamlit app, and has similar functionality to theChartobject for manipulating data, configuring and styling.This object only supports the displaying of static data, and should not be used with the
update_from_tickorupdatemethods. Every call to the chart object must occur before callingload.
- load()¶
Loads the chart into the Streamlit app. This should be called after setting, styling, and configuring the chart, as no further calls to the
StreamlitChartwill be acknowledged.
- class JupyterChart¶
The
JupyterChartobject allows the use of charts within a notebook, and has similar functionality to theChartobject for manipulating data, configuring and styling.This object only supports the displaying of static data, and should not be used with the
update_from_tickorupdatemethods. Every call to the chart object must occur before callingload.
- load()¶
Renders the chart. This should be called after setting, styling, and configuring the chart, as no further calls to the
JupyterChartwill be acknowledged.