그래프 만들기-gd 안쓰고

· 15년 전 · 2365

<?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,382
15년 전 조회 1,354
15년 전 조회 2,618
15년 전 조회 2,506
15년 전 조회 5,492
15년 전 조회 1,458
15년 전 조회 4,222
15년 전 조회 1,353
15년 전 조회 1,646
15년 전 조회 1,611
15년 전 조회 1,605
15년 전 조회 1,106
15년 전 조회 1,357
15년 전 조회 1,497
15년 전 조회 1,400
15년 전 조회 2,130
15년 전 조회 1,272
15년 전 조회 1,331
15년 전 조회 873
15년 전 조회 986
15년 전 조회 948
15년 전 조회 915
15년 전 조회 863
15년 전 조회 925
15년 전 조회 1,069
15년 전 조회 1,089
15년 전 조회 2,606
15년 전 조회 934
15년 전 조회 1,587
15년 전 조회 1,457
15년 전 조회 1,578
15년 전 조회 1,286
15년 전 조회 1,774
15년 전 조회 594
15년 전 조회 1,080
15년 전 조회 1,051
15년 전 조회 2,843
15년 전 조회 3,156
15년 전 조회 1,832
15년 전 조회 1,340
15년 전 조회 1,958
15년 전 조회 1,463
15년 전 조회 1,067
15년 전 조회 3,760
15년 전 조회 1,403
15년 전 조회 1,500
15년 전 조회 2,729
15년 전 조회 1,427
15년 전 조회 4,152
15년 전 조회 2,366
15년 전 조회 3,142
15년 전 조회 1,761
15년 전 조회 1,990
15년 전 조회 1,289
15년 전 조회 4,367
15년 전 조회 3,941
15년 전 조회 3,770
15년 전 조회 5,183
15년 전 조회 3,405
15년 전 조회 1,785
15년 전 조회 1,746
15년 전 조회 1,890
15년 전 조회 1,584
15년 전 조회 3,983
15년 전 조회 2,895
15년 전 조회 2,082
15년 전 조회 1,659
15년 전 조회 1,895
15년 전 조회 2,376
15년 전 조회 1,459
15년 전 조회 2,393
15년 전 조회 1,726
15년 전 조회 1,822
15년 전 조회 1,477
15년 전 조회 2,167
15년 전 조회 1,497
15년 전 조회 1,912
15년 전 조회 2,105
16년 전 조회 1,180
16년 전 조회 1,240
16년 전 조회 1,886
16년 전 조회 5,328
16년 전 조회 1,631
16년 전 조회 2,139
16년 전 조회 2,340
16년 전 조회 1,488
16년 전 조회 1,297
16년 전 조회 2,212
16년 전 조회 4,926
16년 전 조회 2,201
16년 전 조회 2,857
16년 전 조회 1,738
16년 전 조회 3,592
16년 전 조회 4,429
16년 전 조회 3,098
16년 전 조회 2,343
16년 전 조회 2,425
16년 전 조회 2,673
16년 전 조회 2,162
16년 전 조회 5,503
🐛 버그신고