그래프 만들기-gd 안쓰고

· 15년 전 · 2375

<?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,392
15년 전 조회 1,365
15년 전 조회 2,634
15년 전 조회 2,517
15년 전 조회 5,503
15년 전 조회 1,472
15년 전 조회 4,235
15년 전 조회 1,364
15년 전 조회 1,663
15년 전 조회 1,626
15년 전 조회 1,616
15년 전 조회 1,119
15년 전 조회 1,364
15년 전 조회 1,507
15년 전 조회 1,410
15년 전 조회 2,138
15년 전 조회 1,283
15년 전 조회 1,342
15년 전 조회 887
15년 전 조회 998
15년 전 조회 960
15년 전 조회 924
15년 전 조회 873
15년 전 조회 938
15년 전 조회 1,079
15년 전 조회 1,100
15년 전 조회 2,620
15년 전 조회 947
15년 전 조회 1,601
15년 전 조회 1,467
15년 전 조회 1,591
15년 전 조회 1,299
15년 전 조회 1,786
15년 전 조회 605
15년 전 조회 1,093
15년 전 조회 1,061
15년 전 조회 2,854
15년 전 조회 3,171
15년 전 조회 1,845
15년 전 조회 1,351
15년 전 조회 1,970
15년 전 조회 1,473
15년 전 조회 1,077
15년 전 조회 3,772
15년 전 조회 1,413
15년 전 조회 1,510
15년 전 조회 2,742
15년 전 조회 1,436
15년 전 조회 4,161
15년 전 조회 2,376
15년 전 조회 3,154
15년 전 조회 1,769
15년 전 조회 1,999
15년 전 조회 1,301
15년 전 조회 4,376
15년 전 조회 3,956
15년 전 조회 3,779
15년 전 조회 5,195
15년 전 조회 3,416
15년 전 조회 1,796
15년 전 조회 1,759
15년 전 조회 1,901
15년 전 조회 1,596
15년 전 조회 3,997
15년 전 조회 2,908
15년 전 조회 2,090
15년 전 조회 1,670
15년 전 조회 1,905
15년 전 조회 2,384
15년 전 조회 1,468
15년 전 조회 2,400
15년 전 조회 1,736
15년 전 조회 1,836
15년 전 조회 1,490
15년 전 조회 2,176
15년 전 조회 1,507
15년 전 조회 1,923
16년 전 조회 2,113
16년 전 조회 1,186
16년 전 조회 1,251
16년 전 조회 1,899
16년 전 조회 5,339
16년 전 조회 1,637
16년 전 조회 2,148
16년 전 조회 2,349
16년 전 조회 1,499
16년 전 조회 1,309
16년 전 조회 2,223
16년 전 조회 4,935
16년 전 조회 2,212
16년 전 조회 2,867
16년 전 조회 1,748
16년 전 조회 3,600
16년 전 조회 4,442
16년 전 조회 3,105
16년 전 조회 2,353
16년 전 조회 2,434
16년 전 조회 2,683
16년 전 조회 2,172
16년 전 조회 5,512
🐛 버그신고