【发布时间】:2014-01-23 20:17:49
【问题描述】:
我有一个饼图,我希望它显示 3 个结果。我正在使用 2 折线图中的代码,效果很好,我只是希望它显示所有 3 个结果。图例显示所有 3 个,但图表仅显示前两个。我知道我的代码中有错误,但我找不到它。有什么建议吗?
$sql1 = "SELECT totaldep, totalmania, totalanxiety FROM $dbmood ORDER BY DATE ASC";
//Define the object
$rslt1 = @mysql_query($sql1, $conn) or die("Couldn't execute select:".@mysql_error());
// I'm assuming it's somewhere in here, I just can't see it
$iid = "-1";
while($row = mysql_fetch_row($rslt1)) {
if ($row[0] != $iid) {
$iid = $row[0];
} else {
$row[0] = '';
}
// between there and here
$graph_data[] = $row;
//Define some data
$example_data = $graph_data;
}
//Define the object
$graph =& new PHPlot(300,250);
$graph->SetPlotType("pie");
$legend = array();
$legend[] = "Depression";
$legend[] = "Mania";
// It isn't showing anxiety, everything else is showing/updating fine
$legend[] = "Anxiety";
$graph->SetDataValues($example_data);
$graph->SetLegendPixels(1,5,false);
$graph->SetLegend($legend);
//Draw it
$graph->DrawGraph();
提前谢谢你们,你们总是帮忙!
【问题讨论】:
-
不要使用这些函数(mysql_)。它们已被弃用。
标签: php mysql graph charts pie-chart