그래프 만들기-gd 안쓰고

· 15년 전 · 2371

<?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,386
15년 전 조회 1,363
15년 전 조회 2,629
15년 전 조회 2,514
15년 전 조회 5,500
15년 전 조회 1,467
15년 전 조회 4,228
15년 전 조회 1,360
15년 전 조회 1,654
15년 전 조회 1,622
15년 전 조회 1,609
15년 전 조회 1,114
15년 전 조회 1,362
15년 전 조회 1,505
15년 전 조회 1,407
15년 전 조회 2,136
15년 전 조회 1,278
15년 전 조회 1,339
15년 전 조회 883
15년 전 조회 993
15년 전 조회 956
15년 전 조회 922
15년 전 조회 870
15년 전 조회 935
15년 전 조회 1,074
15년 전 조회 1,096
15년 전 조회 2,613
15년 전 조회 940
15년 전 조회 1,593
15년 전 조회 1,463
15년 전 조회 1,585
15년 전 조회 1,294
15년 전 조회 1,781
15년 전 조회 598
15년 전 조회 1,087
15년 전 조회 1,059
15년 전 조회 2,850
15년 전 조회 3,165
15년 전 조회 1,836
15년 전 조회 1,348
15년 전 조회 1,965
15년 전 조회 1,471
15년 전 조회 1,075
15년 전 조회 3,768
15년 전 조회 1,409
15년 전 조회 1,508
15년 전 조회 2,737
15년 전 조회 1,431
15년 전 조회 4,159
15년 전 조회 2,372
15년 전 조회 3,148
15년 전 조회 1,768
15년 전 조회 1,995
15년 전 조회 1,295
15년 전 조회 4,372
15년 전 조회 3,954
15년 전 조회 3,776
15년 전 조회 5,191
15년 전 조회 3,413
15년 전 조회 1,793
15년 전 조회 1,751
15년 전 조회 1,900
15년 전 조회 1,590
15년 전 조회 3,992
15년 전 조회 2,900
15년 전 조회 2,086
15년 전 조회 1,664
15년 전 조회 1,901
15년 전 조회 2,381
15년 전 조회 1,465
15년 전 조회 2,398
15년 전 조회 1,734
15년 전 조회 1,832
15년 전 조회 1,485
15년 전 조회 2,173
15년 전 조회 1,503
15년 전 조회 1,921
16년 전 조회 2,111
16년 전 조회 1,185
16년 전 조회 1,249
16년 전 조회 1,894
16년 전 조회 5,336
16년 전 조회 1,634
16년 전 조회 2,143
16년 전 조회 2,346
16년 전 조회 1,495
16년 전 조회 1,305
16년 전 조회 2,218
16년 전 조회 4,932
16년 전 조회 2,209
16년 전 조회 2,865
16년 전 조회 1,746
16년 전 조회 3,598
16년 전 조회 4,437
16년 전 조회 3,103
16년 전 조회 2,350
16년 전 조회 2,431
16년 전 조회 2,682
16년 전 조회 2,167
16년 전 조회 5,508
🐛 버그신고