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 »

AJAX functions

The RGraph SVG libraries incorporate ajax functions that make it easy for you to fetch data from your server and then use it to create your charts. You can use them by simply including the file RGraph.svg.common.ajax.js in your page and then use the functions like the following example code shows.

See also:
There's also a dedicated CSV reader that fetches data via ajax. The CSV reader is documented here.


<script>
    RGraph.SVG.AJAX.getJSON('/getdata.html?json', function (json)
    {
        var bar = new RGraph.SVG.Bar({
            id: 'chart-container',
            data: json.data,
            options: {
                xaxisLabels: json.labels,
                marginInner: 5,
                yaxisScaleMax: 100,
                marginLeft: 50
            }
        }).draw();
    });
</script>

The available functions can just fetch the desired resource or they can go further, such as the getJSON function which doesn't return the string that the server provides; it returns a usable javascript object for you. Here are the functions:

Name: string RGraph.SVG.AJAX(string url, function callback)
Description: 
This is the function that underpins the other AJAX functions (except the RGraph.SVG.AJAX.post function). It fetches the specified URL and returns the response (as a string). It doesn't parse it or do anything with it - it just gives it to you as-is. This function might look something like this:
RGraph.SVG.AJAX('/get.html', function (text)
{
    // Your code goes here
});
Name: string RGraph.SVG.AJAX.post(string url, object data, function callback)
Description: 
Instead of a GET request (which is what happens normally when you request a page), you can make a POST request instead (which typically happens when you submit a form). In this case, you supply the URL, the data to submit with the request (as an object of key/value pairs) and a callback function. This function might look something like this:
RGraph.SVG.AJAX.post('/post.html', {forename: 'Jane', surname: 'Hayford'}, function (text)
{
    // Your code goes here
});
Name: number RGraph.SVG.AJAX.getNumber(string url, function callback)
Description: 
This function fetches a page and parses the response, turning it into a number before passing it to the callback function. The callback function might look something like this:
RGraph.SVG.AJAX.getNumber('/number.html', function (num)
{
    // Your code goes here
});
Name: string RGraph.SVG.AJAX.getString(string url, function callback)
Description: 
This function fetches a page and explicitly converts the response into a string. The response starts off as a string anyway, so this function simply reinforces it by giving the response to the String function. The callback function might look something like this:
RGraph.SVG.AJAX.getString('/string.html', function (str)
{
    // Your code goes here
});
Name: object RGraph.SVG.AJAX.getJSON(string url, function callback)
Description: 
This function fetches a page and converts the result into a JSON object (by giving it to the eval function). It then returns the resulting object, (you might not get anything returned if the JSON is not valid). The callback function might look something like this:
RGraph.SVG.AJAX.getJSON('/json.html', function (json)
{
    // Your code goes here
});
Name: string RGraph.SVG.AJAX.getCSV(string url, function callback[, string field separator = ','[, string line separator = '\r?\n']])
Description: 
This function fetches a page and parses the result as CSV data. Like the above getJSON function the getCSV function can be used to help you fetch data from your server. The callback function might look something like this:
RGraph.SVG.AJAX.getCSV('/csv.html', function (csv)
{
    // Your code goes here
});
Unless specified otherwise, the field separator is a comma and the line separator is a newline (\n) which is optionally preceded by a carriage return (\ r).