확

그래프 만들기-gd 안쓰고

· 2010-04-28 (수) 18:06:20 · 3920

<?php
/* ================================================================
 * filename  :  gra.php
 * Creator  :  이창열, 2009. 02. 22

 * Comment :  그래프 그리기
 ==================================================================*/
 
# 그래프 출력을 위한 데이터의 최대값및 최소값 세팅
$maxVal = 50;  // 최대값 5백만
$step = 5;   // 단위 5십만


$arrVal = array(25,18, 34, 46, 10, 29, 17, 38, 26, 25, 27, 39, 44, 22, 16, 43, 39, 22, 44, 18, 14, 22, 32, 45);

function showStickGraph($maxVal, $minVal, $step, $arrVal)
{
 $bottomCommentHeight= 30;    // 하단 설명공간 높이 픽셀값
 $cntY = round($maxVal / $step);  // y축 눈금개수
 $unitHight = 30;        // 단위 높이 픽셀값
 $minVal = 0;         // 최소값
 $k= 10;
 
?>
 <table cellpadding=0 cellspacing=0 border="1" >
  <tr>
   
   <!-- y축-->
   <td >
     <table cellpadding=0 cellspacing=0 border="1" >
      
      <? for ($a= $maxVal; $a >= $minVal; $a -= $step){ ?>
      <tr>
       <td height="<?=$unitHight?>" valign="bottom" align="right">
        <font size="2"><?=$a?></font>
       </td>
      </tr>
      <?}?>
      
      <tr>
       <td height="<?=$bottomCommentHeight?>">
        <font size="2">매출<br>(단위:10만)</font></td>
      </tr>
      
     </table>
 
    </td>
   
   <!--x축-->
   <td valign="bottom"> 
    <table cellpadding=0 cellspacing=0 border="0" >
     <tr>
      <? for ($i= 0; $i < 24; $i++){ ?>
      <td align="center" valign="bottom">
          <table cellpadding=0 cellspacing=0 border="1" >
           <tr>
         <td width="20" height="<?=($arrVal[$i])/$step * $unitHight ?>" bgcolor="green" valign="top" align="center">
          <font size="2" color="white"><b><?=$arrVal[$i]?></b></font></td>
        </tr>
        
        <tr>
         <td height="<?=$bottomCommentHeight?>" valigh="top"><font size="2"><?=($i<10)?"0$i":$i?></font></td>
        </tr>
       </table>
        </td>
        <?}?>
      </tr>
     
     </table>

    </td>
  
  </tr>
 </table>
<?
}
showStickGraph($maxVal, $minVal, $step, $arrVal);
?>

[이 게시물은 관리자님에 의해 2011-10-31 16:55:28 jQuery에서 이동 됨]
댓글을 작성하시려면 로그인이 필요합니다.

프로그램

8,187건
+
제목 글쓴이 날짜 조회
08-11-25 조회 3,776
08-11-25 조회 2,970
08-11-25 조회 4,546
08-11-25 조회 4,417
08-11-21 조회 4,399
08-11-21 조회 5,329
08-11-20 조회 3,956
08-11-20 조회 3,767
08-11-19 조회 4,037
08-11-19 조회 4,276
08-11-18 조회 4,057
08-11-15 조회 2,935
08-11-14 조회 3,240
08-11-14 조회 2,908
08-11-14 조회 3,299
08-11-13 조회 3,923
08-11-12 조회 1만
08-11-07 조회 4,628
08-11-07 조회 5,621
08-11-03 조회 3,385
08-11-01 조회 5,091
08-11-01 조회 3,047
08-10-30 조회 2,756
08-10-30 조회 3,688
08-10-30 조회 2,782
08-10-30 조회 3,019
08-10-30 조회 2,887
08-10-29 조회 3,960
08-10-29 조회 2,942
08-10-29 조회 2,474
08-10-20 조회 2,612
08-10-18 조회 4,558
08-10-16 조회 3,614
08-10-16 조회 3,416
08-10-14 조회 2,617
08-10-11 조회 3,920
08-10-11 조회 2,509
08-10-09 조회 2,606
08-10-09 조회 2,760
08-10-09 조회 4,232
08-10-08 조회 3,928
08-10-02 조회 3,868
08-10-02 조회 2,614
08-10-02 조회 2,764
08-09-29 조회 4,696
08-09-29 조회 4,325
08-09-26 조회 5,639
08-09-26 조회 3,606
08-09-26 조회 3,677
08-09-26 조회 2,818
08-09-26 조회 3,858
08-09-26 조회 3,600
08-09-26 조회 4,360
08-09-22 조회 3,924
08-09-22 조회 3,107
08-09-22 조회 4,071
08-09-22 조회 3,032
08-09-22 조회 2,683
08-09-21 조회 3,677
08-09-20 조회 4,251
08-09-20 조회 5,522
08-09-20 조회 4,627
08-09-20 조회 2,944
08-09-20 조회 3,345
08-09-20 조회 3,706
08-09-20 조회 3,088
08-09-20 조회 3,272
08-09-20 조회 4,256
08-09-20 조회 3,754
08-09-20 조회 3,333
08-09-19 조회 5,732
08-09-19 조회 4,509
08-09-19 조회 2,820
08-09-18 조회 5,173
08-09-18 조회 4,256
08-09-18 조회 3,626
08-09-18 조회 2,824
08-09-18 조회 3,742
08-09-18 조회 3,545
08-09-17 조회 3,403
08-09-16 조회 3,346
08-09-10 조회 2,561
08-09-09 조회 3,363
08-09-06 조회 4,249
08-09-06 조회 2,811
08-09-06 조회 3,183
08-09-06 조회 2,841
08-09-06 조회 3,073
08-09-06 조회 2,956
08-09-06 조회 2,932
08-09-05 조회 3,932
08-09-05 조회 3,761
08-09-05 조회 3,580
08-09-05 조회 2,800
08-09-05 조회 3,824
08-09-05 조회 5,787
08-09-05 조회 4,248
08-09-05 조회 3,144
08-09-05 조회 3,288
08-09-05 조회 4,714