airbnb / visx

🐯 visx | visualization components
https://airbnb.io/visx
MIT License
19.4k stars 712 forks source link

LegendThreshold: Domain starting with a 1 returns undefined color #1828

Closed ZachBarbre closed 4 months ago

ZachBarbre commented 5 months ago

Hi y'all,

I found in <LegendThreshold /> that if you have the domain array of scaleThreshold start with a 1 the "Less than 1" rect doesn't color correctly. While testing it I also found that if you have only two negative items in the domain array you can end up with the same color in the middle legend item and the "more than" legend item.

You can see it in action here: https://codesandbox.io/p/sandbox/determined-sanne-4j7x4y?file=%2Fsrc%2FApp.js%3A11%2C20

I have a fix if you would like me to make a PR on it.

hshoff commented 5 months ago

Hi @ZachBarbre thanks for reporting this bug. Happy to review a PR

ZachBarbre commented 4 months ago

@hshoff Awesome. Thank you. PR is up.

hshoff commented 4 months ago

Confirmed fixed with @visx/legend@3.10.3

before: https://codesandbox.io/p/sandbox/determined-sanne-4j7x4y?file=%2Fsrc%2FApp.js%3A11%2C20 after: https://codesandbox.io/p/sandbox/determined-sanne-forked-k8zkm8?file=%2Fpackage.json%3A12%2C5-12%2C29

before after
image image