-
Notifications
You must be signed in to change notification settings - Fork 317
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to fetch data from API in paginated manner using visibleRangeChanged event? #122
Comments
That's not how the library works. As documented here the library is "linked" to the datafeed that could itself be linked to some data providers. |
I think there might be some misunderstanding. I've seen examples of charts that fetch data in batches according to date, just like the one on moneycontrol.com. When the user first enters the chart, it shows the current day's data, and as they scroll down to previous dates, it fetches the data for those dates. https://www.moneycontrol.com/india/stockpricequote/finance-housing/idfc/IDF |
The link above does not seem to display a chart. I'll try to make it clearer. Let me know if that helps.
|
onVisibleRangeChanged will indeed trigger whenever the chart is moved around. But that does not necessarily mean that the chart will require data. But if it does then the chart will indicate to the datafeed the range of data expected. how would i get the range in datafeed.js? |
I wanna do this making subsequent requests bases on visible range, so that i can i provide data in paginated manner from the api. https://groww.in/charts/stocks/vodafone-idea-ltd |
The requested range should be "visible" within the
If you pay close attention to their app it's very similar to the one found on our demo website. They are doing an initial request that's way bigger than the visible range. It can easily be verified with the console where you don't see additional requests made past the initial load, until you go back in time. At some point the application will request data that will then be loaded and cached until the next time.
From the small logs, you can see that some data where requested by the library to the datafeed which was apparently not able to provide those data. Therefore the library is answering that it didn't get anything. |
Can you help me understand the error?
what does it means that barset is empty? the api is returning candles. maybe the issue is it's returning less candle than the library wants? i don't know i am having imposter syndrome rn xD |
Without the full logs it's hard to properly assess the situation but essentially it says that:
But the library didn't received any data or at least the datafeed returned an empty array. |
I'm trying to fetch data from an API in a paginated manner. I've noticed that the visibleRangeChanged event is triggered when the user scrolls or navigates through the chart. I'd like to use this event to fetch the next batch of data from the API.
However, I'm not sure how to implement this correctly. Can someone please provide an example or guidance on how to use the visibleRangeChanged event to fetch data from an API in a paginated manner?
The text was updated successfully, but these errors were encountered: