thanks my code:
<?php
// Aceder a base de dados
$host = "...";
$user= "...";
$pass = "....";
$db="....";
$acessoDB = pg_connect("host=$host dbname=$db user=$user password=$pass");
if (!$acessoDB){
die ("Não foi possível aceder à base de dados.");
}
$queryData =pg_query("SELECT start_time, media_cssr_cs_2g_quinzenal
FROM huawei.quinzenal_cssr_cs_2g
ORDER BY start_time");
$queryData1 =pg_query("SELECT start_time, media_cssr_cs_3g_quinzenal
FROM huawei.quinzenal_cssr_cs_3g
ORDER BY start_time");
$queryData2 =pg_query("SELECT start_time, media_cssr_ps_2g_quinzenal
FROM huawei.quinzenal_cssr_ps_2g
ORDER BY start_time");
$queryData3 =pg_query("SELECT start_time, media_cssr_ps_3g_quinzenal
FROM huawei.quinzenal_cssr_ps_3g
ORDER BY start_time");
$table = array();
$table['cols'] = array(
array('label' => 'start_time', 'type' => 'string'),
array('label' => 'CSSR CS 2G', 'type' => 'number'),
array('label' => 'CSSR CS 3G', 'type' => 'number'),
array('label' => 'CSSR PS 2G', 'type' => 'number'),
array('label' => 'CSSR PS 3G', 'type' => 'number')
);
//1 Series
$rows = array();
while($r = pg_fetch_assoc($queryData)) {
$temp = array();
// the following line will used to slice the Pie chart
$temp[] = array('v' => (string) $r['start_time']);
//Values of the each slice
$temp[] = array('v' => (float) $r['media_cssr_cs_2g_quinzenal']);
$rows[] = array('c' => $temp);
}
$table['rows'] = $rows;
$jsonTable = json_encode($table);
//echo $jsonTable;
//2 Series
$rows = array();
while($r = pg_fetch_assoc($queryData1)) {
$temp = array();
// the following line will used to slice the Pie chart
$temp[] = array('v' => (string) $r['start_time']);
//Values of the each slice
$temp[] = array('v' => (float) $r['media_cssr_cs_3g_quinzenal']);
$rows[] = array('c' => $temp);
}
$table['rows'] = $rows;
$jsonTable1 = json_encode($table);
//echo $jsonTable1;
//3 Series
$rows = array();
while($r = pg_fetch_assoc($queryData2)) {
$temp = array();
// the following line will used to slice the Pie chart
$temp[] = array('v' => (string) $r['start_time']);
//Values of the each slice
$temp[] = array('v' => (float) $r['media_cssr_ps_2g_quinzenal']);
$rows[] = array('c' => $temp);
}
$table['rows'] = $rows;
$jsonTable2 = json_encode($table);
//echo $jsonTable2;
//4 Series
$rows = array();
while($r = pg_fetch_assoc($queryData3)) {
$temp = array();
// the following line will used to slice the Pie chart
$temp[] = array('v' => (string) $r['start_time']);
//Values of the each slice
$temp[] = array('v' => (float) $r['media_cssr_ps_3g_quinzenal']);
$rows[] = array('c' => $temp);
}
$table['rows'] = $rows;
$jsonTable3 = json_encode($table);
//echo $jsonTable3;
?>
<html>
<head>
<!--Load the AJAX API-->
<script type="text/javascript"
src="https://www.google.com/jsapi"></script>
<script type="text/javascript"
src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script type="text/javascript">
google.load('visualization', '1', {'packages':['coreChart']});
// Set a callback to run when the Google Visualization API is loaded.
google.setOnLoadCallback(drawChart);
function drawChart() {
// Create our data table out of JSON data loaded from server.
var data = new google.visualization.DataTable();
data.addColumn('string', 'start_time');
data.addColumn('number', 'CSSR CS 2G');
data.addColumn('number', 'CSSR CS 3G');
data.addColumn('number', 'CSSR PS 2G');
data.addColumn('number', 'CSSR PS 3G');
data.addRows([
[(<?=$jsonTable?>),'CSSR CS 2G'],
[(<?=$jsonTable1?>),'CSSR CS 3G'],
[(<?=$jsonTable2?>),'CSSR PS 2G'],
[(<?=$jsonTable3?>),'CSSR PS 3G']
]);
var options = {
title: 'Acessibility',
//chartArea: {width: 0, top: 30, left: 140, width: "50%", height:
"50%"},
//backgroundColor: 'yellow', //cor do fundo do grafico
//axisTitlesPosition: 'out',
//vAxis: {title: "Valor"}, //legenda horizontal
//hAxis: {title: "Data"}, //legenda vertical
//colors: ['#AA00CC'], // cor da linha do gráfico
//is3D: 'True',
width: 1500, //largura
height: 400, //Altura
};
// Instantiate and draw our chart, passing in some options.
var chart = new
google.visualization.LineChart(document.getElementById('graf31'));
chart.draw(data,options);
}
</script>
</head>
<body>
<!--Div that will hold the chart-->
<div id="graf31"></div>
</body>
</html>
Sexta-feira, 26 de Abril de 2013 15:52:07 UTC-1, Alex escreveu:
>
> Hello
> A need a help .
> My Code don't work. I don't now why.
>
> <!--Load the AJAX API-->
> <script type="text/javascript" src="https://www.google.com/jsapi
> "></script>
> <script type="text/javascript" src="
> http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
> <script type="text/javascript">
>
>
> google.load('visualization', '1', {'packages':['coreChart']});
>
> // Set a callback to run when the Google Visualization API is loaded.
> google.setOnLoadCallback(drawChart);
>
> function drawChart() {
>
> // Create our data table out of JSON data loaded from server.
> var data = new google.visualization.DataTable();
> data.addColumn('string', 'start_time');
> data.addColumn('number', 'CSSR CS 2G');
> data.addColumn('number', 'CSSR CS 3G');
> data.addColumn('number', 'CSSR PS 2G');
> data.addColumn('number', 'CSSR PS 3G');
> data.addRows([
> [(<?=$jsonTable?>),'CSSR CS 2G'],
> [(<?=$jsonTable1?>),'CSSR CS 3G'],
> [(<?=$jsonTable2?>),'CSSR PS 2G'],
> [(<?=$jsonTable3?>),'CSSR PS 3G']
> ]);
>
> var options = {
> title: 'Acessibility',
> //chartArea: {width: 0, top: 30, left: 140, width: "50%",
> height: "50%"},
> //backgroundColor: 'yellow', //cor do fundo do grafico
> //axisTitlesPosition: 'out',
> //vAxis: {title: "Valor"}, //legenda horizontal
> //hAxis: {title: "Data"}, //legenda vertical
> //colors: ['#AA00CC'], // cor da linha do gráfico
> //is3D: 'True',
> width: 1500, //largura
> height: 400, //Altura
> };
>
> // Instantiate and draw our chart, passing in some options.
> var chart = new
> google.visualization.LineChart(document.getElementById('graf31'));
>
> chart.draw(data,options);
>
> }
>
>
>
--
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.