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

ResponsiveBar - Custom minValue/maxValue axisBottom overflow #2226

Closed
eschoni opened this issue Jan 26, 2023 · 2 comments
Closed

ResponsiveBar - Custom minValue/maxValue axisBottom overflow #2226

eschoni opened this issue Jan 26, 2023 · 2 comments

Comments

@eschoni
Copy link

eschoni commented Jan 26, 2023

Overview
I am reporting an issue which I believe to be a bug with the ResponsiveBar component. I have read the ResponsiveBar documentation thoroughly. I believe the code I have is properly configured per the docs. Under the base section of the documentation there is the minValue and maxValue props which are set to "auto" by default. I am specifying custom number values for the minValue and maxValue.

Describe/explain the bug
The ResponsiveBar component bars overflow on the axisBottom when specifying custom number values for the minValue and maxValue props. There appears to be an issue with the bars calculating/rendering properly for the minValue causing the bottom of each bar to overflow beyond the minValue on the axisBottom of the chart.

To Reproduce
Here is the Codesandbox where I have included a minimal example to reproduce the issue.

Expected behavior
The bars in the chart should render properly based on the minValue/maxValue passed to the component and not overflow on the axisBottom.

Screenshots
Screen Shot 2023-01-26 at 10 48 58 AM

Desktop

  • macOS Version 12.6 (Build 21G115)
  • Chrome 108.0.5359.124 (Official Build) (arm64)
  • @nivo/core (0.80.0)
  • @nivo/bar (0.80.0)
@eschoni
Copy link
Author

eschoni commented Mar 2, 2023

Posted this question on Stack overflow and the user Scott Murphy had the answer. When specifying the min and max value you must include the "clamp: true" prop VIA valueScale for the chart to render properly when using custom min/max values.

<ResponsiveBar ... valueScale={{ type: 'linear', min: minVal * 0.8, max: maxVal * 1.2, clamp: true }} ... />

I didn't see that property anywhere in the docs.

I have update the Codesandbox example to reflect this.

Hopefully this helps someone else facing the same issue.

@eschoni eschoni closed this as completed Mar 2, 2023
@jarvin95
Copy link

jarvin95 commented Jun 4, 2024

Posted this question on Stack overflow and the user Scott Murphy had the answer. When specifying the min and max value you must include the "clamp: true" prop VIA valueScale for the chart to render properly when using custom min/max values.

<ResponsiveBar ... valueScale={{ type: 'linear', min: minVal * 0.8, max: maxVal * 1.2, clamp: true }} ... />

I didn't see that property anywhere in the docs.

I have update the Codesandbox example to reflect this.

Hopefully this helps someone else facing the same issue.

Owe you one, my man! Saved me hours

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

No branches or pull requests

2 participants