Bug Fixes/Enhancements:
- Added the chart.spinner method, which when set to `True` shows a loading spinner on the chart (a nice visual for API calls, large datasets etc). - If an empty data frame is passed to set (eg.`chart.set(pd.DataFrame())`) the volume series and candle series will be cleared. - added the `cumulative_volume` parameter to `update_from_tick`, which adds the given volume tick onto the latest bar. - Added `vert_visible` and `horz_visible` parameters to `crosshair`. - Small style improvements to the searchbox and topbar. - Fixed a bug preventing callbacks within `WxChart` and `QtChart` Thanks to @emma-uw for the following fixes and enhancements! - Methods `hide_data`, `show_data` and `price_line` can be used within Charts, Subcharts and Lines to change the visibility of data, price lines, and the price line labels. - Added the `delete` method to Line, which irreversably deletes the Line on the chart as well as its objects in JavaScript and Python. - Added the `lines` common method, which returns a list of all Line objects for the chart. - Added the `fit` method to the common methods, which uses the `fitContent()` method from Lightweight Charts. - Fixed a big which caused synced SubCharts to be out of sync upon loading. BETA: Polygon.io integration - Added the `PolygonChart` and `polygon` method, allowing for direct integration of polygon.io’s API. - This feature is still in beta, and there will be a full announcement and update once the feature is complete!
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
import asyncio
|
||||
import webview
|
||||
import time
|
||||
import multiprocessing as mp
|
||||
import webview
|
||||
|
||||
from lightweight_charts.js import LWC, CALLBACK_SCRIPT, TopBar
|
||||
|
||||
@ -63,6 +64,7 @@ class Chart(LWC):
|
||||
if not topbar and not searchbox:
|
||||
return
|
||||
self.run_script(CALLBACK_SCRIPT)
|
||||
self.run_script(f'makeSpinner({self.id})')
|
||||
self.topbar = TopBar(self) if topbar else None
|
||||
self._make_search_box() if searchbox else None
|
||||
|
||||
@ -79,10 +81,18 @@ class Chart(LWC):
|
||||
self._q.put('show')
|
||||
if block:
|
||||
try:
|
||||
self._exit.wait()
|
||||
while 1:
|
||||
while not self._exit.is_set() and self.polygon._q.empty():
|
||||
time.sleep(0.05)
|
||||
continue
|
||||
if self._exit.is_set():
|
||||
self._exit.clear()
|
||||
return
|
||||
value = self.polygon._q.get_nowait()
|
||||
func, args = value[0], value[1:]
|
||||
func(*args)
|
||||
except KeyboardInterrupt:
|
||||
return
|
||||
self._exit.clear()
|
||||
|
||||
async def show_async(self, block=False):
|
||||
if not self.loaded:
|
||||
@ -94,17 +104,23 @@ class Chart(LWC):
|
||||
if block:
|
||||
try:
|
||||
while 1:
|
||||
while self._emit.empty() and not self._exit.is_set():
|
||||
await asyncio.sleep(0.1)
|
||||
while self._emit.empty() and not self._exit.is_set() and self.polygon._q.empty():
|
||||
await asyncio.sleep(0.05)
|
||||
if self._exit.is_set():
|
||||
self._exit.clear()
|
||||
return
|
||||
key, chart_id, arg = self._emit.get()
|
||||
self.api.chart = self._charts[chart_id]
|
||||
if widget := self.api.chart.topbar._widget_with_method(key):
|
||||
widget.value = arg
|
||||
await getattr(self.api, key)()
|
||||
else:
|
||||
await getattr(self.api, key)(arg)
|
||||
elif not self._emit.empty():
|
||||
key, chart_id, arg = self._emit.get()
|
||||
self.api.chart = self._charts[chart_id]
|
||||
if widget := self.api.chart.topbar._widget_with_method(key):
|
||||
widget.value = arg
|
||||
await getattr(self.api, key)()
|
||||
else:
|
||||
await getattr(self.api, key)(arg)
|
||||
continue
|
||||
value = self.polygon._q.get()
|
||||
func, args = value[0], value[1:]
|
||||
func(*args)
|
||||
except KeyboardInterrupt:
|
||||
return
|
||||
asyncio.create_task(self.show_async(block=True))
|
||||
@ -123,4 +139,3 @@ class Chart(LWC):
|
||||
self._exit.wait()
|
||||
self._process.terminate()
|
||||
del self
|
||||
|
||||
|
||||
Reference in New Issue
Block a user