1. <tt id="5hhch"><source id="5hhch"></source></tt>
    1. <xmp id="5hhch"></xmp>

  2. <xmp id="5hhch"><rt id="5hhch"></rt></xmp>

    <rp id="5hhch"></rp>
        <dfn id="5hhch"></dfn>

      1. PHP 柱形統計圖的實現代碼

        時間:2024-06-23 03:17:25 PHP 我要投稿
        • 相關推薦

        PHP 柱形統計圖的實現代碼

          效果圖:

          復制代碼 代碼如下:

          <?php

          function createImage($data,$twidth,$tspace,$height){

          header("Content-Type:image/jpeg");

          $dataname = array();

          $datavalue = array();//data里面的值

          $i = 0;

          $j = 0;

          $k = 0;

          $num = sizeof($data);

          foreach($data as $key => $val){

          $dataname[] = $key;

          $datavalue[] = $val;

          }

          $width = $num * ($twidth + $tspace) + 20 ;//獲取圖像的寬度

          $im = imagecreate($width,$height);//創建圖像

          $bgcolor = imagecolorallocate($im,255,255,255);//背景色

          $jcolor = imagecolorallocate($im,255,255,0);//矩形的背景色

          $acolor = imagecolorallocate($im,0,0,0);//線的顏色

          imageline($im,25,$height-20,$width-5,$height -20,$acolor);//X軸

          imageline($im,25,$height-20,25,2,$acolor);//Y軸

          while($i< $num){

          imagefilledrectangle($im,$i*($tspace+$twidth)+40,$height-$datavalue[$i]-20,$i*($twidth+$tspace)+$tspace+40,$height-20,$jcolor);//畫矩形

          imagestring($im,3,$i*($tspace+$twidth)+40+$twidth/2,$height-$datavalue[$i]-35,$datavalue[$i],$acolor);//在柱子上面寫出值

          imagestring($im,3,$i*($tspace+$twidth)+40+$twidth/2,$height-15,$dataname[$i],$acolor);//在柱子下面寫出值

          $i ++;

          }

          while($j < 400/10){

          imageline($im,25,($height-20)-$j*8,28,($height-20)-$j*8,$acolor);//畫出刻度

          imagestring($im,2,5,($height-30)-$j*8,$j*10,$acolor);//標出刻度值

          $j = $j +10;

          }

          imagejpeg($im);

          }

          $data =array("1"=>25,"2"=>30,"3" =>21 );

          createImage($data,40,40,300);

          ?>

        【PHP 柱形統計圖的實現代碼】相關文章:

        將php實現過濾UBB代碼09-11

        php如何過濾危險html代碼09-21

        php對圖像的各種處理函數代碼總結07-03

        如何在cmd下面寫php代碼01-22

        JavaScript實現網頁刷新代碼段08-07

        PHP url 加密解密函數代碼方法10-25

        探討PHP函數的實現原理及性能07-07

        關于php堆排序實現原理與應用方法10-09

        防盜鏈接ASP函數實現代碼01-23

        常用排序算法之JavaScript實現代碼段06-04

        国产高潮无套免费视频_久久九九兔免费精品6_99精品热6080YY久久_国产91久久久久久无码

        1. <tt id="5hhch"><source id="5hhch"></source></tt>
          1. <xmp id="5hhch"></xmp>

        2. <xmp id="5hhch"><rt id="5hhch"></rt></xmp>

          <rp id="5hhch"></rp>
              <dfn id="5hhch"></dfn>