【问题标题】:PHPlot only showing 2 of 3 results with MySQLPHPlot 只显示 MySQL 的 3 个结果中的 2 个
【发布时间】: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


【解决方案1】:

我把它们单独拉出来修好了

$datab = mysql_select_db( 'medtrack', $conn ) or die(mysql_error());

$sql1 = "SELECT * FROM $dbmood ORDER BY DATE ASC";



$getit = mysql_query ( $sql1, $conn );

while($row = mysql_fetch_array($getit, MYSQL_ASSOC))
{
$dep="{$row['totaldep']}";
$man="{$row['totalmania']}";
$anx="{$row['totalanxiety']}";


$example_data = array(
array('a',$dep,$man,$anx)
);
}


//Include the code

//Define the object
$graph =& new PHPlot(300,250);
$graph->SetPlotType("pie");
$legend = array();
$legend[] = "Depression";
$legend[] = "Mania";
$legend[] = "Anxiety";


$graph->SetDataValues($example_data);
$graph->SetLegendPixels(1,5,false);
$graph->SetLegend($legend);
//Draw it
$graph->DrawGraph();

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-11-04
    • 1970-01-01
    • 2011-10-13
    • 1970-01-01
    • 2013-06-20
    • 1970-01-01
    • 1970-01-01
    • 2017-08-18
    相关资源
    最近更新 更多