About
RGraph is a JavaScript charts library based on HTML5 SVG and canvas. RGraph is mature (over 15 years old) and has a wealth of features making it an ideal choice to show charts on your website.

More »

 

License
RGraph can be used for free under the GPL or if that doesn't suit your situation there's an inexpensive (£99) commercial license available.

More »

 

Download
Get the latest version of RGraph (version 6.17) from the download page. There's also older versions available, minified files and links to cdnjs.com hosted libraries.

More »

AJAX functions

RGraph has some simplified ajax helper functions that make it much easier to initiate ajax calls without having to be concerned about what the format that the response is in (string, number, object etc).

Previously, because the response to an ajax request is a string, you had to convert it into a usable form (such as a number or an array).

With these functions though they automatically do the data format conversion for you. The ajax functions that are available to you now consist of:

The first three functions are pretty clear. The getCSV function gets a comma-separated set of numbers and converts it to an array for you so that you can use it as an RGraph dataset.

It doesn't support multi-line files - it only gets a single line of csv data. If you want multi-line support you'll need to use the CSV reader.

The getJSON function fetches the URL that you give it and treats the response as json (ie it runs the eval function on the response).

Using json means that you can get multiple datasets and/or labels or other information in your response.

The post function allows you to make post requests - sending data back to the server. The data argument should be a javascript object of key/value pairs that should be sent to the server as post data. The data is encoded for you.

There are straight-forward examples of the ajax functions in the basic examples in the download archive

<script>
    RGraph.AJAX.getJSON('/getdata.html?json', function (json)
    {
        new RGraph.Bar({
            id: 'cvs',
            data: json.data,
            options: {
                marginLeft:     50,
                marginInner:    10,
                tickmarksStyle: 'endcircle',
                linewidth:      2,
                xaxisLabels:    json.labels
            }
        }).draw();
    });
</script>

* As of October 2013 there's now a dedicated CSV reader (that also fetches the csv file via ajax) that's a part of RGraph.