그래프 만들기-gd 안쓰고

· 15년 전 · 2848

<?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에서 이동 됨]
|
댓글을 작성하시려면 로그인이 필요합니다.

프로그램

+
제목 글쓴이 날짜 조회
15년 전 조회 1,908
15년 전 조회 1,853
15년 전 조회 3,145
15년 전 조회 3,024
15년 전 조회 6,033
15년 전 조회 1,977
15년 전 조회 4,757
15년 전 조회 1,858
15년 전 조회 2,139
15년 전 조회 2,138
15년 전 조회 2,110
15년 전 조회 1,599
15년 전 조회 1,862
15년 전 조회 1,974
15년 전 조회 1,940
15년 전 조회 2,637
15년 전 조회 1,786
15년 전 조회 1,875
15년 전 조회 1,378
15년 전 조회 1,472
15년 전 조회 1,483
15년 전 조회 1,417
15년 전 조회 1,375
15년 전 조회 1,415
15년 전 조회 1,577
15년 전 조회 1,583
15년 전 조회 3,089
15년 전 조회 1,420
15년 전 조회 2,075
15년 전 조회 1,934
15년 전 조회 2,088
15년 전 조회 1,796
15년 전 조회 2,292
15년 전 조회 1,085
15년 전 조회 1,595
15년 전 조회 1,561
15년 전 조회 3,351
15년 전 조회 3,690
15년 전 조회 2,381
15년 전 조회 1,842
15년 전 조회 2,447
15년 전 조회 1,945
15년 전 조회 1,560
15년 전 조회 4,248
15년 전 조회 1,899
15년 전 조회 1,989
15년 전 조회 3,251
15년 전 조회 1,949
15년 전 조회 4,655
15년 전 조회 2,849
15년 전 조회 3,651
15년 전 조회 2,254
15년 전 조회 2,485
15년 전 조회 1,795
15년 전 조회 4,860
15년 전 조회 4,470
16년 전 조회 4,266
16년 전 조회 5,685
16년 전 조회 3,905
16년 전 조회 2,265
16년 전 조회 2,221
16년 전 조회 2,376
16년 전 조회 2,070
16년 전 조회 4,504
16년 전 조회 3,405
16년 전 조회 2,571
16년 전 조회 2,163
16년 전 조회 2,365
16년 전 조회 2,868
16년 전 조회 1,959
16년 전 조회 2,877
16년 전 조회 2,205
16년 전 조회 2,327
16년 전 조회 1,950
16년 전 조회 2,667
16년 전 조회 1,979
16년 전 조회 2,404
16년 전 조회 2,575
16년 전 조회 1,643
16년 전 조회 1,713
16년 전 조회 2,385
16년 전 조회 5,798
16년 전 조회 2,111
16년 전 조회 2,635
16년 전 조회 2,816
16년 전 조회 1,969
16년 전 조회 1,758
16년 전 조회 2,672
16년 전 조회 5,399
16년 전 조회 2,660
16년 전 조회 3,321
16년 전 조회 2,192
16년 전 조회 4,077
16년 전 조회 4,877
16년 전 조회 3,525
16년 전 조회 2,780
16년 전 조회 2,899
16년 전 조회 3,110
16년 전 조회 2,627
16년 전 조회 5,976