lightweight-charts-python icon indicating copy to clipboard operation
lightweight-charts-python copied to clipboard

delete lines by one click

Open anxi0us628 opened this issue 1 year ago • 2 comments

Question

Is it possible to delete all lines created with toolbox as one action? chart.lines() function returns nothing for those created by toolbox. I found clearDrawings() function in toolbox.js, but do not know how to use it my python code.

Code example

No response

anxi0us628 avatar Mar 11 '24 08:03 anxi0us628

Just like this:

def clear_drawings(chart):
    chart.run_script(f'if ({chart.id}.toolBox) {chart.id}.toolBox.clearDrawings()')

# add a button that will clear all lines created with toolbox when clicked
chart.topbar.button('clear', 'clear_drawings', func=clear_drawings)

I also implemented this function by referring to the js and python code. Some features are not implemented in Python.

HEUDavid avatar Mar 05 '25 03:03 HEUDavid

Question

Is it possible to delete all lines created with toolbox as one action? chart.lines() function returns nothing for those created by toolbox. I found clearDrawings() function in toolbox.js, but do not know how to use it my python code.是否可以一次性删除使用 toolbox 创建的所有行?chart.lines()函数对于由 toolbox 创建的行返回空值。我在 toolbox.js 中找到了 clearDrawings()函数,但不知道如何在 Python 代码中使用它。

Code example

No response  无响应

@anxi0us628

HEUDavid avatar Mar 05 '25 03:03 HEUDavid