//轉載請標注:製作人Seven(QQ9256114 / see7di@gmail.com)
//參數含義(數組,橫坐標,縱坐標,圖表的寬度,圖表的高度,圖表標題,單位)
Function table2($stat_array,$table_left,$table_top,$all_width,$all_height,$table_title,$unit){
$num =Count($stat_array);

For($i=0;$i<$num;$i++){
Static $allvalues=0;
$allvalues = $allvalues+$stat_array[$i][0];
}

$pie=Array();
For($i=0;$i<$num;$i++){
Static $k=0;
$pie[$i]=Round($stat_array[$i][0]/$allvalues,2);
$k=$k+$pie[$i];
}

$pie[$num]=Round((1-$k),2);

Echo "";

Echo "path='m@7,l@8,m@5,21600l@6,21600e'> ";
Echo "";
Echo "";
Echo "";
Echo "
";

Echo "";
Echo "";
Echo "
";

Echo "";
Echo "";
Echo "";
Echo "

";
Echo "";
Echo "
".$table_title."
";
Echo "";
Echo " ";

Echo "";
Echo "";
Echo "
";

Echo "";
Echo "";
Echo "";
Echo "
";

Echo "";
Echo "

总数:".$allvalues.$unit."
";
Echo " ";

For($i=0;$i<$num;$i++){
Echo "";
Echo "";
Echo "
";
Echo "";
Echo "";
Echo "

".$stat_array[$i][1].":".$stat_array[$i][0].$unit."
";
Echo " ";
}

Echo "";

$k1=180;
$k4=10;
For($i=0;$i<$num;$i++){
$k2=360*$pie[$i]/2;
$k3=$k1+$k2;
IF($k3>=360){
   $k3=$k3-360;
}
$kkk=(-11796480*$pie[$i]+5898240);

$k5=3.1414926*2*(180-($k3-180))/360;
$R=$all_height/2;
$txt_x = $table_left+$all_height/8-30+$R+$R*sin($k5)*0.7;
$txt_y = $table_top+$all_height/14-39+$R+$R*cos($k5)*0.7*0.5;

$titlestr = "名 稱:".$stat_array[$i][1]." 數 值:".$stat_array[$i][0].$unit." 所佔比例:".($pie[$i]*100)."% ";
Echo "

";
Echo "";
Echo "";
Echo "";
Echo "
";
Echo "";
Echo "
";
$k1=$k1+$k2*2;
IF($k1>=360){
   $k1=$k1-360;
}
IF($k1>180){
   $k4=$k4+1;
}else{
   $k4=$k4-1;
}
}
}
?>





$total=array(
    0=>array(0=>2000,1=>"項目1",2=>"#ff1919"),
    1=>array(0=>1800,1=>"項目2",2=>"#ffff19"),
    2=>array(0=>1700,1=>"項目3",2=>"#1919ff"),
    3=>array(0=>1500,1=>"項目4",2=>"#19ff19"),
    4=>array(0=>1222,1=>"項目5",2=>"#fc0"),
    5=>array(0=>1100,1=>"項目6",2=>"#3cc"),
    6=>array(0=>1000,1=>"項目7",2=>"#ff19ff"),
    7=>array(0=>800,1=>"項目8",2=>"#993300"),
    8=>array(0=>700,1=>"項目9",2=>"#f60"),
    9=>array(0=>600,1=>"項目10",2=>"#a18c19")

);


table2($total,140,100,700,400,"三維餅狀圖","元");
?>

創作者介紹

電腦軟體討論交流區

逗號 發表在 痞客邦 留言(0) 人氣()