그래프 만들기-gd 안쓰고

· 15년 전 · 2370

<?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,385
15년 전 조회 1,361
15년 전 조회 2,624
15년 전 조회 2,513
15년 전 조회 5,499
15년 전 조회 1,464
15년 전 조회 4,227
15년 전 조회 1,359
15년 전 조회 1,652
15년 전 조회 1,621
15년 전 조회 1,609
15년 전 조회 1,113
15년 전 조회 1,362
15년 전 조회 1,504
15년 전 조회 1,407
15년 전 조회 2,134
15년 전 조회 1,278
15년 전 조회 1,335
15년 전 조회 882
15년 전 조회 991
15년 전 조회 955
15년 전 조회 920
15년 전 조회 870
15년 전 조회 931
15년 전 조회 1,074
15년 전 조회 1,094
15년 전 조회 2,612
15년 전 조회 939
15년 전 조회 1,590
15년 전 조회 1,461
15년 전 조회 1,583
15년 전 조회 1,292
15년 전 조회 1,779
15년 전 조회 595
15년 전 조회 1,083
15년 전 조회 1,058
15년 전 조회 2,849
15년 전 조회 3,163
15년 전 조회 1,836
15년 전 조회 1,345
15년 전 조회 1,962
15년 전 조회 1,469
15년 전 조회 1,073
15년 전 조회 3,767
15년 전 조회 1,408
15년 전 조회 1,507
15년 전 조회 2,736
15년 전 조회 1,430
15년 전 조회 4,157
15년 전 조회 2,371
15년 전 조회 3,147
15년 전 조회 1,766
15년 전 조회 1,995
15년 전 조회 1,293
15년 전 조회 4,371
15년 전 조회 3,951
15년 전 조회 3,773
15년 전 조회 5,188
15년 전 조회 3,410
15년 전 조회 1,790
15년 전 조회 1,749
15년 전 조회 1,899
15년 전 조회 1,589
15년 전 조회 3,988
15년 전 조회 2,900
15년 전 조회 2,086
15년 전 조회 1,662
15년 전 조회 1,899
15년 전 조회 2,381
15년 전 조회 1,463
15년 전 조회 2,396
15년 전 조회 1,733
15년 전 조회 1,829
15년 전 조회 1,483
15년 전 조회 2,172
15년 전 조회 1,499
15년 전 조회 1,921
16년 전 조회 2,111
16년 전 조회 1,185
16년 전 조회 1,246
16년 전 조회 1,891
16년 전 조회 5,335
16년 전 조회 1,634
16년 전 조회 2,143
16년 전 조회 2,344
16년 전 조회 1,494
16년 전 조회 1,303
16년 전 조회 2,215
16년 전 조회 4,931
16년 전 조회 2,205
16년 전 조회 2,864
16년 전 조회 1,745
16년 전 조회 3,597
16년 전 조회 4,434
16년 전 조회 3,102
16년 전 조회 2,349
16년 전 조회 2,430
16년 전 조회 2,681
16년 전 조회 2,165
16년 전 조회 5,508
🐛 버그신고