Bogaat
Posts: 2
Joined: Tue Aug 16, 2016 11:14 am

Async lazy load plus dynamic data

Hey guys,
I setup a chart similar to the demo...
http://www.highcharts.com/stock/demo/lazy-loading
I have multiple tables storing averaged data and slice out depending on the extremes. The problem I have is trying to add data points at intervals and getting the slider to stick to the right with the new data. If I call setExtremes to make it stick, it kicks off afterSetExtremes and reloads the data for that range. This "works" but instead of just adding my new point...I am reloading that entire set. I am hoping for something for efficient. I thought about disabling the event, calling setExtremes and then re-enabling...terrible thought.
I poked around a bit in the code, but haven't come up with any tricks just yet. I have tried setting the stickToMax variable and then calling modifyBaseAxisExtremes manually...but no go. I am hoping someone has either solved this or has some good ideas. My data is there...but I have to click the scroller to see it. All thoughts are greatly appreciated!
Bogaat
Posts: 2
Joined: Tue Aug 16, 2016 11:14 am

Re: Async lazy load plus dynamic data

Well, I figured it out. Why is it you spin your wheels on code for hours and hours just to find a simple solution? I set a namespace level bool flag before calling setExtremes. In the afterSetExtremes function, I check to see if the flag is set before doing anything. At the end, I reset it. That way the afterSetExtremes code does not get used when updating at intervals. Done.
ak!!!!!
Posts: 5
Joined: Fri Feb 10, 2023 12:28 pm

Re: Async lazy load plus dynamic data

Hello Team,

I am also trying to combine async-loading/lazy-loading plus dynamic data. here is is the demo on code pen https://codepen.io/a-k-iiiii/pen/ZEqOWgR?editors=0110.
lazy loading working fine but main problem is when i move navigator scrollbar to right where we expect live data to update chart every 5 seconds but that is not happening (data is added in series every 5 seconds but can't see in main chart area also series is moving left as data keeps on adding).

one major reason i found is, we are not updating navigator as we have set "adaptToUpdatedData: false" which is must for lazy loading or it will go into loop.

@Boogat i tried what you mention in 2nd post but still it is not working when navigator is in extreme right end no data is visible.
User avatar
dawid.d
Posts: 848
Joined: Thu Oct 06, 2022 11:31 am

Re: Async lazy load plus dynamic data

Hello,

Thanks for the questions,
I'm glad, Bogaat, that you managed to solve the problem!

As for the second question, I think the problem is due to the third argument being set to 'true' in the addPoint methods, which causes the range to be shifted when adding live data. See the demo below, with disabled shifting.

Demo: https://jsfiddle.net/BlackLabel/gyabzns5/
API: https://api.highcharts.com/class-refere ... l#addPoint

Let me know if that was what you were looking for
Best regards
Dawid Draguła
Highcharts Developer
ak!!!!!
Posts: 5
Joined: Fri Feb 10, 2023 12:28 pm

Re: Async lazy load plus dynamic data

Hi david,

Thanks for your answers, it works!!!. one more doubt i have, if you will see in above codepen script i have kept navigator : {adaptToUpdatedData:true} is if fine? i hope that will not have any side impact ? because docs https://api.highcharts.com/highstock/na ... pdatedData says we need to keep it false when loading async/lazily
User avatar
dawid.d
Posts: 848
Joined: Thu Oct 06, 2022 11:31 am

Re: Async lazy load plus dynamic data

Hi,

I think that in your case this is the best solution and I don't foresee any side effects. The data is added to the series at an interval, so updating the navigator seems to be necessary.

Let me know if you have any further questions!
Best regards
Dawid Draguła
Highcharts Developer

Return to “Highcharts Stock”