Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why I cannot update the data that is set on the chart? #496

Open
TamijiMehrdad opened this issue Dec 9, 2024 · 0 comments
Open

Why I cannot update the data that is set on the chart? #496

TamijiMehrdad opened this issue Dec 9, 2024 · 0 comments

Comments

@TamijiMehrdad
Copy link

TamijiMehrdad commented Dec 9, 2024

Question

I used this library(version 1.0.22) 6 months ago but now my codes that worked that time doesn't work. I have several separate functions that I am sure they worked but now they doesn't work now. I check this by versions of 1.0.22, 2.0.1, and 2.1.0. The only thing that changed since 6 month ago, I changed my operation system from Ubuntu 22.04 to Ubuntu 24.04

The code is very easy and I used ohlcv.csv in example folder of this repository. I want to show all the candles and then start from first candle and add some text to that candle. I got this error:

Exception in thread Thread-2 (loop):
Traceback (most recent call last):
File "/../ml/lib/python3.10/site-packages/lightweight_charts/chart.py", line 89, in loop
window.evaluate_js(arg)
File "/../ml/lib/python3.10/site-packages/webview/window.py", line 48, in wrapper
return function(self, *args, **kwargs)
File "/../ml/lib/python3.10/site-packages/webview/window.py", line 459, in evaluate_js
raise JavascriptException(result)
webview.errors.JavascriptException: {'name': 'Error', 'message': 'Cannot update oldest data, last time=[object Object], new time=[object Object]', 'line': 7, 'column': 147441, 'sourceURL': 'http://127.0.0.1:16789/lightweight-charts.js', 'stack': 'Lb@http://127.0.0.1:16789/lightweight-charts.js:7:147441\ntw@http://127.0.0.1:16789/lightweight-charts.js:7:158601\nupdate@http://127.0.0.1:16789/lightweight-charts.js:7:153502\neval code@\neval@[native code]\nglobal code@http://127.0.0.1:16789/test.html:4:33'}

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/../ml/lib/python3.10/threading.py", line 1016, in _bootstrap_inner
self.run()
File "/../ml/lib/python3.10/threading.py", line 953, in run
self._target(*self._args, **self._kwargs)
File "/../ml/lib/python3.10/site-packages/lightweight_charts/chart.py", line 94, in loop
raise JavascriptException(f"\n\nscript -> '{arg}',\nerror -> {msg['name']}[{msg['line']}:{msg['column']}]\n{msg['message']}")
webview.errors.JavascriptException:

script -> 'window.qsygphzs.series.update({
"Unnamed: 0": 0,
"time": 1277769600.0,
"open": 1.2667,
"high": 1.6667,
"low": 1.1693,
"close": 1.5927,
"volume": 277519500.0
})',
error -> Error[7:147441]
Cannot update oldest data, last time=[object Object], new time=[object Object]

I know if I change the line chart.set(df1) to chart.set(df1[0:1]) to make sure chart._last_bar is correct, the problem would be solve but the problem is that in that situation I cannot see all the candles.

Code example

    chart = Chart()
    df1 = pd.read_csv('ohlcv.csv')
    chart.set(df1)
    chart.show()
    for i, series in df1.iterrows():
        chart.update(series)
        chart.marker(text='THIS')
    input()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant