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

More »

 

Version 7.20
Version 7.20 (released in June 2026) is the latest version of RGraph and the major change in this version is an update to the default values of properties making for better looking charts without having to set any properties. Read more about this and other changes in the changelog.

Download »

 

Download
Get the latest version of RGraph (version 7.20, 9th June 2026) 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.

Download »

 

Latest forum posts
These are the latest support forum posts that have been posted or updated.


16th June, Rachel
I have a question about the 3D Bar chart
12th June, Marco
Should I use SVG or canvas for the charts on my website?
9th June, Richard
New version of RGraph: version 7.20
3rd June, Patrick
Question about installing RGraph
1st June, Ouja
How do I add a click event to a bar in my Bar chart?


Support forum »

 

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]