그래프 만들기-gd 안쓰고

· 15년 전 · 2362

<?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,380
15년 전 조회 1,353
15년 전 조회 2,616
15년 전 조회 2,503
15년 전 조회 5,490
15년 전 조회 1,456
15년 전 조회 4,219
15년 전 조회 1,349
15년 전 조회 1,642
15년 전 조회 1,609
15년 전 조회 1,604
15년 전 조회 1,105
15년 전 조회 1,353
15년 전 조회 1,494
15년 전 조회 1,398
15년 전 조회 2,126
15년 전 조회 1,270
15년 전 조회 1,323
15년 전 조회 870
15년 전 조회 984
15년 전 조회 945
15년 전 조회 912
15년 전 조회 861
15년 전 조회 922
15년 전 조회 1,067
15년 전 조회 1,086
15년 전 조회 2,604
15년 전 조회 932
15년 전 조회 1,584
15년 전 조회 1,454
15년 전 조회 1,574
15년 전 조회 1,282
15년 전 조회 1,769
15년 전 조회 592
15년 전 조회 1,079
15년 전 조회 1,048
15년 전 조회 2,839
15년 전 조회 3,154
15년 전 조회 1,831
15년 전 조회 1,337
15년 전 조회 1,955
15년 전 조회 1,461
15년 전 조회 1,063
15년 전 조회 3,757
15년 전 조회 1,399
15년 전 조회 1,497
15년 전 조회 2,724
15년 전 조회 1,425
15년 전 조회 4,150
15년 전 조회 2,363
15년 전 조회 3,141
15년 전 조회 1,759
15년 전 조회 1,987
15년 전 조회 1,287
15년 전 조회 4,365
15년 전 조회 3,938
15년 전 조회 3,767
15년 전 조회 5,182
15년 전 조회 3,401
15년 전 조회 1,782
15년 전 조회 1,745
15년 전 조회 1,888
15년 전 조회 1,581
15년 전 조회 3,981
15년 전 조회 2,893
15년 전 조회 2,078
15년 전 조회 1,656
15년 전 조회 1,892
15년 전 조회 2,373
15년 전 조회 1,457
15년 전 조회 2,391
15년 전 조회 1,724
15년 전 조회 1,820
15년 전 조회 1,475
15년 전 조회 2,164
15년 전 조회 1,495
15년 전 조회 1,908
15년 전 조회 2,101
15년 전 조회 1,178
15년 전 조회 1,238
15년 전 조회 1,882
15년 전 조회 5,326
16년 전 조회 1,628
16년 전 조회 2,136
16년 전 조회 2,336
16년 전 조회 1,486
16년 전 조회 1,294
16년 전 조회 2,208
16년 전 조회 4,924
16년 전 조회 2,200
16년 전 조회 2,856
16년 전 조회 1,737
16년 전 조회 3,589
16년 전 조회 4,426
16년 전 조회 3,095
16년 전 조회 2,342
16년 전 조회 2,422
16년 전 조회 2,672
16년 전 조회 2,159
16년 전 조회 5,502
🐛 버그신고