$daytoday_regs = $_SESSION['pic_daytoday_regs'];//纵坐标数据
$daytoday_days = $_SESSION['pic_daytoday_days'];//横坐标数据
$size = count($daytoday_regs);
$max_regs = 0;
for ($i=0;$i<$size;$i++)
{
if ($max_regs<$daytoday_regs[$i])
{
$max_regs=$daytoday_regs[$i];
}
}
//print_r($pic_daytoday_regs);
//print_r($pic_daytoday_days);
//exit();
$im = imagecreate(530,450); //创建图象
//分配颜色
$black = imagecolorallocate($im, 0,0,0);
$white = imagecolorallocate($im, 255,255,255);
$gray = imagecolorallocate($im, 223,223,223);
$red   = imagecolorallocate($im,255,0,0);
$green = imagecolorallocate($im,0,255,0);
$blue  = imagecolorallocate($im,0,0,255);
$yellow = imagecolorallocate($im,241,236,186);
$unit = ceil($max_regs/300);//每像素代表的单位
//画出矩形并填充
imagefilledrectangle($im,0,0,530,450,$yellow);
imagefilledrectangle($im,50,50,520,350,$white);
imagerectangle($im,0,0,529,449,$black);//画横向虚线及刻度
$style = array ($gray,$gray,$gray,$white);
$style2 = array ($gray,$white,$white,$white);
imagesetstyle($im, $style);
for ($i=50;$i<=350;$i=$i+20) {
imageline($im,50,$i,520,$i,IMG_COLOR_STYLED);
$strtmp=(350-$i)*$unit;
imagestring($im,2,20,$i-10,$strtmp,$blue);
}//输出文字注解
//$strtmp = "title";
//imagestring($im,8,175,20,$strtmp,$black);
$strtmp = "date";
imagestring($im,8,250,420,$strtmp,$black);
$strtmp = "new reg community numbers ";
imagestringup($im,5,2,300,$strtmp,$black);//定义横竖坐标单位//$unit_x=array(50,110,170,230,290,350,420);
//$unit_x=3600*24*30/400;
for ($i=0;$i<count($daytoday_regs);$i++)
{
$x_pos[] = $i*floor(470/$size)+50;
}
//画纵坐标和日期
for ($j=0;$j<count($daytoday_regs);$j++)
{
$cdate=$daytoday_days[$j];
if (($j+1)%5==0)
{
imagestringup($im,2,$x_pos[$j]-5,410,$cdate,$black);
imagesetstyle($im, $style);
imageline($im,$x_pos[$j],50,$x_pos[$j],350,IMG_COLOR_STYLED);
}else
{
imagesetstyle($im, $style2);
imageline($im,$x_pos[$j],50,$x_pos[$j],350,IMG_COLOR_STYLED);
}
}
for ($j=0;$j<count($daytoday_regs)-1;$j++)
{
imageline($im,$x_pos[$j],350-ceil($daytoday_regs[$j]/$unit),$x_pos[$j+1],350-ceil($daytoday_regs[$j+1]/$unit),$red);
}
//完成画图
Imagegif($im); 
ImageDestroy($im);