Nivo: max width for a column (Bar chart)

Created on 17 Oct 2018  路  3Comments  路  Source: plouc/nivo

hey, first of all, thanks for a great library :)

I create a chart bar dynamically and I don't know how many exactly there will be columns inside. This rage can be from 1 till 20. When there are 20 columns - it looks good but when there are only 1 or 2 - it doesn't look good. is it possible to have a maxWidth for columns? in docs I only found width for the whole chart which doesn't suit for my case.
Thanks)

Most helpful comment

@plouc I'm adding my plus one to adding bar width to the API. It would be really great to see this feature so we wouldn't have to create an entire custom bar component. In my case, adjusting the padding is not a good solution because I want more space in between the bars without making them thinner.

All 3 comments

One thing that might help is the padding option, which can be a value between 0 and 1. Try padding={0.7}!

Sorry but I won't add this option to the API, someone also opened an issue asking for minWidth :), but IMO padding is sufficient and you can adjust its value depending on number of bars, another (radical) option is to use a custom component for bars.

@plouc I'm adding my plus one to adding bar width to the API. It would be really great to see this feature so we wouldn't have to create an entire custom bar component. In my case, adjusting the padding is not a good solution because I want more space in between the bars without making them thinner.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

PattieC4ke picture PattieC4ke  路  3Comments

barnapisti1994 picture barnapisti1994  路  3Comments

tj picture tj  路  4Comments

stahlmanDesign picture stahlmanDesign  路  3Comments

pratikguru picture pratikguru  路  3Comments