Hey All

Im just trying out charts for the first time, and need to chart from a CSV

Messing around for a while but cant find out what is wrong.

I managed to get as far as an error: Data column(s) for axis #0 cannot be 
of type string

Here is my code:

<html>
        <head>
                <title>Test</title>


                <script type="text/javascript" src=
"https://www.google.com/jsapi";></script>
               
 <script 
src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"; 
type="text/javascript"></script>
                <script src=
"http://jquery-csv.googlecode.com/files/jquery.csv-0.71.js";></script>
                <script type="text/javascript">
                        // load the visualization library from Google and 
set a listener
                        google.load('visualization', '1.0', {packages:[
'corechart']});
                        google.setOnLoadCallback(drawChart);


                        // this has to be a global function
                        function drawChart() {
                           // grab the CSV
                           $.get("example.csv", function(csvString) {
                              // transform the CSV string into a 
2-dimensional array
                              var arrayData = $.csv.toArrays(csvString, {
onParseValue: $.csv.hooks.castToScalar});

                              // this new DataTable object holds all the 
data
                              var data = new google.visualization.
arrayToDataTable(arrayData);


                              // this view can select a subset of the data 
at a time
                              var view = new google.visualization.DataView(
data);
                              view.setColumns([0,1]);

                             // set chart options
                             var options = {
                                title: "A Chart from a CSV!",
                               
 hAxis: {title: data.getColumnLabel(0), minValue: 
data.getColumnRange(0).min, maxValue: data.getColumnRange(0).max},
                               
 vAxis: {title: data.getColumnLabel(1), minValue: 
data.getColumnRange(1).min, maxValue: data.getColumnRange(1).max},
                                legend: 'none'
                             };

                             // create the chart object and draw it
                             var chart = new google.visualization.LineChart(
document.getElementById('chart'));
                             chart.draw(view, options);
                        });
                        }
                </script>

        </head>
<body>

<div id="chart" style="width: 900px; height: 500px;" ></div>

</body>
</html>




ANd here is the contents of the CSV im testing on:
"Date","Time","T_1-04","%H_1-04","T_2-13","%H_2-13","T_3-04","%H_3-04",
"T_4-13","%H_4-13","T_5-04","%H_5-04","T_6-19","%H_6-19"
"31.10.2014","14:50:07",34,26,32,30,33,30,36,24,23,55,33,30
"31.10.2014","14:49:07",34,26,32,30,33,30,36,24,23,55,33,30
"31.10.2014","14:48:07",34,26,32,30,33,30,36,24,23,55,33,30
"31.10.2014","14:47:07",34,26,32,30,33,30,36,24,23,55,33,30



Thanks for your help

Ray



-- 
You received this message because you are subscribed to the Google Groups 
"Google Chart API" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-chart-api.
For more options, visit https://groups.google.com/d/optout.

Reply via email to