0

我是使用 pChart 的新手。我从数据库中获取数据来构建图表。

我将有随机数量的行,我想为每一行做一个图表。(一行 -> 一个图表)。可能吗?

到目前为止,我可以绘制图表,但所有行都在同一个图表中。

这是我的代码:

<?php

include("pChart/class/pData.class.php");
include("pChart/class/pDraw.class.php");
include("pChart/class/pImage.class.php");
include("pChart/class/pPie.class.php"); 

$myData = new pData(); 

$Requete = "SELECT * FROM `day`"; 
$Result = mysql_query($Requete, $db);

while($row = mysql_fetch_array($Result)){
    $hour = explode(" ", $row["g1"]);
    $nb = $row["numb"] * 2;
    for($i = 0; $i < $nb; $i++){
        if ($i%2 == 1){  
            $time[$i] = ($hour[$i])/ 60;    
            $myData->addPoints($time[$i],"year"); 
        }else{ 
            if ($hour[$i] == "00"){
                $name[$i] = "On";
            }elseif ($hour[$i] == "02"){
                $name[$i] = "Off";
            }
            $myData->addPoints($name[$i],"name");
        }
    }
}

$myData->setAbscissa("name");
$myData->setSerieDescription("year","Application A"); 
$myPicture = new pImage(600,300,$myData);  
$myPicture->setFontProperties(array("FontName"=>"pChart/fonts/tahoma.ttf","FontSize"=>16));  
$PieChart = new pPie($myPicture,$myData);  
$PieChart->draw3DPie(340,125,array("DrawLabels"=>TRUE,"Border"=>TRUE)); 
$myPicture->autoOutput("images/example.png");   
?>
4

1 回答 1

0

如果我理解这个问题,你想要每一行的图片吗?在这种情况下,我认为您必须在 while 循环中包含代码的下半部分(从 $myData 到 $myPicture)。

于 2013-10-08T03:23:02.003 回答