首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用MySQL时,PHPlot仅显示3个结果中的2个

使用MySQL时,PHPlot仅显示3个结果中的2个
EN

Stack Overflow用户
提问于 2014-01-24 04:17:49
回答 1查看 615关注 0票数 0

我有一个饼图,我想让它显示3个结果。我使用的代码来自两条线的图表,这工作得很好,我只是希望它能显示所有3个结果。图例显示全部3个,但图表仅显示前两个。我知道我的代码中有一个错误,我只是找不到它。有什么建议吗?

代码语言:javascript
复制
$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();

提前感谢,你们总是帮助我们!

EN

回答 1

Stack Overflow用户

发布于 2014-01-24 05:04:20

我把它们一个个拔出来解决了

代码语言:javascript
复制
$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();
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/21318446

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档