nobody
Posts: 3
Joined: Tue Nov 09, 2021 4:30 pm

Update highcharts with loop data

Dear Highcharts Stock team,

I am having a stock data array that includes (ohlc, volumes).
I WANT TO UPDATE HIGHCHART AT 15s BY ADDING EACH POINT IN THIS ARRAY.
I want to update highchart at 15s by adding each point in this array from zero index to n-1 index with n is the length of stock data array.
When index reach to n-1, chart will readd point from zero index to n-1 index for the second time.

Would you please suggest / give a sample to me about updating stockcharts with the logic above ?
Your support is quite important to me.
I looked at the sample from Highcharts about updating chart dynamically at https://jsfiddle.net/btk8cv97/4/

I am looking forward to receiving your consultant soon.

Best regards,
mateusz.b
Posts: 2006
Joined: Tue Jul 13, 2021 11:34 am

Re: Update highcharts with loop data

Hi nobody,

Thanks for contacting us with your question.

Sorry, but the example is not entirely clear for me. It seems to me that you have an array of data that you want to add to a chart every 15 sec. To make it happen you can use for example setInterval method like in the demo. When it comes to the data, you said that it should add points of indexes from 0 to n - 1 where n is the length of the array, but doesn't that mean that you simply want to add a whole array? Then you mentioned repeating whole process, but the condition when it should happen is not clear for me. Frankly speaking such logic is not implemented in Highcharts anyway, and it sounds like you need to figure it out yourself.

Here are functions that most likely you need to use:
- some sort of setInterval to make it repeat every 15sec (setInterval, setTimeout)
- series.setData in case where you want to add more than a single point
- series.addPoint in case when you need to add only one point.

In case of any troubles with implementing it feel free to ask any further questions, but remember about posting a live demo with a sample data and more detailed description.

Regards!
Mateusz Bernacik
Highcharts Developer

Return to “Highcharts Stock”