In your browser, go to the data source page (goo2.php) and see what shows
up. You should see something that looks like the sampleData.json file on
the example page, except it will be all one long string without the line
breaks.
Your javascript also needs a couple of small fixes:
1) you need to use the DataTable constructor, not the #arrayToDataTable
method, ie:
var data = new google.visualization.DataTable(jsonData);
2) you need to define the "options" variable that you pass to the chart's
#draw method, even if it's just an empty object:
var options = {
// define the options in here
};
On Wednesday, August 29, 2012 6:20:17 PM UTC-4, Diana Flores wrote:
>
> it doesnt show the Columnchart!!!....
>
> this what i have:
>
>
> <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 jsonData = $.ajax({
> url: "goo2.php",
> dataType:"json",
> async: false
> }).responseText;
>
>
> var data = google.visualization.arrayToDataTable(jsonData);
>
>
> 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>
>
>
>
> --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
>
> <?php
>
> $con=mysql_connect("localhost","root","") or die("problemas al conectarse
> al server!!!!");
>
> mysql_select_db("bdregistro", $con);
>
> $sth = mysql_query("SELECT * FROM bd_salidas");
> $rows = array();
> $flag = true;
>
> $table = array();
>
> $table['cols'] = array(
>
> array('label' => 'PLACA', 'type' => 'string'),
> array('label' => 'SEMANA_1', 'type' => 'number'),
> array('label' => 'SEMANA_2', 'type' => 'number'),
> array('label' => 'SEMANA_3', 'type' => 'number'),
> array('label' => 'SEMANA_4', 'type' => 'number'),
> array('label' => 'SEMANA_5', 'type' => 'number')
>
> );
>
> $rows = array();
> while($r = mysql_fetch_assoc($sth)) {
> $temp = array();
>
> $temp[] = array('v' => (string) $r['PLACA']);
> $temp[] = array('v' => (int) $r['S1']);
> $temp[] = array('v' => (int) $r['S2']);
> $temp[] = array('v' => (int) $r['S3']);
> $temp[] = array('v' => (int) $r['S4']);
> $temp[] = array('v' => (int) $r['S5']);
>
>
> $rows[] = array('c' => $temp);
> }
>
> $table['rows'] = $rows;
>
> $jsonTable = json_encode($table);
>
>
> ?>
>
> it doesnt show an error!!!! just blank page!!!
>
>
--
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/-/RxBE3LhejtcJ.
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.