I have the following html which works fine in producing a stacked column 
chart with Google Charts. I want to replace the static data in the html 
with an external csv file and am unable to get it to work.

Static Example (This works fine)

<html>
  <head>
    <script type="text/javascript" 
src="https://www.gstatic.com/charts/loader.js";></script>
    <script type="text/javascript">
      google.charts.load('current', {'packages':['corechart']});
      google.charts.setOnLoadCallback(drawChart);

      function drawChart() {
        var data = google.visualization.arrayToDataTable([
          ['Day', 'Status A', 'Status B', 'Status C'],
          ['Monday', 10, 5, 3],
          ['Tuesday', 8, 2, 6],
          ['Wednesday', 6, 4, 10],
          ['Thursday', 12, 8, 4],
          ['Friday', 4, 12, 2],
          ['Saturday', 6, 4, 8],
          ['Sunday', 10, 6, 4]
        ]);

        var options = {
          title: 'Status Values by Day',
          isStacked: true
        };

        var chart = new 
google.visualization.ColumnChart(document.getElementById('chart_div'));
        chart.draw(data, options);
      }
    </script>
  </head>
  <body>
    <div id="chart_div" style="width: 900px; height: 500px;"></div>
  </body>
</html>

I have replaced the var data block with the following block of code to 
reference a 'data.csv' file.

var data = new google.visualization.DataTable();
data.addColumn('string', 'Day');
data.addColumn('number', 'Status A');
data.addColumn('number', 'Status B');
data.addColumn('number', 'Status C');
data.load('data.csv', {'header': true, 'delimiter': ','});

The 'data.csv' file is formed as follows and I have it in the same folder 
as the html file.

Day,Status A,Status B,Status C
Monday,10,5,3
Tuesday,8,2,6
Wednesday,6,4,10
Thursday,12,8,4
Friday,4,12,2
Saturday,6,4,8
Sunday,10,6,4

When I now open the html file it is blank, I'd like to know where I have 
gone wrong. Thank you in advance for any help or pointers you can give me.

-- 
You received this message because you are subscribed to the Google Groups 
"Google Visualization API" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-visualization-api+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-visualization-api/13c9a850-4b63-4b85-b74a-e546b247b37cn%40googlegroups.com.

Reply via email to