그래프 만들기-gd 안쓰고

· 15년 전 · 2866

<?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,929
15년 전 조회 1,870
15년 전 조회 3,157
15년 전 조회 3,046
15년 전 조회 6,051
15년 전 조회 2,001
15년 전 조회 4,777
15년 전 조회 1,884
15년 전 조회 2,163
15년 전 조회 2,157
15년 전 조회 2,140
15년 전 조회 1,625
15년 전 조회 1,876
15년 전 조회 1,995
15년 전 조회 1,962
15년 전 조회 2,654
15년 전 조회 1,810
15년 전 조회 1,902
15년 전 조회 1,398
15년 전 조회 1,496
15년 전 조회 1,508
15년 전 조회 1,435
15년 전 조회 1,398
15년 전 조회 1,428
15년 전 조회 1,594
15년 전 조회 1,601
15년 전 조회 3,110
15년 전 조회 1,443
15년 전 조회 2,088
15년 전 조회 1,947
15년 전 조회 2,105
15년 전 조회 1,813
15년 전 조회 2,315
15년 전 조회 1,111
15년 전 조회 1,606
15년 전 조회 1,584
15년 전 조회 3,368
15년 전 조회 3,704
15년 전 조회 2,401
15년 전 조회 1,858
15년 전 조회 2,468
15년 전 조회 1,957
15년 전 조회 1,580
15년 전 조회 4,268
15년 전 조회 1,922
15년 전 조회 2,005
15년 전 조회 3,267
15년 전 조회 1,971
15년 전 조회 4,684
15년 전 조회 2,867
15년 전 조회 3,663
15년 전 조회 2,264
15년 전 조회 2,502
15년 전 조회 1,815
15년 전 조회 4,875
15년 전 조회 4,483
16년 전 조회 4,280
16년 전 조회 5,707
16년 전 조회 3,926
16년 전 조회 2,281
16년 전 조회 2,245
16년 전 조회 2,396
16년 전 조회 2,095
16년 전 조회 4,521
16년 전 조회 3,421
16년 전 조회 2,589
16년 전 조회 2,181
16년 전 조회 2,382
16년 전 조회 2,881
16년 전 조회 1,977
16년 전 조회 2,894
16년 전 조회 2,224
16년 전 조회 2,344
16년 전 조회 1,965
16년 전 조회 2,686
16년 전 조회 2,000
16년 전 조회 2,424
16년 전 조회 2,596
16년 전 조회 1,667
16년 전 조회 1,731
16년 전 조회 2,405
16년 전 조회 5,817
16년 전 조회 2,132
16년 전 조회 2,653
16년 전 조회 2,831
16년 전 조회 1,996
16년 전 조회 1,785
16년 전 조회 2,702
16년 전 조회 5,418
16년 전 조회 2,690
16년 전 조회 3,344
16년 전 조회 2,215
16년 전 조회 4,096
16년 전 조회 4,896
16년 전 조회 3,545
16년 전 조회 2,797
16년 전 조회 2,913
16년 전 조회 3,128
16년 전 조회 2,641
16년 전 조회 5,994