You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When you open the graph, it loads the position of the lines created with the toolbox and when you close the program it should save the coordinates of the lines in the drawings.json file.
Current Behaviour
When moving a created line, the following error appears in the terminal (I am using vcode):
Tracking (most recent recent calls):
File "C:\Users\Home\AppData\Local\Programs\Python\Python312\Lib\site-packages\lightweight_charts\widgets.py", line 64, in
self.webview.Bind(wx.html2.EVT_WEBVIEW_SCRIPT_MESSAGE_RECEIVED, lambda e: emit_callback(self, e.GetString()))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Home\AppData\Local\Programs\Python\Python312\Lib\site-packages\lightweight_charts\widgets.py", line 50, in emit_callback
func, args = parse_event_message(window, string)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Home\AppData\Local\Programs\Python\Python312\Lib\site-packages\lightweight_charts\util.py", line 33, in parse_event_message
func = window.handlers[name]
^^^^^^^^^^^^^^^
AttributeError: Object 'WxChart' does not have attribute 'controllers'
Reproducible Example
importpandasaspdfromlightweight_chartsimportChartimportreimportjsondefcalculate_sma(df, period: int=50):
returnpd.DataFrame({
'time': df['date'],
f'SMA {period}': df['close'].rolling(window=period).mean()
}).dropna()
defget_bar_data(symbol, timeframe):
#print(f'Archivo: {symbol}_{timeframe}.csv')ifsymbolnotin ('AAPL', 'GOOGL', 'TSLA'):
print(f'No data for "{symbol}"')
returnpd.DataFrame()
returnpd.read_csv(f'bar_data/{symbol}_{timeframe}.csv')
defon_search(chart, searched_string):
new_data=get_bar_data(searched_string, chart.topbar['timeframe'].value)
ifnew_data.empty:
returnchart.topbar['symbol'].set(searched_string)
chart.set(new_data)
# Load the drawings saved under the symbol.chart.toolbox.load_drawings(searched_string)
defon_timeframe_selection(chart):
new_data=get_bar_data(chart.topbar['symbol'].value, chart.topbar['timeframe'].value)
ifnew_data.empty:
return# The symbol has not changed, so we want to re-render the drawings.chart.set(new_data, render_drawings=True)
if__name__=='__main__':
chart=Chart(toolbox=True)
chart.legend(True)
chart.events.search+=on_searchchart.topbar.textbox('symbol', 'TSLA')
chart.topbar.switcher(
'timeframe',
('1min', '5min', '30min'),
default='1min',
func=on_timeframe_selection
)
df=get_bar_data('TSLA', '1min')
chart.set(df)
line=chart.create_line('SMA 20')
sma_data=calculate_sma(df, period=20)
line.set(sma_data)
line=chart.create_line('SMA 40','rgba(255,0,0,1)')
sma_data=calculate_sma(df, period=40)
line.set(sma_data)
# Imports the drawings saved in the JSON file.chart.toolbox.import_drawings('drawings.json')
# Loads the drawings under the default symbol.chart.toolbox.load_drawings(chart.topbar['symbol'].value)
# Saves drawings based on the symbol.chart.toolbox.save_drawings_under(chart.topbar['symbol'])
chart.show(block=True)
# Exports the drawings to the JSON file upon close.chart.toolbox.export_drawings('drawings.json')
Environment
- OS: Windows 11
- Library: 1.0.20
The text was updated successfully, but these errors were encountered:
Expected Behavior
When you open the graph, it loads the position of the lines created with the toolbox and when you close the program it should save the coordinates of the lines in the drawings.json file.
Current Behaviour
When moving a created line, the following error appears in the terminal (I am using vcode):
Tracking (most recent recent calls):
File "C:\Users\Home\AppData\Local\Programs\Python\Python312\Lib\site-packages\lightweight_charts\widgets.py", line 64, in
self.webview.Bind(wx.html2.EVT_WEBVIEW_SCRIPT_MESSAGE_RECEIVED, lambda e: emit_callback(self, e.GetString()))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Home\AppData\Local\Programs\Python\Python312\Lib\site-packages\lightweight_charts\widgets.py", line 50, in emit_callback
func, args = parse_event_message(window, string)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Home\AppData\Local\Programs\Python\Python312\Lib\site-packages\lightweight_charts\util.py", line 33, in parse_event_message
func = window.handlers[name]
^^^^^^^^^^^^^^^
AttributeError: Object 'WxChart' does not have attribute 'controllers'
Reproducible Example
Environment
The text was updated successfully, but these errors were encountered: