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

Sorted numerical values #2924

Closed
wants to merge 3 commits into from
Closed

Sorted numerical values #2924

wants to merge 3 commits into from

Conversation

nlkluth
Copy link
Member

@nlkluth nlkluth commented Oct 17, 2024

Description

Uses sorted values if a sortKey is specified when x is a number

Fixes #2881

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

To reproduce, create a bar chart that has numerical x values and specify a sortKey
NOTE: There may be a different bug in that a key of y won't sort, you have to name it and use the y prop to specify your value, and then sort off that value Ex:

<VictoryBar
  data={data2015}
  y="earnings"
  sortKey="earnings"
/>

Unsorted, numerical values will attempt to space along independent axis:

<VictoryChart domainPadding={20} theme={VictoryTheme.material}>
  <VictoryAxis />
  <VictoryAxis dependentAxis tickFormat={(x) => `$${x / 1000}k`} />
  <VictoryBar
      data={[
          { x: 1, earnings: 18000 },
          { x: 2, earnings: 13250 },
          { x: 3, earnings: 15000 },
          { x: 14, earnings: 12000 },
       ]}
       y="earnings"
    />
</VictoryChart>

Screenshot 2024-10-17 at 10 22 56 AM

Sorting this data with sortKey now sorts the bars (this is the fix):
Screenshot 2024-10-17 at 10 25 46 AM

Notice that the spacing is no longer applied, since sorting breaks down any sort of relative comparisons. This also means axis labels must be managed, but I don't feel like either of those two scenarios are new or regressions.

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 all builds, tests, and linting and all checks pass
  • 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 Oct 17, 2024

⚠️ No Changeset found

Latest commit: 0770da2

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

Copy link

vercel bot commented Oct 17, 2024

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

1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
victory ⬜️ Ignored (Inspect) Oct 17, 2024 4:27pm

@nlkluth nlkluth closed this Oct 17, 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
Development

Successfully merging this pull request may close these issues.

Sorting doesn't work if data for both axis is numeric
1 participant