그래프 만들기-gd 안쓰고

· 15년 전 · 2679

<?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,718
15년 전 조회 1,680
15년 전 조회 2,959
15년 전 조회 2,874
15년 전 조회 5,876
15년 전 조회 1,804
15년 전 조회 4,602
15년 전 조회 1,702
15년 전 조회 1,962
15년 전 조회 1,945
15년 전 조회 1,940
15년 전 조회 1,433
15년 전 조회 1,677
15년 전 조회 1,820
15년 전 조회 1,743
15년 전 조회 2,445
15년 전 조회 1,608
15년 전 조회 1,730
15년 전 조회 1,208
15년 전 조회 1,306
15년 전 조회 1,293
15년 전 조회 1,247
15년 전 조회 1,198
15년 전 조회 1,246
15년 전 조회 1,387
15년 전 조회 1,427
15년 전 조회 2,923
15년 전 조회 1,259
15년 전 조회 1,912
15년 전 조회 1,790
15년 전 조회 1,919
15년 전 조회 1,613
15년 전 조회 2,120
15년 전 조회 924
15년 전 조회 1,393
15년 전 조회 1,374
15년 전 조회 3,151
15년 전 조회 3,532
15년 전 조회 2,209
15년 전 조회 1,655
15년 전 조회 2,285
15년 전 조회 1,770
15년 전 조회 1,392
15년 전 조회 4,073
15년 전 조회 1,747
15년 전 조회 1,815
15년 전 조회 3,110
15년 전 조회 1,799
15년 전 조회 4,475
15년 전 조회 2,680
15년 전 조회 3,459
15년 전 조회 2,088
15년 전 조회 2,318
15년 전 조회 1,609
15년 전 조회 4,667
15년 전 조회 4,317
15년 전 조회 4,121
16년 전 조회 5,512
16년 전 조회 3,744
16년 전 조회 2,102
16년 전 조회 2,055
16년 전 조회 2,201
16년 전 조회 1,902
16년 전 조회 4,339
16년 전 조회 3,231
16년 전 조회 2,402
16년 전 조회 1,980
16년 전 조회 2,185
16년 전 조회 2,687
16년 전 조회 1,771
16년 전 조회 2,699
16년 전 조회 2,017
16년 전 조회 2,146
16년 전 조회 1,796
16년 전 조회 2,493
16년 전 조회 1,823
16년 전 조회 2,238
16년 전 조회 2,395
16년 전 조회 1,490
16년 전 조회 1,553
16년 전 조회 2,207
16년 전 조회 5,620
16년 전 조회 1,925
16년 전 조회 2,451
16년 전 조회 2,643
16년 전 조회 1,803
16년 전 조회 1,589
16년 전 조회 2,510
16년 전 조회 5,221
16년 전 조회 2,500
16년 전 조회 3,159
16년 전 조회 2,025
16년 전 조회 3,900
16년 전 조회 4,729
16년 전 조회 3,372
16년 전 조회 2,612
16년 전 조회 2,713
16년 전 조회 2,954
16년 전 조회 2,463
16년 전 조회 5,841