-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Assertion failed: data must be asc ordered by time. TIME DIPLICATES #1700
Comments
I suspect that your |
Are the actual At some point you will be converting your |
Yeah of course i do some conversion into mili epoch using
|
The error is suggesting that there are some data points which are either duplicates or multiple data points for the same timestamp. This can sometimes occur when using external data sources that they will provide more than one data point for timestamp. For example:
You could log your data before providing it to |
@SlicedSilver it doesn't make sense. If I remove y.id !== x.id comparison, the script will return me all the initial array, because using y.id !== x.I find If my array has entries with the same time but different id. Id field is always unique. |
So you want to keep data points with the same timestamp as long as the ids are different? Therefore you are okay with this: [
{ currency_code: "BTC", id: 1161674, price: "62890.00", timestamp:, "2024-09-20T13:57:28.947Z" },
{ currency_code: "BTC", id: 1161675, price: "62892.00", timestamp:, "2024-09-20T13:57:28.947Z" }, // same timestamp as previous
] Well the library will see this as a problem because you have two data points at the same timestamp. Which one should it plot? because it can only plot one.
Therefore the |
if you want too keep duplicates an easy way is to pull that duplicates out of that array and add it to another series! |
Lightweight Charts™ Version: ^4.2.0
Steps/code to reproduce:
From the error I understand that I have the same time property for a few entries:
Assertion failed: data must be asc ordered by time, index=3, time=1727077163.929, prev time=1727077163.929;
I using data from the backend to get coin price history, approximately 400 items in the array.
Array item:
I have an endpoint that saves data in storage:
I added console.log to find duplications in the response data.
The findDuplicateDatesWithTime function:
But it logs me empty array every time(No duplicates have been found). So BE response is valid.
This is how I use timestamp from the response:
The strangest thing is that sometimes it works without any errors after the page refresh, but sometimes it crashes.
Tech stack: react, vite, lightweight-charts, typescript, redux-toolkit
Actual behavior:
Error Assertion failed: data must be asc ordered by time, index=3, time=1727077163.929, prev time=1727077163.929;
Expected behavior:
It should work whenever BE response has unique entries in the array
Screenshots:
CodeSandbox/JSFiddle/etc link:
The text was updated successfully, but these errors were encountered: