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 »

 

SQLiteEditor 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.


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 »

A canvas-based black Line chart

[No canvas support]

This is quite an old demo of a Line chart but it has stood up through the years very well and still looks very presentable.

It's a black Line chart with two datasets that both use custom tickmarks. These custom tickmarks are drawn by utilising the RGraph.path api function. This is a function that makes drawing with the canvas api far less verbose than it usually is.

Before drawing commences, using the beforedraw event, the canvas is cleared to a plain black color. You might find this as a performance-enhancing tip on various canvas performance articles though by the second frame you'll not be drawing on a transparent canvas - so it might be a redundant action.

The trace Line chart effect is used here - but an options object is passed to the effects function call. This is just a regular javascript object which contains a single property: frames As the name suggests this stipulates the number of frames in the animation. Lower numbers make for quicker animations that finish sooner.

The responsive function changes the size of the text and the margins, changes the css float to none and a callback function updates a global variable that controls the size of the custom tickmarks. The callback function runs after the chart has been redrawn so if you change anything here (as we're doing) then you need to redraw the chart. That can be done by calling the RGraph.redraw function.

This goes in the documents header:
<script src="RGraph.common.core.js"></script>
<script src="RGraph.line.js"></script>
Put this where you want the chart to show up:
<div style="float: right">
    <canvas id="cvs" width="600" height="250" style="border-radius: 5px">[No canvas support]</canvas>
</div>
This is the code that generates the chart - it should be placed AFTER the canvas tag(s):
<script>
    tickmarkRadius = 6;

    line = new RGraph.Line({
        id: 'cvs',
        data: [
            [7.0,6.9,9.5,14.5,18.2,21.5,25.2,26.5,23.3,18.3,13.9,9.6],
            [0.2,0.8,5.7,11.3,17.0,22.0,24.8,24.1,20.1,14.1,8.6, 2.5]
        ],
        options: {
            xaxisLabels: ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],
            colors: ['#0f0','#76D0FF'],
            tickmarksStyle: function (obj, data, value, index, x, y, color, prevX, prevY)
            {
                obj.path(
                    'b lw 2 a % % % 0 % false f null s black',
                    x, y, tickmarkRadius, RGraph.TWOPI
                );
            },
            linewidth: 3,
            textColor: '#eee',
            responsive: [
                {maxWidth: null, width:600,height:250,options:{textSize: 12,marginLeft: 40,marginBottom: 40,marginTop: 40,marginRight: 40},parentCss:{'float':'right',textAlign:'none'},callback:function (){tickmarkRadius = 6; RGraph.redraw();}},
                {maxWidth: 900, width:400,height:150,options:{textSize: 10,marginTop:15,marginRight:15,marginBottom:25,marginLeft:30},parentCss:{'float':'none',textAlign:'center'},callback:function (){tickmarkRadius = 5; RGraph.redraw();}}
            ],
            events: {
                beforedraw: function (obj)
                {
                    RGraph.clear(obj.canvas, 'black');
                }
            }
        }
    }).trace({frames: 15});
</script>