# A Rose chart using the CSV reader

This chart demonstrates using the CSV reader to read the sample.csv file.

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

This goes in the documents header:

    <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,
                        backgroundAxes: false,
                        backgroundGridRadials: 0
                    }
                }).draw();
            });
        };
    </script>