//.............................function_DIAGRAMM...............................//
function Diagramm($value,$value_text,$header_text,$type) {
//siize of the image
//color of the text:
//count the number of legend content
$legend_count=count($value_text); $max_length=0;
foreach($value_text as $v) if ($max_length<strlen
($v)) $max_length=strlen($v); $FONT=2;
$l_width=($font_w*$max_length)+$font_h+20;
$l_height=$font_h*$legend_count+20;
//header text
$text_header_x=$font_h+200;
$text_header_y=10;
$FONT_HEADER=3;
ImageString($im,$FONT_HEADER, $text_header_x,$text_header_y,$heading_text, $fontcolor);
//the type.......................................................................//
//.................................................//
//legend and square
$text_x=$font_h+10;
$text_y=10;
$square_x=10;
$i=0;
if($type=1) {
foreach($value_text as $v) {
$dy=$text_y+($i*$font_h);
$square_x+1,$dy+1,$square_x+$font_h-1,$dy+$font_h-1,
$COLORS[$i+1]);
$square_x+1,$dy+1,$square_x+$font_h-1,$dy+$font_h-1,
$fontcolor);
$i++;
}
}
//.................................................//
//.................................................//
$i=1;
// count the angels
while($i<count($value)) {
$part=$value[$i-1]/$total;
$angle_grad[$i]=floor($part*360
); $angle_percent[$i]=floor($part*100
); $anglesum_percent[$i]=array_sum($angle_percent); $i++;
}
$anglesum[]=$anglesum[0];
$anglesum_percent[]=$anglesum_percent[0];
//esli type=2
//.................................................//
//.................................................//
if ($type==2)
{
foreach($anglesum_percent[$i-1] as $p) {
ImageString($im, $FONT, $square_x+$font_h-1
, $dy+$font_h-1
, $p, $fontcolor); $i++;
}
foreach($value_text as $v) {
$dy=$text_y+($i*$font_h);
$square_x+1,$dy+1,$square_x+$font_h-1,$dy+$font_h-1,
$COLORS[$i+1]);
$square_x+1,$dy+1,$square_x+$font_h-1,$dy+$font_h-1,
$fontcolor);
$i++;
}
}
//.................................................//
//.................................................//
$diametr =-110;
$circle_x = ($diametr/2)+200;
//using the height of the image
$circle_y = $H/2-10;
//correct the diametr
if ($diametr>($H*2)-20) $diametr=($H*2)-80;
//................not...important................................//
//make a shadow
for ($j=20;$j>0;$j--)
for ($i=0;$i<count($anglesum)-1;$i++)
$diametr,$diametr/2,
$anglesum[$i],$anglesum[$i+1],
$SHADOWS[$i],IMG_ARC_PIE);
//.................................................//
//output the diagramm:
for ($i=0;$i<count($anglesum)-1;$i++)
$diametr,$diametr/2,
$anglesum[$i],$anglesum[$i+1],
$COLORS[$i],IMG_ARC_PIE);
}
//.............................................................................................//