Search code examples
javascriptlightweight-charts

How do I update chart with new data in TradingView Lightweight charts


I am currently displaying an areaseries chart on a php page. The data gets populated during the initial page load which I fetch from database. Now I want to update the chart with duration, say for 1 week, 1 year etc. Couldn't find in the documentation as to how to delete the series or reload the chart with new data. I scoured the docs and github links but couldn't find what I was looking for.

Any pointers please.


Solution

  • if you use tradingview lightweight-charts library, you can use .update for example :

    lineSeries.update(data)
    candleSeries.update(data)
    areaSeries.update(data)
    

    The format of the data dictionary datas must be the same as the one you set them