Your ow structure is wrong, each row should be an object with a "c"
property which is an array of cells. Your cells are almost correct (the
numbers should not be quoted), but you need to put them in the cell arrays
correctly. Instead of this:
{"c":[{"v": "Google"},]},{"c":[{"v": "1"},]} // highlighted the stuff to
remove in red
you should have this:
{"c":[{"v": "Google"},{"v": 1}]}
On Tuesday, April 15, 2014 6:45:39 AM UTC-4, Vincent_IRE wrote:
>
> Hi asgallant, I've been trying to get this chart working for a couple of
> days.
>
> This is the result of my getdata2.php
>
> { "cols": [{"label": "name","type": "string"},{"label": "up","type":
> "number"}],"rows" : [{"c":[{"v": "Google"},]},{"c":[{"v":
> "1"},]},{"c":[{"v": "mercury"},]},{"c":[{"v": "2"},]}]}
>
> When I run chart.html on goolge code playground, the output says "table
> has no colums". See chart.html below. Any help would be greatly
> appreciated.
>
> <html>
> <head>
> <!--Load the AJAX API-->
> <script type="text/javascript" src="https://www.google.com/jsapi"></
> script>
> <script type="text/javascript" src="//
> ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
> <script type="text/javascript">
>
> // Load the Visualization API and the piechart package.
> google.load('visualization', '1', {'packages':['corechart']});
>
> // Set a callback to run when the Google Visualization API is loaded.
> google.setOnLoadCallback(drawChart);
>
> function drawChart() {
> var jsonData = $.ajax({
> url: "localhost/servermonitor/getdata2.php",
> dataType:"json",
> async: false
> }).responseText;
>
> // Create our data table out of JSON data loaded from server.
> var data = new google.visualization.DataTable(jsonData);
>
>
> // Instantiate and draw our chart, passing in some options.
> var chart = new google.visualization.PieChart(document.
> getElementById('chart_div'));
> chart.draw(data, {width: 400, height: 240});
> }
>
> </script>
> </head>
>
> <body>
> <!--Div that will hold the pie chart-->
> <div id="chart_div"></div>
> </body>
> </html>
>
>
>
>
>
> On Tuesday, 26 July 2011 21:07:35 UTC+1, asgallant wrote:
>>
>> There's a simple example here:
>> http://code.google.com/apis/chart/interactive/docs/php_example.html and
>> the documentation for creating a data source is here:
>> http://code.google.com/apis/chart/interactive/docs/dev/implementing_data_source.html
>>
>> I tend to use a middle road, where I pull my data from mySQL and/or
>> Oracle and encode it in JSON. I use jQuery's AJAX to make requests to my
>> source and pass the data to the chart drawing functions.
>>
>
--
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.