FormidableLabs / victory

A collection of composable React components for building interactive data visualizations
http://commerce.nearform.com/open-source/victory/
Other
11.03k stars 524 forks source link

fix/bars-disappear-on-zoom #2970

Closed nstolpe closed 4 days ago

nstolpe commented 1 week ago

Description

Addresses the issue where bar chart items more than 50% out of their chart area when zoomed disappear completely, as the bar middle point was being used to determine whether they should be culled from view.

Fixes # 2905

Type of Change

How Has This Been Tested?

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

Original video from issue:

https://github.com/user-attachments/assets/311b9725-00b7-4867-a539-90f9dc8e125e

Video after fix:

https://github.com/user-attachments/assets/965e120c-73ee-43bc-9923-33a666e56e85

vercel[bot] commented 1 week ago

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

Name Status Preview Updated (UTC)
victory ✅ Ready (Inspect) Visit Preview Nov 18, 2024 9:14pm
changeset-bot[bot] commented 1 week ago

🦋 Changeset detected

Latest commit: 210b9b00a4cf20555b0e1c1b32c24fa665e3fd9b

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

This PR includes changesets to release 30 packages | Name | Type | | --------------------------- | ----- | | victory-bar | Patch | | victory-core | Patch | | victory-canvas | Patch | | victory-histogram | Patch | | victory | Patch | | victory-area | Patch | | victory-axis | Patch | | victory-box-plot | Patch | | victory-brush-container | Patch | | victory-brush-line | Patch | | victory-candlestick | Patch | | victory-chart | Patch | | victory-create-container | Patch | | victory-cursor-container | Patch | | victory-errorbar | Patch | | victory-group | Patch | | victory-legend | Patch | | victory-line | Patch | | victory-pie | Patch | | victory-polar-axis | Patch | | victory-scatter | Patch | | victory-selection-container | Patch | | victory-shared-events | Patch | | victory-stack | Patch | | victory-tooltip | Patch | | victory-voronoi-container | Patch | | victory-voronoi | Patch | | victory-zoom-container | Patch | | victory-native | Patch | | victory-vendor | 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

nstolpe commented 1 week ago

@carbonrobot this fixes the issue in 2905, in a way that I don't think is going to conflict with anything else. There's a lot of jumping around in logic, from the actual component class, to its helper methods, into data, and into domain as well. I don't think this the best way to fix it in terms of code maintainability and understandability, but I think to have a better fix would require a larger refactor, which seems like something coming in the future. There might also be a slightly cleaner check than component.type.displayName, I'll take a look into that refactor once I get your thoughts and see if you'd definitely like to go this route.

github-actions[bot] commented 1 week ago
Folder/File Previous size New size Difference
/packages/victory/dist/victory.min.js 385.59KB 385.76KB +0.17KB (+0.04%)
TOTAL +0.17KB
nstolpe commented 1 week ago

After seeing @nlkluth's solution here, I gave a try at subclassing VictoryBar and overriding renderData, getBaseProps and getCalculatedValues from the EventsMixin in the derived class to see if this could be accomplished without modifying internal packages (aside from exposing an export or 2). Unfortunately, the overrides got out of control, each additional one triggering an error that required another. I think what's here might be the best way to go at this point.