• 技术文章 >后端开发 >php教程

    如何用php作线形图的函数_PHP教程

    2016-07-20 11:04:59原创425
    很高兴大家对PHP如此的情有独钟!
    下面就给大家介绍php作线形图的函数:
    /*
    函数说明
    $data:y轴数据(数组)
    $graphdata:y轴数据--百分比(数组)
    $label:x轴数据(数组)
    $height:图像高度
    $width:图像宽度
    $font:字号
    $dot:决定点的大小
    $bg:背景色
    $line :线色
    $text :文本色
    $dotcolor:点色
    $file:输出图像文件名
    */
    function qximage($data ,
    $graphdata,
    $label ,
    $height,
    $width ,
    $font,
    $dot,
    $bg,
    $line,
    $text,
    $dotcolor,
    $file)
    {
    $jc=$height/100;
    $fontwidth= imagefontwidth ($font);
    $fontheight=imagefontheight($font);
    $image= imagecreate ($width,$height+20);
    $bg= imagecolorallocate($image ,$bg[0],$bg[1],$bg[2]);
    $line=imagecolorallocate($image ,$line[0],$line[1],$line[2]);
    $text=imagecolorallocate($image ,$text[0],$text[1],$text[2]);
    $dotcolor=imagecolorallocate($image ,$dotcolor[0],$dotcolor[1],$$dotcolor[2]);
    imageline ($image,0,0,0,$height,$line);
    imageline($image,0,$height,$width,$height,$line);
    for ($i=1;$i<11;$i++)
    {
    imagedashedline($image,0,$height - $jc*$i*10 ,$width ,$height -$jc*$i*10 ,$line );
    imagestring ($image,$font,0,$height-$jc*$i*10,$i*10,$text);
    }
    for ($i=0;$i {
    #echo $tmp."
    ";
    $x1=(($width-50)/count($data))*($i)+40;
    #echo $x1 ."
    ";
    $y1=$height-$graphdata[$i]*$jc;
    $x2=$x1;
    $y2=$y1+$graphdata[$i]*$jc;
    #echo $y1."
    ";
    imagestring($image,$font,$x1,$y1-2*$fontheight,$graphdata[$i]."%(".$data[$i].")",$text);
    imagearc ($image,$x1 ,$y1,$dot,$dot,0,360,$dotcolor);
    imagefilltoborder ($image,$x1,$y1,$dotcolor,$dotcolor);
    imagestring ($image,$font,$x1,$y2,$label[$i],$text);
    if ($i>0)
    {
    imageline($image,$tmpx1,$tmpy1,$x1,$y1,$line);
    }
    $tmpx1=$x1;$tmpy1=$y1;
    }
    imagegif ($image,$file);
    }
    ?>


    www.bkjia.comtruehttp://www.bkjia.com/PHPjc/445170.htmlTechArticle很高兴大家对PHP如此的情有独钟! 下面就给大家介绍php作线形图的函数: /* 函数说明 $data:y轴数据(数组) $graphdata:y轴数据--百分比(数组...

    声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。
    专题推荐: 何用 php 作线 形图 函数 很高兴 大家 PHP 如此 情有独钟 下面 介绍 php 作线
    上一篇:用PHP实现WEB动态网页静态化_PHP教程 下一篇:如何利用PHP会话显示出当前在_PHP教程
    千万级数据并发解决方案

    相关文章推荐

    • 这么写是为啥?运行过程是怎样的• 上载上来的网站不能登录什么有关问题• thinkphp中判断远路及非远程文件是否存在• discuz密码加密的有关问题• php摘引详解,php引用传递使用,php引用方法返回,php引用分析
    1/1

    PHP中文网