-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Loading data on Lazyloading #234
Comments
Can you please provide a bit more information regard your issue? Maybe provide some examples, screenshots, etc... |
Hello, |
Yeah, I've knew about lazyloading, but what's problem you faced with that? It shouldn't be hard to implement it with lightweight-charts. You can 1) load the code of the library async when an user scrolls to the chart and/or 2) load your data async to insert them to the chart. |
I'm going to close the issue. If you'll have any question or updates - feel free to re-open it. |
I also meet two difficultes with Lazy Loading.
|
@alexbom I'm not sure where it's related to LazyLoading itself... I'd suggest you create another issue(s) with your requests (please don't forget about providing jsfiddle-like examples 🙂) |
Yes we can do it, but there are some special cases. For example, a user can scroll chart using mouse wheel. How can we know when the user finished scrolling?
That's because we convert our internal info about visible range to time. We cannot determine what the time at the empty left edge of the chart without some extrapolation algorithm. But I agree that we can provide some additional information like the number of bars in the empty space or something like this. |
@kirchet That can easily be dealt with by using a timer, some delay after scrolling with the mouse, so that not every single scroll pings the API, for side drag, I like that usage of only loading after the click has ended. |
@timothymarois now there is a possibility to implement lazy loading, look at barsInLogicalRange function onVisibleLogicalRangeChanged(newVisibleLogicalRange) {
const barsInfo = series.barsInLogicalRange(newVisibleLogicalRange);
// if there less than 50 bars to the left of the visible area
if (barsInfo !== null && barsInfo.barsBefore < 50) {
// try to load additional historical data and prepend it to the series data
}
}
chart.timeScale().subscribeVisibleLogicalRangeChange(onVisibleLogicalRangeChanged);
You can do this right now on your side inside |
@kirchet Did you scuueed in your code? I can not update historical data with series.update method. |
You should replace all data if you want to add more history bars, you need to use |
@kirchet OK ,thank you very much |
I would like to know is there a possibility to save data on lazyloading mode, since I will be able to show also the data for more last days without any difficulties.
The text was updated successfully, but these errors were encountered: