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 »

 

SQLite Editor for PHP
The SQLite Editor for PHP software is a tool which will help you and/or your users administer and maintain your SQLite databases. Built as a tool that you can easily provide to your users, there's no danger of them damaging your database.

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.


23rd June, Richard
The SQLite Editor for PHP admin tool is now available for you to download

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

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 »

A black and orange SVG Horizontal Bar chart

A black and orange SVG Horizontal Bar chart that uses two Horizontal Bar objects to provide the gray backgrounds to the bars.

This is a Horizontal Bar chart that's made up of two separate objects. The first is the gray background for the bars that you can see. Then the orange Horizontal Bar chart is overlaid on top. The labels on the right are made up from the labelsAbove option (on the first, background chart). As you can see the chart uses the wave effect (the wave effect is not just a Bar chart effect but also available with the Horizontal Bar chart).

By combining charts like this you can get a multitude of different effects that just wouldn't be feasible with just a single chart. You can examine the source code for both of the Horizontal Bar objects below. The div tag that the svg uses is itself wrapped in another div tag and it's this one that has css applied to it.

This chart doesn't do a lot in terms of responsive features. It reduces in size a little, the text size is reduced and the css float is removed.

This goes in the documents header:
<script src="RGraph.svg.common.core.js"></script>
<script src="RGraph.svg.hbar.js"></script>
Put this where you want the chart to show up:
<div style="float: right">
    <div style="width: 500px; height: 300px; display: inline-block; background-color: black" id="chart-container"></div>
</div>
This is the code that generates the chart - it should be placed AFTER the div tag:
<script>
    // The data for the chart
    data   = [70,80,60,50,40,80];
    
    // The labels for the chart. These labels are positioned on the
    // left-hand-side as normal and the data is also given as the
    // labelsAbove labels.
    labels = ['JavaScript','HTML','CSS','React','Ruby','Python'];

    // Create the HBar chart that becomes the gray backgrounds to
    // the bars. Note that all of the bits of data are set to one.
    // This means that all of the gray bars on the chart will be
    // as far right as it goes.
    bar_bg = new RGraph.SVG.HBar({
        id: 'chart-container',
        data: [1,1,1,1,1,1],
        options: {
            colors: ['gray'],
            xaxisScale: false,
            backgroundGrid: false,
            marginInner: 5,
            
            // If these aren't given then the marginLeftAuto will make
            // the left margin 0 when it actually needs to match the
            // other chart.
            yaxisLabels: labels, 
            
            // Don't want to see any text on the background chart.
            textColor: 'transparent',

            // Add the labels that you can see on the right of the
            // chart.
            labelsAboveColor: 'white',
            labelsAboveSpecific: data,
            responsive: [
                {maxWidth: null, width: 500, height: 300, options: {textSize: 12},parentCss:{'float':'right', textAlign:'none'}},
                {maxWidth: 800, width: 400,  height: 250, options: {textSize: 10},parentCss:{'float':'none', textAlign:'center'}}
            ]
        }
    }).draw();








    // This is the orange HBar chart that you can see and which
    // represents the actual values.
    bar_fg = new RGraph.SVG.HBar({
        id: 'chart-container',
        data: data,
        options: {
            colors: ['orange'],
            textColor: 'white',
            yaxisLabels: labels,
            xaxisScale: false,
            backgroundGrid: false,
            marginInner: 5,
            responsive: [
                {maxWidth: null, width: 500, height: 300, options: {textSize: 12}},
                {maxWidth: 800, width: 400,  height: 250, options: {textSize: 10}}
            ]
        }
    
    // The orange chart uses the wave() effect.
    }).grow({callback: function ()
    {
        bar_bg.set('labelsAbove', true);
        RGraph.SVG.redraw();
    }});
</script>