Using query string data

Introduction

If you're passing data around via the query string that's going to be displayed on your charts then RGraph has a set of functions that will make this much easier for you.

These functions take the name of the query string parameter that you want and return the value to you in the desired format which can be a number, a string, a JSON object or a JavaScript array depending on your data and which function you use.

The available functions

The available functions are:

An example

This is an example of using the RGraph.GET.json() function (because it's the most versatile). Click the link below to add some JSON to the URL and the chart that it produces will appear:

querystring.html?json={"data":[4,8,6,6,3,5,9],"labels":["Mark","Craig","Rich","Pete","Luis","Bob","John"]}#an-example

<script>
    json = RGraph.GET.json('json');


    if(json) {
        new RGraph.Bar({
            id: 'cvs',
            data: json.data,
            options: {
                xaxisLabels: json.labels,
                xaxis: false,
                yaxis: false,
                backgroundGridVlines: false,
                backgroundGridBorder: false
            }
        }).wave().responsive([
            {maxWidth: null, width: 700, height: 300, options:{textSize: 16, marginInner: 20}},
            {maxWidth: 750, width: 400, height: 200, options:{textSize: 11, marginInner: 5}}
        ]);
    }
</script>