Hello, I have a little problem.

Hmm...maybe I will start with show you my code:

<?php
require_once('config.php');
include_once('dateform.lib.php');

if(isset($_POST['button'])){
    $year = $_POST['year'];
    $month = $_POST['month'];
}

for( $i=0; $i < count($brName); $i++ )
{
  $data[] = $brName[$i]['il_brn'];
  $labels[] = $brName[$i]['browser_name'];
  $colors[] = generateRandomColor();
}

$resultTable = array();
$resultTable[] = Array("Name", "Value");
for($j = 0; $j < count($brName); $j++){
    $resultTable[] = array($brName[$j]['browser_name'], 
(int)$brName[$j]['il_brn']);
}

$colors = generateRandomColorInArray($colors);
$js = json_encode($resultTable);
?>
<head>
<script type="text/javascript" src="https://www.google.com/jsapi";></script>
<script type="text/javascript" src="js/jquery-1.8.0.min.js"></script>
<script type="text/javascript">
google.load('visualization', '1.0', {'packages':['corechart']});
google.setOnLoadCallback(drawChart);
function drawChart() {
    var jsonData = <?php echo $js; ?>;
        
    var obj = jQuery.parseJSON(jsonData);
    var data = google.visualization.arrayToDataTable(obj);
          
    var options = {'title':'Browsers',
                    'width':500,
                    'is3D':true,
                    'height':300};
    var chart = new 
google.visualization.PieChart(document.getElementById('chart_div'));
        chart.draw(data, options);
}
</script>
</head>
<div id="chart_div"></div>

OK, so...I have script for example browser.php which looks like as I shown. 
In the php case I am getting data from database and parse to the json 
format. In the <head> case I would like to show pie chart with data from 
php case in the same script. Is it possible?

-- 
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/-/laygVwx_gewJ.
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