MENU
.net Powerful JavaScript charts
About
RGraph is a JavaScript charts library based on HTML5 SVG and canvas. RGraph is mature (over 15 years old) and has a wealth of features making it an ideal choice to use for showing charts on your website.

More »

 

Download
Get the latest version of RGraph (version 6.18, 1st June 2024) from the download page. You can read the changelog here. There's also older versions available, minified files and links to cdnjs.com hosted libraries.

More »

 

License
RGraph can be used for free under the GPL or if that doesn't suit your situation there's an inexpensive (£129) commercial license available.

More »

Is there a maximum width setting for the Bar chart?


Posted by Roberto at 14:33 on Thursday 22nd April 2021 [link]
Hello,
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.
Thanks

Posted by Richard at 16:35 on Thursday 22nd April 2021 [link]
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,
...

Richard

[Replies are closed]