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

add default upper and lower x/y bounds if single data point #237

Merged
merged 6 commits into from
Apr 18, 2024

Conversation

masiddee
Copy link
Contributor

@masiddee masiddee commented Apr 15, 2024

Description

Fixes issue #207

The problem here is we do not enforce at least 2 distinct data points, so whenever a user adds a data array with a single data point (or an array with multiple identical data points), we'd throw a duplicate key warning and the chart UI would break.

This fix simply checks the following: if the min and max bounds are the same, then manually append an upper and lower bound.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

Checklist: (Feel free to delete this section upon completion)

  • I have included a changeset if this change will require a version change to one of the packages.
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have run yarn run check:code and all checks pass
  • I have created a changeset for new features, patches, or major changes
  • I have added tests that prove my fix is effective or that my feature works
  • My changes generate no new warnings
  • Any dependent changes have been merged and published in downstream modules

Copy link

changeset-bot bot commented Apr 15, 2024

🦋 Changeset detected

Latest commit: 0f0bd87

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
victory-native Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

vercel bot commented Apr 15, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
victory-native-xl-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 17, 2024 10:41pm

Copy link
Contributor

@zibs zibs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Aside from the small comments

@zibs
Copy link
Contributor

zibs commented Apr 17, 2024

But I'm not 100% this is exactly what we want to do, have you tried using a Set to remove the duplicate ticks before rendering? That may be another option?

…midableLabs/victory-native-xl into bug/single-data-point-dupe-key-error
@masiddee
Copy link
Contributor Author

masiddee commented Apr 17, 2024

But I'm not 100% this is exactly what we want to do, have you tried using a Set to remove the duplicate ticks before rendering? That may be another option?

@zibs yep. I played around with using a Set, and it successfully resolves the duplicate keys warning, but it does not resolve the chart rendering weirdness. I also briefly played around with updating the types to enforce at least 2 data points, but felt that was an unnecessary restriction, as there could be a number of valid reasons a user would want to display a single data point graph.

Essentially, I figured my options were:

  • De-dupe the ticks array
  • Enforce 2 data point min in TS/Add a ListEmptyProp prop to display, as suggested on the issue
  • Massage the upper/lower bounds if single data point provided (✅ preferable, as it was least intrusive option, and neatly resolved the issues)

@zibs
Copy link
Contributor

zibs commented Apr 17, 2024

Dang! Yep okay, maybe this is the best option then! @keithluchtel Feel free to take a look if you want!

@masiddee masiddee linked an issue Apr 18, 2024 that may be closed by this pull request
@masiddee masiddee merged commit 9e7d736 into main Apr 18, 2024
3 checks passed
@masiddee masiddee deleted the bug/single-data-point-dupe-key-error branch April 18, 2024 13:55
@github-actions github-actions bot mentioned this pull request Apr 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants