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 »

How to get crisp lines on your canvas tag

Introduction

By default HTML5 canvas antialiases (smooths) lines that you draw and this can make them appear to be thicker than they really are. You can avoid this if you prefer and get crisp lines by using the techniques described here. The offsetting method was used by RGraph for many years and just involves a simple translation before you start drawing. The second, more recent method, involves doubling the size of the pixel space and using CSS to size the canvas to the desired dimensions. This produces superb results, but does mean that you will probably have to account for it when if you do any additional drawing after your chart is drawn.

The original style of chart

This chart is drawn without any antialiasing fix and it allows you to see the state of the canvas drawing without any offsetting or scaling in effect.

[No canvas support]

<canvas id="cvs1" width="700" height="300">[No canvas support]</canvas>

<script>
    bar = new RGraph.Bar({
        id: 'cvs1',
        data: [4,8,6,5,5,3,1],
        options: {
            scale: false,
            marginTop: 50,
            textSize: 16,
            titleSize: 20,
            marginInner: 25,
            title: 'A chart with no antialiasing fix',
            xaxisLabels: ['Mon','Tue','Wed','Thu','Fri','Sat','Sun']
        }
    }).draw();
</script>

The old-style antalias fix

And here is the chart after the former antialias fix has been applied. This involved translating the canvas by half a pixel in both the horizontal and vertical directions. As you can see it provides reasonable results, however the text on the chart is still a little thicker and blurrier than it should be.

[No canvas support]

<canvas id="cvs2" width="700" height="300">[No canvas support]</canvas>

<script>
    bar = new RGraph.Bar({
        id: 'cvs2',
        data: [4,8,6,5,5,3,1],
        options: {
            events: {
                beforedraw: function (obj)
                {
                    obj.context.translate(0.5, 0.5);
                }
            },
            scale: false,
            marginTop: 50,
            textSize: 16,
            titleSize: 20,
            marginInner: 25,
            title: 'A chart with the old-style antialiasing fix',
            xaxisLabels: ['Mon','Tue','Wed','Thu','Fri','Sat','Sun']
        }
    }).draw();
</script>

The up-to-date antialias fix

This is a chart that uses the up-to-date method that RGraph uses to get rid of antialiasing. It involves increasing the canvas HTML dimensions and then using the CSS width and height to set the desired dimensions of the chart. The resulting chart looks much better and the lines (and the text) are crisper. Also, with animations they look a little smoother.

[No canvas support]
<canvas id="cvs3" width="700" height="300">[No canvas support]</canvas>

<script>
    bar = new RGraph.Bar({
        id: 'cvs3',
        data: [4,8,6,5,5,3,1],
        options: {
            marginTop: 50,
            textSize:14,
            titleSize: 20,
            marginInner: 25,
            title: 'A chart with the up-to-date antialiasing fix',
            xaxisLabels: ['Mon','Tue','Wed','Thu','Fri','Sat','Sun']
        }
    }).draw();
</script>

As you can see, the canvas tag looks no different - and it isn't! This is because RGraph will apply the scaling fix automatically and you don't have to worry about anything. Here's what the scaled canvas tag really looks like after it's been modified. You can see that the width/height HTML attributes have been doubled and there is now a style attribute which has width/height properties that stipulate the desired dimensions.

<canvas id="cvs" width="1400" height="600" style="width: 700px; height: 300px">[No canvas support]</canvas>