Skip to content

Am struggling with setting initial data and updating chart data #1516

Closed Answered by SlicedSilver
iphyman asked this question in Q&A
Discussion options

You must be logged in to vote

You are looking for the update function on the SeriesAPI.
So the use setData when you want to replace all the data (or set the initial data) for a series, and then use update when you want to provide realtime updates (only the last bar can be updated, or a new bar added at a newer time).

See this documentation for more details: https://tradingview.github.io/lightweight-charts/docs#setting-and-updating-a-data

Finally, if you are using React then try not to create the chart on each change but rather create it once and use the setData / update / applyOptions methods to make changes to the chart.

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by iphyman
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants