Php 精确值未显示在谷歌图表中
我使用这段代码从mysql调用数据,并将其显示为饼图。但是图表没有显示列中的确切值,而显示为百分比 我想显示准确的值 这是我的密码Php 精确值未显示在谷歌图表中,php,mysql,Php,Mysql,我使用这段代码从mysql调用数据,并将其显示为饼图。但是图表没有显示列中的确切值,而显示为百分比 我想显示准确的值 这是我的密码 <?php $con=mysql_connect("localhost","pramir_feedback","feedback") or die("Failed to connect with database!!!!"); mysql_select_db("pramir_feedback", $con); $sth = mysql_query("SELE
<?php
$con=mysql_connect("localhost","pramir_feedback","feedback") or die("Failed to connect with database!!!!");
mysql_select_db("pramir_feedback", $con);
$sth = mysql_query("SELECT * FROM average");
$rows = array();
$flag = true;
$table = array();
$table['cols'] = array(
array('label' => 'data', 'type' => 'string'),
array('label' => 'average', 'type' => 'number')
);
$rows = array();
while($r = mysql_fetch_assoc($sth)) {
$temp = array();
$temp[] = array('v' => (string) $r['data']);
$temp[] = array('v' => (int) $r['average']);
$rows[] = array('c' => $temp);
}
$table['rows'] = $rows;
$jsonTable = json_encode($table);
?>
<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">
// 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() {
// Create our data table out of JSON data loaded from server.
var data = new google.visualization.DataTable(<?=$jsonTable?>);
var options = {
title: 'Average Data',
is3D: 'true',
width: 800,
height: 600
};
// Instantiate and draw our chart, passing in some options.
// Do not forget to check your div ID
var chart = new google.visualization.PieChart(document.getElementById('chart_div'));
chart.draw(data, options);
}
</script>
</head>
<body>
<!--this is the div that will hold the pie chart-->
<div id="chart_div">fgfgfgfhiefkefejkfwefhfwjkefewfwf</div>
</body>
</html>
//加载可视化API和piechart包。
load('visualization','1',{'packages':['corechart']});
//将回调设置为在加载Google Visualization API时运行。
setOnLoadCallback(drawChart);
函数绘图图(){
//使用从服务器加载的JSON数据创建我们的数据表。
var data=new google.visualization.DataTable();
变量选项={
标题:“平均数据”,
is3D:'正确',
宽度:800,
身高:600
};
//实例化并绘制图表,传入一些选项。
//别忘了检查你的部门ID
var chart=new google.visualization.PieChart(document.getElementById('chart_div');
图表绘制(数据、选项);
}
FGFGFGFHIEFKEJKFWEFFWJKEFWF
在这里你可以看到图表
谢谢。您需要添加PieSiceText参数,该参数采用以下值“百分比”、“值”、“标签”和“无”
var options = {
title: 'Average Data',
is3D: 'true',
width: 800,
height: 600,
pieSliceText : 'value'};
有关更多详细信息,请单击此处