Enhancements and Bug Fixes

Tables Feature
- Added the `create_table` method, which returns a `Table` object. This can be used to display watchlists, order windows, position windows and more.
- See the new page on the docs for more information!

Bugs
- Fixed a bug preventing the named column of a line to not work as a label of the series.
- Fixed a bug causing drawings loaded from the minute timeframe to not show on a daily timeframe.
- Fixed a bug causing `chart.exit` to not work.
- Fixed a bug preventing the chart from being moved after placing a ray.
- Fixed the ‘price in hoveringOver’ web console error.

Enhancements
- The date/time column can also be the `name` of the passed series object.
- Added the `label` method to `HorizontalLine`, allowing for the price line label of horizontal lines to be updated.
- `None` or an empty DataFrame can now be passed to `line.set` as a means to clear it.
- Seperate Chart objects will now run on the same pywebview instance. This means that any Chart objects created after the first will inherit the first Chart’s API.
- Reorganized the documentation for clarity.
This commit is contained in:
louisnw
2023-08-02 13:47:52 +01:00
parent 77a70848fc
commit 06b605d3a7
20 changed files with 1289 additions and 871 deletions

View File

@ -1,6 +1,4 @@
import asyncio
import pandas as pd
from lightweight_charts import Chart
@ -15,24 +13,24 @@ class API:
def __init__(self):
self.chart: Chart = None # Changes after each callback.
async def on_search(self, searched_string): # Called when the user searches.
def on_search(self, searched_string): # Called when the user searches.
new_data = get_bar_data(searched_string, self.chart.topbar['timeframe'].value)
if new_data.empty:
return
self.chart.topbar['symbol'].set(searched_string)
self.chart.set(new_data)
async def on_timeframe_selection(self): # Called when the user changes the timeframe.
def on_timeframe_selection(self): # Called when the user changes the timeframe.
new_data = get_bar_data(self.chart.topbar['symbol'].value, self.chart.topbar['timeframe'].value)
if new_data.empty:
return
self.chart.set(new_data, render_drawings=True)
self.chart.set(new_data, True)
async def on_horizontal_line_move(self, line_id, price):
def on_horizontal_line_move(self, line_id, price):
print(f'Horizontal line moved to: {price}')
async def main():
if __name__ == '__main__':
api = API()
chart = Chart(api=api, topbar=True, searchbox=True, toolbox=True)
@ -46,8 +44,4 @@ async def main():
chart.horizontal_line(200, interactive=True)
await chart.show_async(block=True)
if __name__ == '__main__':
asyncio.run(main())
chart.show(block=True)