[BUG] Adding multiple range_change subscribers causes errors [2.0]
Expected Behavior
.
Current Behaviour
Exception in thread Thread-2 (loop):
Traceback (most recent call last):
File "path/to/lightweight_charts/chart.py", line 89, in loop
window.evaluate_js(arg)
File "path/to/.venv/lib/site-packages/webview/window.py", line 50, in wrapper
return function(self, *args, **kwargs)
File "path/to/.venv/lib/site-packages/webview/window.py", line 455, in evaluate_js
raise JavascriptException(result)
webview.errors.JavascriptException: {'name': 'SyntaxError', 'stack': "SyntaxError: Identifier 'checkLogicalRange' has already been declared\n at
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "path/to/Python310/lib/threading.py", line 1016, in _bootstrap_inner self.run() File "path/to/Python310/lib/threading.py", line 953, in run self._target(*self._args, **self._kwargs) File "path/to/lightweight_charts/chart.py", line 94, in loop raise JavascriptException(f"\n\nscript -> '{arg}',\nerror -> {msg['name']}[{msg['line']}:{msg['column']}]\n{msg['message']}") KeyError: 'line'
Reproducible Example
import pandas as pd
from lightweight_charts import Chart
chart = Chart(inner_width=0.5)
sub_chart = chart.create_subchart(position="right", width=0.5, height=1)
df1 = pd.read_csv(f'./data.csv')
df2 = df1.copy()
chart.events.range_change += lambda chart, bef, aft: print(chart, bef, aft)
sub_chart.events.range_change += lambda chart, bef, aft: print(chart, bef, aft)
chart.set(df1)
sub_chart.set(df2)
if __name__ == "__main__":
chart.show(block=True)
Environment
- OS: Windows
- Library: 2.0 (cloned from latest commit: https://github.com/louisnw01/lightweight-charts-python/commit/906571e4fb1db01d28367648a76e8572fe14e29e)