Chart.js icon indicating copy to clipboard operation
Chart.js copied to clipboard

Increasing space between groups of bars [Category:Support]

Open willmichael opened this issue 10 years ago • 11 comments

Hey I'm wondering if there's a workaround to add space between bars. I wanted values to be displayed at all times above the bars, but it results in them being fairly squashed together:

image

I need a way to add a little spacing between bars so that the graph is more readable

willmichael avatar Jun 29 '16 21:06 willmichael

@willmichael v2 does have an option that might help barPercentage. Docs

Reducing the value of the barPercentage will make the bars smaller which could help. I don't know if this is sufficient for your needs.

etimberg avatar Jun 29 '16 22:06 etimberg

Yeah I've seen that option; it does help, but it makes spacing between groups a little more ambiguous

image

willmichael avatar Jun 29 '16 22:06 willmichael

Yeah. Reducing the categoryPercentage could help, but it again will make things smaller.

Another option would be to rotate your label text, change the font color and draw it in the bar.

etimberg avatar Jun 29 '16 22:06 etimberg

Closing since this has an adequate answer

etimberg avatar Aug 07 '16 18:08 etimberg

How can this be done with ChartJS V.3.2.1 ? How do I add space around groups of bars?

MHCreations avatar Jun 22 '21 10:06 MHCreations

@willmichael How do I increase space between the bars? Though I have a group of 3 bars and I want to increase the gap between each bar not on the group of bars

Sasi-007 avatar Aug 09 '21 13:08 Sasi-007

A nasty hack is to add a transparent border, you'll need to increase the bar thickness too. This is nasty because the end of the bar is trimmed as the border is inset so the chart is inaccurate but in my case it didn't matter.

borderColor: "rgba(0,0,0,0)",
borderWidth: 10,
barThickness: 20,
maxBarThickness: 20,

tristanisginger avatar Jan 12 '22 11:01 tristanisginger

The spacing between group of bars and bars are determined by categoryPercentage, barPercentage and the chart width. No need to use any hacks.

kurkle avatar Jan 12 '22 11:01 kurkle

A nasty hack is to add a transparent border, you'll need to increase the bar thickness too. This is nasty because the end of the bar is trimmed as the border is inset so the chart is inaccurate but in my case it didn't matter.

borderColor: "rgba(0,0,0,0)",
borderWidth: 10,
barThickness: 20,
maxBarThickness: 20,

Thank you! It's really worked!

tyumen-777 avatar May 27 '22 07:05 tyumen-777

The spacing between group of bars and bars are determined by categoryPercentage, barPercentage and the chart width. No need to use any hacks.

This works for my use case. It allows the bars(in a group) to have the borders touching to each other. I only used 'barPercentage = 1' for each dataset.

Before image

After 'barPercentage' image

codelikesuraj avatar Oct 05 '22 17:10 codelikesuraj

A nasty hack is to add a transparent border, you'll need to increase the bar thickness too. This is nasty because the end of the bar is trimmed as the border is inset so the chart is inaccurate but in my case it didn't matter.

borderColor: "rgba(0,0,0,0)",
borderWidth: 10,
barThickness: 20,
maxBarThickness: 20,

Thank you! It's really worked!

CrismariMain avatar Feb 21 '23 18:02 CrismariMain