A basic demonstration of the .getCSV() function that's a part of RGraph. Here a new Bar chart is created every second by fetching the data from the /getdata.html URL. The whole thing is on a timer so it repeats itself every second. The CSV connector can also get data from within the page - there's an example of the data for that in the source code snippet.
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.common.csv.js"></script> <script src="RGraph.svg.bar.js"></script>Put this where you want the chart to show up:
<div id="klkl" style="display: none">
Richard,8,4,7,6,5,3,4
Dave,7,4,6,9,5,8,7
Luis,4,3,5,2,6,5,4
Kevin,4,2,8,9,6,7,3
Joel,4,5,1,3,5,8,6
Pete,4,5,6,3,5,8,6
</div>
<div style="width: 750px; height: 300px" id="chart-container"></div>
This is the code that generates the chart:
<script>
// This is the function that runs every second to fetch new data
function update ()
{
RGraph.SVG.AJAX.getCSV('/getdata.html', function (csv)
{
if (window.bar) {
RGraph.SVG.clear(bar.svg);
}
window.bar = new RGraph.SVG.Bar({
id: 'chart-container',
data: csv,
options: {
}
}).draw();
});
setTimeout(function ()
{
update();
}, 1000);
}
// Initiate the first AJAX request
update();
</script>