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

fix(vx-legend): Fix label generation in Threshold legend #612

Merged
merged 2 commits into from
Jan 26, 2020

Conversation

williaster
Copy link
Collaborator

🐛 Bug Fix

This PR closes #605 where @vx/legend's LegendThreshold does not generate the correct number of labels after the TS re-write.

More context
Without a major refactor, the base Legend generates its labels from the domain of the input scale. However for threshold (and quantile) scales, if the domain contains n threshold values, the range should include n+1 values to capture both the less than domain[0] and greater than domain[1] intervals of the thresholds.

The fix

  • Previously this wasn't accounted for and thus LegendThreshold did not include the last value in range as seen in the linked issue. This updates LegendThreshold to instead behave like LegendQuantile to effectively allow label generation from the range values.

  • This PR also updates the Legends demo to use a valid threshold scale with n domain and n+1 range values.

Before
image

After
image

@hshoff @camille-s @kristw

@williaster williaster merged commit e950b93 into master Jan 26, 2020
@williaster williaster deleted the chris--ts-threshold-legend-fix branch January 26, 2020 22:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

LegendThreshold not including last value
2 participants