Im struggling to get a simple example working, once i see a working example i should be fine but cant get to that point, heres my code:
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();
I know $p1->SetLegends is wrong as i print_r both that and $data out, $data returns the values but not $p1 but im really a bit lost and could do with some guidance.
If i just use the set values like $data = array(40,21,17,27,23); $p1->SetLegends(array("Jan (%d)","Feb","Mar","Apr","May","Jun","Jul"));
Then it works fine so its something to do with how i pass the info, any ideas?
Please write this code into your code. I hope this will help you
//$p1->SetLegends[]=$user;
$userarr[] = $user;
then
$p1 = new PiePlot3D($data);
//$p1->SetLegends(array("Jan (%d)","Feb","Mar","Apr","May","Jun","Jul"));
$p1->SetLegends($userarr);