Please help me fix this code to show a local CSV file. I'm starting from this simple example:
<html> <head> <script src="https://www.google.com/jsapi"></script> <script src="http://code.jquery.com/jquery-1.10.1.min.js"></script> <script src="https://jquery-csv.googlecode.com/files/jquery.csv-0.71.js"></script> <script> google.load("visualization", "1", {packages:["corechart"]}); google.setOnLoadCallback(drawChart); function drawChart() { $.get("https://docs.google.com/spreadsheet/pub?key=0Ao6fMN9Cw0GPdFVtZ29iYmd1cmRORU0yemYxUjE3OVE&single=true&gid=0&output=csv", function(csvString) { var arrayData = $.csv.toArrays(csvString, {onParseValue: $.csv.hooks.castToScalar}); var data = new google.visualization.arrayToDataTable(arrayData); var view = new google.visualization.DataView(data); view.setColumns([0,1]); var options = { 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' } var chart = new google.visualization.PieChart(document.getElementById('chart_div')); chart.draw(view, options); }); } </script> </head> <body> <div id="chart_div"></div> </body> </html> It makes this: <https://lh3.googleusercontent.com/--Y-s40cDFkU/VZwrWynWzXI/AAAAAAAAtW8/cLe5KCGxGLg/s1600/Screen%2BShot%2B2015-07-07%2Bat%2B12.40.18%2BPM.png> But when I insert my own local file in the same folder into the $.get function: $.get("data.csv", function(csvString) { I get the following error: Uncaught SyntaxError: missing ) after argument list I have read some of the posts here that describe using the following code: var queryOptions = { csvColumns: ['High','Low'], csvHasHeader: false } csvUrl= 'http://localhost/temperatures.csv'; var query = new google.visualization.Query(csvUrl,queryOptions); query.setQuery('select A,B'); But I'm not sure how to correctly include this in the above code to make anything that works. I was getting more exotic errors having to do with file security earlier today but lost that exact code along the way. I would just love for someone show me an example of some complete code that displays a chart from a local .csv file so I can see a working example to start from. -- 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 [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/google-visualization-api. For more options, visit https://groups.google.com/d/optout.
