The problem here is that the {v: value, f: 'formatted value'} syntax is not 
valid for use with the arrayToDataTable method (as documented 
here<https://developers.google.com/chart/interactive/docs/reference#google.visualization.arraytodatatable>).
 
 If you want to use that syntax, you will have to define your DataTable 
manually, and then use the #addRows method, like this:

var data = new google.visualization.DataTable();
data.addColumn('number', 'Camera');
data.addColumn('number', 'Avg Rating');
data.addRows([
    [{v:6000, f: 'Canon EOS-1Ds Mark III'}, 60],
    [{v:5000, f: 'Canon EOS-1Ds Mark II'}, 50],
    [{v:4000, f: 'Canon EOS-1D Mark IV'}, 40]
]);

On Tuesday, December 25, 2012 11:33:41 PM UTC-5, Reza Mirza wrote:
>
> I'm having a really weird issue while trying to visualize this scatter 
> plot using the google visualization API.
>
> Basically, if I put the first data point as [0,0] everything will be fine, 
> but if remove [0,0] as the first point, the chart won't produce. I checked 
> the console and this is what I said:
>
> "Uncaught SyntaxError: Unexpected token <
> Uncaught Error: Invalid value in 0,0"
>
> Why exactly does the first point need to be [0,0]?
>
> <html>
>   <head>
>     <script type="text/javascript" 
> src="https://www.google.com/jsapi";></script>
>     <script type="text/javascript">
>       google.load("visualization", "1", {packages:["corechart"]});
>       google.setOnLoadCallback(drawChart);
>       function drawChart() {
>         var data = google.visualization.arrayToDataTable([
>           ['Camera','Avg Rating'],
>           [ {v:6000, f: 'Canon EOS-1Ds Mark III'}, 60],
>           [ {v:5000, f: 'Canon EOS-1Ds Mark II'}, 50],
>           [ {v:4000, f: 'Canon EOS-1D Mark IV'}, 40]
>         ]);
>
>         var options = {
>           title: 'Breakdown of Camera Models by Price, Photo Rating and 
> Brand',
>           hAxis: {title: 'Price (USD)', minValue: 0, maxValue: 7500},
>           vAxis: {title: 'Avg Rating (at peak)', minValue: 0, maxValue: 55},
>           legend: 'none'          
>         };
>         var chart = new 
> google.visualization.ScatterChart(document.getElementById('chart_div'));
>         chart.draw(data, options);
>       }
>     </script>
>   </head>
>   <body>
>     <div id="chart_div" style="width: 1000px; height: 1000px;"></div>
>   </body></html>
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Visualization API" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/google-visualization-api/-/jhgdvU_HnOgJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-visualization-api?hl=en.

Reply via email to