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

More »

 

Version 7.01 released
Version 7.01 (released in October 2025) is the latest version of RGraph and now includes a new tree structure object. The accompanying Treemenu object can then turn the object into a fully dynamic tree menu. You can read the API documentation for the tree on the main API documentation page and see an example of the Treemenu feature by following this link...

More »

 

New HTML datagrid
In the April 2025 (v6.21) release a new datagrid object was added. This makes it easy to add static or dynamic data tables to your pages. It can be used whether you use the canvas or SVG libraries or entirely standalone.

Read more »

 

Download
Get the latest version of RGraph (version 7.01, 8th October 2025) 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 »

 

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 »

HOWTO: 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: 16,
            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>