0

簡単な例を機能させるのに苦労しています。機能する例を見ると、問題はないはずですが、そのポイントに到達できません。コードは次のとおりです。

foreach($users as $user => $tbl_user_id)
{
    $query = "SELECT * FROM my_table WHERE name = '$user'". $sel_query_tech . "" ;

    $result = mysql_query($query);
    $query_num_rows = mysql_num_rows($result);
    $tc = mysql_num_rows($query);           

    $user_hours_query = "SELECT * FROM tbl_activity WHERE activity_user_id = '$tbl_user_id' AND activity_task_id = '10' ". $sel_query . "" ;
    $result1 = mysql_query($user_hours_query);
    $hours_worked = 0;

            while ($row1 = mysql_fetch_array($result1))
                {
                $hours_worked += $row1['activity_hrs_done'];
                }

    echo '<tr><td>'.$user.'</td>';
    echo '<td>'.$tbl_user_id.'</td>';
    echo '<td>'. $tc_num_rows.'</td>';
    echo '<td>'. number_format($hours_worked,2).'</td>';
    $rt = number_format($query_num_rows / $hours_worked ,2);
    echo '<td>'. $rt.'</td></tr>';  
    $data[]=number_format($hours_worked,2);
    $p1->SetLegends[]=$user;
    }

// Some data
//$data = array(40,21,17,27,23);

// Create the Pie Graph. 
$graph = new PieGraph(400,200,'auto');
$graph->SetShadow();

// Set A title for the plot
$graph->title->Set("3D Pie Client side image map");
$graph->title->SetFont(FF_FONT1,FS_BOLD);

// Create
$p1 = new PiePlot3D($data);
//$p1->SetLegends(array("Jan (%d)","Feb","Mar","Apr","May","Jun","Jul"));
$targ=array("pie3d_csimex1.php?v=1","pie3d_csimex1.php?v=2","pie3d_csimex1.php?v=3",
            "pie3d_csimex1.php?v=4","pie3d_csimex1.php?v=5","pie3d_csimex1.php?v=6");
$alts=array("val=%d","val=%d","val=%d","val=%d","val=%d","val=%d");
$p1->SetCSIMTargets($targ,$alts);

// Use absolute labels
$p1->SetLabelType(1);
$p1->value->SetFormat("%d kr");

// Move the pie slightly to the left
$p1->SetCenter(0.4,0.5);

$graph->Add($p1);


// Send back the HTML page which will call this script again
// to retrieve the image.
$graph->StrokeCSIM();

$p1->SetLegendsが間違っていることはわかっています。それと$dataoutの両方をprint_rすると、$ dataは値を返しますが、$ p1は返しませんが、実際には少し失われており、いくつかのガイダンスで行うことができます。

$ data = array(40,21,17,27,23);のような設定値を使用する場合 $ p1-> SetLegends(array( "Jan(%d)"、 "Feb"、 "Mar"、 "Apr"、 "May"、 "Jun"、 "Jul"));

それからそれはうまくいくので、それは私が情報を渡す方法と関係があります、何かアイデアはありますか?

4

1 に答える 1

0

このコードをコードに書き込んでください。これがお役に立てば幸いです

   //$p1->SetLegends[]=$user;
    $userarr[] = $user;

それから

$p1 = new PiePlot3D($data);
//$p1->SetLegends(array("Jan (%d)","Feb","Mar","Apr","May","Jun","Jul"));

$p1->SetLegends($userarr);
于 2013-01-15T04:45:53.140 に答える