Skip to content
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

Unable to use all null data in timeseries with VictoryStack #2844

Open
2 tasks done
PeterYurkovich opened this issue Apr 1, 2024 · 0 comments
Open
2 tasks done

Unable to use all null data in timeseries with VictoryStack #2844

PeterYurkovich opened this issue Apr 1, 2024 · 0 comments
Labels
Type: Bug 🐛 Oh no! A bug or unintentional behavior

Comments

@PeterYurkovich
Copy link

PeterYurkovich commented Apr 1, 2024

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

Code Sandbox link

https://codesandbox.io/p/sandbox/victory-starter-forked-3gxgkt?file=%2Fsrc%2FApp.tsx

Bug report

VictoryStack supports null values in the VictoryArea data, except in the instance where all values are null, x values are dates, and there are multiple VictoryAreas. In this case VictoryStack crashes.

This is due to filtering out all null values before determining if the array of data uses dates as the x data.

function stackData(props, childComponents) {
  const dataFromChildren = Wrapper.getDataFromChildren(props, childComponents);
  const filterNullChildData = dataFromChildren.map((dataset) =>
    dataset.filter((datum) => datum._x !== null && datum._y !== null),
  );
  const datasets = fillData(props, filterNullChildData);
  return datasets.map((d, i) => addLayoutData(props, datasets, i));
}

The dataset being passed into fillData is empty, and so when inside fill data it is checked if the x value is a date, it returns a falsey value (undefined).

const isDate = dataset[0] && dataset[0]._x instanceof Date;

This causes the return from fillData to place unix timestamps instead of JS date objects in the x value. Once this new dataset is passed into addLayoutData it sees the other VictoryArea uses JS Dates, and so tries to call a date function (getTime) on a unix timestamp.

This can be solved by waiting to filter the null values out until the isDate is determined so that a Date object will be returned rather than a unix timestamp.

Steps to reproduce

Steps to reproduce behavior:

  1. Added Code Sandbox link Code Sandbox

Expected behavior

VictoryStack should render even if one VictoryArea is only null values.

Actual behavior

JS error occurs and the chart does not render.

Environment

- Device: Desktop
- OS: MacOS 14.4.1
- Browser: Firefox, Chrome, Arc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug 🐛 Oh no! A bug or unintentional behavior
Projects
None yet
Development

No branches or pull requests

1 participant