[RGRAPH SUPPORT] Is there a "maximum width" setting for the Bar chart?

Is there a "maximum width" setting for the Bar chart?

Post a reply
Posted by Roberto at 14:33 on 22nd April 2021
I would like to ask you something else, when drawing the graphs the bars adapt to the size of the x-axis of the graph. So if for example I have 5 data the bars are very large, if I have 20 data the bars are very fine. How can I give a maximum size to the bar so that even if I have little data it does not become too big? A fixed size would also work if possible.

Posted by Richard at 16:35 on 22nd April 2021
There's no "maximum width" setting for the bars but there is a marginInner setting which indirectly does what you want - if you give a larger marginInner setting the bars on the Bar chart will be thinner.

So you could do this:

data = [4,8,6,5,3,5,8];
numbars = data.length;

if (numbars > 20) {
    myMargin = 5;
} else if (numbars > 15) {
    myMargin = 10;
} else if (numbars > 10) {
    myMargin = 20;
} else {
    myMargin = 25;

And then in your chart configuration:

marginInner: myMargin,


Post a reply

What's your name?
What do you want to say?