-
Notifications
You must be signed in to change notification settings - Fork 535
Open
Labels
Issue: StaleThis issue is marked as stale and will close in 14 daysThis issue is marked as stale and will close in 14 daysType: Bug 🐛Oh no! A bug or unintentional behaviorOh no! A bug or unintentional behavior
Description
Is there an existing issue for this?
- I have searched the existing issues
Code of Conduct
- I agree to follow this project's Code of Conduct
Victory version
37.3.6
Code Sandbox link
No response
Bug report
The fillData function in victory-stack's helper methods incorrectly assumes that the input dataset arrays are already sorted by _x. However, in many cases (such as the one shown below), the data comes in an unsorted order. This causes the function to mismatch x values during its map-reconstruction step, leading to missing or incorrect data in the final output.
This bug becomes especially problematic when the x values are timestamps and not sorted — the function uses index - indexOffset to try and realign the original data, which fails if the dataset is out of order.
Steps to reproduce
1. Pass in a datasets array containing multiple series where each dataset array is not sorted by _x values.
2. Ensure there are multiple unique _x values across datasets.
3. Call fillData(props, datasets) with fillInMissingData: true.
Here’s an example dataset that reproduces the issue:
const datasets = [
[
{ _x: 808470, _y: 1 },
{ _x: 1102244, _y: 0.42 },
{ _x: 1054475, _y: 0.23 },
]
];
Expected behavior
The function should produce a "filled" dataset that:
Retains all original data points (matched by _x)
Inserts synthetic points (y: 0 or null) only for missing x values across datasets
Matches _x values accurately, regardless of order in input dataset
Expected output:
[
{ _x: 808470, _y: 1, ... },
{ _x: 1054475, _y: 0.23, ... },
{ _x: 1102244, _y: 0.42, ... }
]
Actual behavior
Because the dataset is unsorted, the original function tries to access dataset[index - indexOffset], which may point to the wrong item. As a result:
Some actual values are skipped
Wrong data may be returned
Synthetic points may be inserted even when valid data exists
Environment
- Device: Mac
- OS: 15.5 (24F74)
- Node: 22.16.0
- pnpm: 10.11.1
Metadata
Metadata
Assignees
Labels
Issue: StaleThis issue is marked as stale and will close in 14 daysThis issue is marked as stale and will close in 14 daysType: Bug 🐛Oh no! A bug or unintentional behaviorOh no! A bug or unintentional behavior