jpgraph画柱状图部分代码如下:
$bplot1array = array();
while($row = mysql_fetch_array($query)){
 $datay = array();
 for($i = 0; $i < 7; $i++){
  $datay[] = $row[$i];
 }
 $bplot = new BarPlot($datay);
 $bplot->SetFillColor('[email protected]');
 
 $bplot->SetLegend('Label 1');
 
 $bplot->SetShadow('[email protected]');
 
 $bplotarray[] = $bplot;
 
 
}
$gbarplot = new GroupBarPlot($bplotarray);
$gbarplot->SetWidth(0.6);
$graph->Add($gbarplot);
$graph->Stroke();
报错$bplotarray为空。$datay测试了,有值。

解决方案 »

  1.   

    $bplotarray = array(); //这里原来是$bplot1array,错了
    while($row = mysql_fetch_array($query)){
     $datay = array();
     for($i = 0; $i < 7; $i++){
      $datay[] = $row[$i];
     }
     $bplot = new BarPlot($datay);
     $bplot->SetFillColor('[email protected]');
      
     $bplot->SetLegend('Label 1');
      
     $bplot->SetShadow('[email protected]');
      
     $bplotarray[] = $bplot;
      
     
    }
    $gbarplot = new GroupBarPlot($bplotarray);
    $gbarplot->SetWidth(0.6);
    $graph->Add($gbarplot);
    $graph->Stroke();
      

  2.   

    改了
    已经把
    $bplot1array = array();
    改成
    $bplotarray = array();