An SVG Bar chart using the AJAX functions

This is a demonstration of the RGraph.SVG.AJAX.getJSON() function that can be used to fetch data from your server dynamically.


Note: For browser security reasons the AJAX demos don't work offline. You can view the demos on the RGraph website here: https://www.rgraph.net/demos/index.html#svg

This goes in the documents header:
<script src="RGraph.svg.common.core.js"></script>
<script src="RGraph.svg.common.ajax.js"></script>
<script src="RGraph.svg.bar.js"></script>
Put this where you want the chart to show up:
<div style="width: 750px; height: 300px" id="chart-container"></div>
    [No canvas support]
</div>
This is the code that generates the chart:
<script>
    RGraph.SVG.AJAX.getJSON('/getdata.html?json', function (json)
    {
        new RGraph.SVG.Bar({
            id: 'chart-container',
            data: json.data,
            options: {
                xaxisLabels: json.labels,
                marginLeft: 50,
                yaxisScaleMax: 100,
                yaxis: false
            }                    
        }).grow();
    });
</script>