This chart demonstrates using the CSV reader to read the sample.csv file.
<script src="RGraph.common.core.js"></script> <script src="RGraph.common.csv.js"></script> <script src="RGraph.rose.js"></script>Put this where you want the chart to show up:
<canvas id="cvs" width="400" height="400">
[No canvas support]
</canvas>
This is the code that generates the chart:
<script>
window.onload = function ()
{
RGraph.CSV('/sample.csv', function (csv)
{
var data = [];
/**
* First column is the labels
*/
var labels = csv.getCol(0);
/**
* Number of rows in the CSV file
*/
var numrows = csv.numrows;
for (var i=0; i<numrows; i+=1) {
data.push(csv.getRow(i, 1));
}
var bar = new RGraph.Rose({
id: 'cvs',
data: data,
options: {
labelsAxes: 'n',
margin: 15,
colors: ['red', 'green', '#aaf', 'mauve', 'cyan','#fca', 'pink'],
colorsAlpha: 0.5,
textAccessible: true
}
}).draw();
});
};
</script>