10000 Feature Request: Allow Explicit Bar Height (barHeight or maxBarHeight) for Bar Charts · Issue #2771 · plouc/nivo · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Feature Request: Allow Explicit Bar Height (barHeight or maxBarHeight) for Bar Charts #2771

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

Open
ayyanababu opened this issue May 31, 2025 · 0 comments

Comments

@ayyanababu
Copy link
ayyanababu commented May 31, 2025

Is your feature request related to a problem? Please describe.
Yes, my feature request is related to a problem with controlling bar height for certain layouts.
In use cases where the number of bars is small (e.g., 3–6), I want the bars to always have a fixed, explicit height (e.g., 16px or 32px), regardless of the overall chart height or the parent container’s height. Currently, Nivo's automatically distributes all available vertical space among bars and padding, making it impossible to strictly control individual bar height via a prop or API.

Describe the solution you'd like
I’d like to be able to explicitly set or lock the height of bars (for horizontal bars) or width (for vertical bars) in the Nivo Bar chart—for example, by specifying a barHeight or maxBarHeight prop (in pixels). When this is set, each bar should render at exactly the specified height, regardless of the container’s overall height or the number of bars, as long as all bars fit within the chart area. The chart should automatically adjust its total height to fit the specified bars (with optional padding or margin).

If the number of bars is too high for the available chart height (i.e., bars plus gaps would overflow), then the chart should gracefully fallback to a calculated bar height or a minimum allowed bar height, ensuring all data remains visible. This way, the strict barHeight is enforced only when possible and reasonable.

Describe alternatives you've considered

  1. Manually setting the chart container’s height based on the number of bars and desired bar height, but this approach is fragile, not responsive, and doesn’t scale well with dynamic data.

  2. Adjusting the Nivo padding prop, but this only controls the fraction of space between bars and doesn’t guarantee fixed bar height.

Additional context
This feature is important for dashboard and design system use cases where visual consistency is required—e.g., having 5 bars, each exactly 16px tall, regardless of parent size.
Below is an example mockup and workaround I’ve tried, which requires hard-coding the container’s height and doesn’t respond well to changes:

Adding My Mocks Images as well

Image
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

1 participant
0