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.11
Version 7.11 (released in March 2026) is the latest version of RGraph and contains just a few updates to the code which you can see on the changelog page. There's a new dumbbell variation for the Bar and Horizontal bar charts (both SVG and canvas) and the front page layout of the website has been tweaked.

Download »

 

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.11, 21st March 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 »

 

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,
                backgroundGridVlines: false,
                backgroundGridBorder: false,
                yaxis: false,
                yaxisScaleMax: 100,
                marginLeft: 50,
                shadow: true,
                shadowOpacity: 0.1,
                colors: ['Gradient(orange:orange:white)']
            }
        }).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).